title: Best way to lazy load blob from database in Java?

text: I have a database table that stores uploaded files (excel files) in a blob field. Each record contains the uploader, upload-time, the upload ID (primary key) and of-course, the blob itself. At some point, I need to get that data from the database do something with it. Currently, I have a POJO which just mirrors the table structure and stores the file in a byte array, ie;               class Upload {         private String ID;         private ByteArray[] data;         //Other fields and methods ommited for brevity     }      As I am sure you will agree, this leaves the application open to memory issues if the file is particularly large. In reality, this file is unlikely to get so large as to cause a problem, but this definitely can't be considered a good design. I have been trying to find what the best practices are for lazy-loading blob data but I am having trouble finding material that isn't about using particular application frameworks. I am thinking I need to lose the 'data' field and just have a method, ie. getData(), that starts a new DB transaction to retrieve the blob returns an InputStream to it? See below for example, please let me know if there is a better way to do this..               public InputStream getData(){         //Construct and execute SQL query.         Blob blob = rs.getBlob(1);         return blob.getBinaryStream();     }


title: What are the most impressive tricks an IDE could pull off with the code?

text: Modern IDEs have a lot of tricks up their sleeves to help with code writing, refactoring, searching. All those are very helpful, but rarely any of them looks like a real "magic" and makes me think "Wow! How did it figure that out?" Can you name any impressive IDE code automation (or other) features that blew your mind first time you saw them?


title: What are the pros and cons for having a dedicated T-SQL developer on your team?

text: Our T-SQL developer just gave his two weeks notice. We have been asked if our team of four developers would like an additional developer. We are offered to do our own T-SQL / Entitiy Framework development or we could get another dedicated T-SQL developer. What are the pros and cons with having a dedicated T-SQL developer on the team? Which would you prefer and why?


title: Entity Framework design help

text: I'm after some advice as to whether I'm on the right track with what I'm doing. I'm developing a WPF app where I need to retrieve a large graph of entities, work on that graph in the UI (display, CRUD), then persist it all back to the database when the user eventually clicks Save. I've used the DbContext POCO code template for my entities. An added complication is that the UI needs to provide undo/redo functionality, and this is where I started to come a bit unstuck. One of the problems with POCO is that you don't get "association fix-up", so when you add a new entity you must remember to set up the relationship on both sides (i.e. `customer.Orders.Add(myOrder);` and `myOrder.Customer = customer;`). Alternatively I could just add the new entity to its parent collection then call DetectChanges(), which has the effect of fixing-up the other side. Either way, there are a couple of things to do when creating a new entity. Deletions are also tricky to handle, not just in POCO but EF in general. To delete an entity I have to call DbContext.Set<>.Remove(entity), but it doesn't feel right having the UI calling into the BLL (my UI view model holds a reference to a BLL class, which in turn holds an instance of the DbContext, ensuring the context is alive from initial retrieval to subsequent saving, giving me change-tracking). Alternatively I could implement an "IsDeleted" flag on my entities, but this will complicate many areas of my application - I would have to remember to filter out entities that are pending deletion, and handle deletions manually in my business tier. Back to the undo/redo - if I need to undo a creation, I guess I just need to remove the entity from its parent and set the parent property to null. As for undoing a deletion, I'm not sure what I need to do here. I'm guessing I have to restore the entity's state to what it was before the deletion, _and_ fix-up both sides of the relationship again? **Edit** \- I've since found that undoing a creation is not straightforward. Although I've removed both sides of the relationship, the context still "knows" about the new entity. I guess I would have to detach it, but again it doesn't feel right having to call through to the BLL to perform such operations. The only other solution I can think of to all this is to manage the graph in a "detached" state, and implement a flag on my entities to track its state (new/updated/deleted). I would then have to manually manage adding/attaching everything to the context when the graph is passed back to the BLL during saving.


title: How should I organize the words of a sentence for better outputs/maintenance and performance?

text: Having this sentence (consider many sentences in the future) > David Henderson Houston patented the first roll film for cameras in 1881. I can make questions like   1\. Who patented the roll film?   2\. When was the first roll film for cameras patented?   3\. What did David Houston patent (in 1881)? The answer will return some or all of the sentence above in a format of answering the who, when and what. My question (and what I am trying to achieve) is to separate this sentence in such a way that I can save it in a DB, smartly and efficiently. I thought of editing this sentence leaving only the main keywords/facts; let's say `David Houston patented the roll film in 1881.` After this, I thought I have to organize the words. So a solution may be to create tables for nouns, verbs, adjectives... separating the sentence in the correct table. Every word will have its unique ID. In the table `answers`, the answer will be saved in a form like 2,23,64,4 every ID is a word... and with some agorithm and sql magic (this is not my point now) it will return the `David Houston patented the roll film in 1881` on the question `who`. What do you think of my thinking of separating the sentences like I wrote above? What are your thoughts on how I should organize the words to access them through a database? Am I entirely off the correct path?


title: Count true array elements

text: In my code (Python+numpy or Matlab, but issue can apply to any array programming language), I often need to count the number of elements in an array where the elements are true. Usually, I implement this as `sum(x>0.5)`, but this may be considered improper. See _Is it correct to add booleans in order to count the number of true values in a vector?_. Numpy has `count_nonzero`, but if there is no special-purpose function, what would be the proper way to write this? For example, in `Matlab`, I can either write `sum(x>.5)` or `length(find(x>0.5))`. The former is slightly faster but may be considered improper (see above). Are there any other alternatives for counting the number of true values in an array, and what should be my criteria for selecting one? (In a low-level language, one would write an explicit for-loop, but that is an extremely inefficient way to implement this in a high-level array programming language)


title: The array class in C# - Implementation questions

text: I am studying the `Array` class in C#. The following is the implementation of `System.Array` class:               [SerializableAttribute]      [ComVisibleAttribute(true)]      public abstract class Array : ICloneable, IList, ICollection, IEnumerable, IStructuralComparable, IStructuralEquatable       I have two questions regarding this:   1. I have read that `System.Array` class is derived from `System.Object`. But why is this not seen in the above definition?   2. ICloneable is implemented in order to allow the Array to be Deep-Copied in case of XML serialization. ICloneable provides only one method - Clone(). What is the advantage of implementing ICloneable explicitly? Why could not Clone() method be directly implemented? Is this a type of providing a Marking Interface pattern where a particular Interface is implemented only to convey a certain characteristic of the class?


title: Nested Enum type in C++ or C#?

text: I've come across a recurring issue in a few of my recent projects in which I find myself using enums to represent state, or type, or something else, and I need to check against a few conditions. Some of these conditions span multiple enums, so I end up with a load of logic in `switch` and `if` blocks, which I don't like. This is a particular problem when having to cast things to and from the enum, like when the enum is being used to check an int that you're getting from a web request or a calculation. Is there something in C++ or C# that can be used as a nested enum? Something like this:               enum Animal     {         Mammal         {             Cat,             Dog,             Bear         },         Bird         {             Pigeon,             Hawk,             Ostrich         },         Fish         {             Goldfish,             Trout,             Shark         },         Platypus    //srsly what is that thing     };      Obviously, it may or may not be declared like that, but you get the idea. The point is that in code you could use it like `Animal thisAnimal = Animal.Mammal.Cat` and then later check `if (thisAnimal.IsMember(Animal.Mammal))` or something like that. I've seen Java's EnumSet, and found them pretty useful, but I don't think they're an exact match for the functionality I'm after. For this example, you'd have to declare an enum with all the animals at one level, and then add them all to the relevant sets. That would mean that when using the original enum, higher-level things like `Mammal` or `Invertebrate` would appear on the same "level" as something very specific like `African Swallow`, which would imply that they were (to some degree) interchangeable, which isn't true. In theory, a nested structure as above might allow you to specify the level of "specificness" needed, so you could get this:               enum Animal::Kingdom.Order.Family.Genus.Species     { /*stuff*/ }          Organism::Kingdom.Phylum.Class.Order.Family thisThing;          thisThing = Animalia.Cordata;                               //compiler error     thisThing = Animalia.Chordata.Aves.Passeri.Hirundinidae;    //compiles OK      Does a structure like this exist anywhere? If not, how might I build one for C++ and/or C# and have it remain as generic and re-usable as possible?


title: Considerations when designing a file type

text: I'm about to start writing a process for saving some data structure from code in to a file of some proprietary, as-yet-undefined type. However, I've never designed a file type or structure before.   * Are there any things, generally speaking, that I should consider before starting my design?   * Are there any accepted good practices here? Bad practices I should avoid?   * Any absolute do's and don'ts?   * Can anybody recommend any good reading on this topic?


title: Delphi doesn't have Lambda Expressions and I'm a Delphi programmer, what am I missing out on?

text: I'm nearly clueless as to what a lambda expression is, but I have a hard time believing that I couldn't finagle something to the same effect in Delphi (albeit with 900% more code). What is the big advantage of lambda expressions, what am I missing out on and is there anything with the post Delphi 2009 RTL improvements that comes close to emulating the powers of C# in this regard?


title: Where do you get new software ideas from?

text: The world of software creation is very competitive. I've heard it said to be successful you need to be the first one with the idea. Everyone knows how Bill Gates created IBM DOS on one machine while simultaneously building MS-DOS on another machine (and we all know how that turned out). In order to be the first to come up with a new software product, where do you go looking for fresh ideas? **Update 06/26/13:** Reworded this question in an attempt to get it reopened. Bill Gates developed MS-DOS at the same time he was hired to develop IBM DOS. As a programming community, we would all gain by understanding how to think up great ideas for software. As programmer we tend to get stuck in our thinking... it's refreshing to hear how fellow programmers busted out and came up with their ideas. It's not very likely that we will have an MS-DOS opportunity like Bill Gates. Please vote to reopen.


title: What advantages would the Twitter streaming API provide?

text: I'm in the very early stages of writing an application to mine through Twitter data looking for certain types of information. I've been using Twitterizer, which I have found effective in downloading the information (it provides interfaces to the "old" REST based API, and the newer streaming one). This would only be for personal use, so I don't think I would max out the number of API calls per hour on the old API, and it seems as though the streaming API is slightly slower. On the surface, it seems like the REST would suit me better, but I'm wondering if I'm missing any hidden advantages to using the streaming API that could benefit my application.


title: Programming in the Security Field?

text: Is there such a market for programmers who are interested in security (exploits, antivirus, firewalls, etc)? Reason I ask is that I really love software development and I am also interested in security. I'm wondering if I can have a career in this field. If there is such a market, what kinds of concepts and topics should I learn? Any particular languages or operating system? I know some basic networking concepts, C, Unix..


title: Is there an API for determining congressional districts?

text: I'm looking to determine the congressional district based on an address my user is providing. This will avoid having the user to look it up themselves. Does an API of this sort exist? **Note** Through my attempts to find one, I've only come across these:   * http://www.govtrack.us/developers/api   (not sure how to submit an an address or zip code however) > The following resources are available in the API > > ...Bills and resolutions in the U.S. Congress since 1973 (the 93rd > Congress). > > ...A (bill, person) pair indicating cosponsorship, with join and withdrawn > dates. > > ...Members of Congress and U.S. Presidents since the founding of the nation. > > ...Terms held in office by Members of Congress and U.S. Presidents. Each > term corresponds with an election, meaning each term in the House covers two > years (one 'Congress'), as President four years, and in the Senate six years > (three 'Congresses'). > > ...Roll call votes in the U.S. Congress since 1789. How people voted is > accessed through the Vote_voter API. > > ...How people voted on roll call votes in the U.S. Congress since 1789. See > the Vote API. Filter on the vote field to get the results of a particular > vote...   * http://www.opencongress.org/api   (seems to be a way to find congress information, but not districts) > This API provides programmers with structured access to all the data on > OpenCongress, everything from official bill info to news and blog coverage > to user-generated votes on bills and much more... > > This API defaults to returning XML. All queries can also return JSON...   * https://groups.google.com/forum/?fromgroups=#!topic/opendems-discuss/CeKyi_aANaE   (similar question, no resolution) > I've been looking over Open Dems, and seeing what's exposed at this point > and what isn't. I work with Democrats Abroad, and am interested in using > stuff from the lab for their sites. > > I quickly looked over the Precinct API, which does both more and less than > what I'd need. An ideal resource would be any way of translating addresses > into CD at the very least (getting state district data would be good as > well), since that would make it easier for DA's membership to make a > difference in races like last month's NY26 race... **Update** I'm looking at the source for the govtrack.us website and the 'doGeoCode' function may be useful. view-source:http://www.govtrack.us/congress/members If no one has any suggestions, I will try to go off of what they are doing.


title: A measure of development speed

text: I've seen a lot of tests measuring execution speed of programming languages, but I've never found tests measuring development speed. I've heard development speed is increased when working with dynamic languages, but is there any proof of that ? I'm not trying to say dynamic languages aren't efficient, but I'd kind of like to see the results of a scientific study, if such a thing exists. Even better would be informations on maintenance facility. Are some languages easier to debug than others ? EDIT : I'm mostly interested in the differences between two languages that are close in syntax. For example, I guess programming in C will usually be slower than programming in Java; but is programming in Java faster than programming in C# ?


title: Is comparing cloud computing to main frames a bad analogy?

text: They both can be seen as centralized processing, but from a developer's perspective is it returning us to the days when access to computers you could program yourself were limited and expensive? To me that was the problem the PC solved. Heard this on http://thisdeveloperslife.com/ 1.0.6 Abstraction.


title: messaging class and global state

text: This is a front end project that is using socket.io for all communication with the server. This allows for push which is good, but recently we have been asked to provide a pause button. The pause button is intended on stopping the data from changing out on the ui if the user does not wish it to do so automatically. We currently have a class that wraps the web-socket and provides very minimal wrapping of socket.io. The problem is, we can't just turn off the socket. User interactions need to continue to work, and different views have different specs as to what messages need to be ignored. Ultimately its a big global boolean no matter how you slice it, and that sucks. I would rather not have it truly be a global variable, so here are the idea's I've had so far: * * * **Narsty Global**                 // A non pausable listener       socket.on('myEvent', function(data){           // do thing       });            // A pausable listener       socket.on('myPausable', function(data){           if(window.isPaused){ return false; }           // do thing       });      * * * **Passed Value**                 // A non pausable listener       socket.on('myEvent', function(data){           // do thing       });            // A pausable listener       socket.on('myPausable', function(data, isPaused){           if(isPaused){ return false; }           // do thing       });      * * * **Wrapped Method**                 // A non pausable listener       socket.on('myEvent', function(data){           // do thing       });            // A pausable listener       socket.onLive('myPausable', function(data){           // do thing       });      * * * **Separate Class**                 // A non pausable listener       socket.on('myEvent', function(data){           // do thing       });            // A pausable listener       liveData.on('myPausable', function(data){           // do thing       });      Currently there is ALOT of messaging taking place over the socket, and there is only going to be one 'PAUSE' toggle on the UI, so this needs to be done carefully. Advice and best practices are appreciated. Thanks folks.


title: What is Domain Driven Development in practical terms?

text: I heard about Domain Driven Development from a developer in the area. He talked it up like it was just about the silver bullet to changing requirements. I read the wiki. Still not too clear. What is "3D" in practical terms? Is it really that amazing that now UML class diagramming is just obsolete?


title: Equivalent of common IntelliJ actions in vim for C development

text: I am attempting to move from IntelliJ IDEA to vim, primarily for C development. What are the equivalent of the following common IntelliJ features/tasks in vim (and what plugin is required if any)? **Source Navigation** 1) Find file in project by name (Ctrl + Shift + N) 2) Navigate to [Function] Declaration (Ctrl + B / Ctrl + Right Click) 3) File Structure Pop-up (Ctrl + F12) 4) "Forward" (Ctrl + Alt + Right) 5) "Back" (Ctrl + Alt + Left) **Refactoring** Note that for the following, I don't want just "find/replace." If I change a single function definition, I want all occurrences of that function updated in the project (as a single command). 6) Rename File / Function / Variable (Shift + F6) 7) Change Function Signature (Ctrl + F6) 8) Inline Function (Ctrl + Alt + N) 9) "Safe Delete" (Alt + Delete) Safe Delete helps you delete a file / function / variable without breaking your compile. So, (for C) you could delete a *.h file from your project, with the operation listing the other files that import functions defined in that header and giving you the chance to cancel the delete. **Other** 10) Show Usages (Ctrl + Alt + F7) This is different from just "grep" as it gives you the option to exclude matches in comments, documentation, etc. 11) Surround with... (Ctrl + Alt + T) In IntelliJ, I most commonly use this to surround method calls with "try/catch/finally." Perhaps not something that is needed much in C development? 12) Quick Documentation (Ctrl + Q) IntelliJ pops up the JavaDoc in a tiny window, giving you the option to select from possible matches (if more than one). Here, I would expect equivalent except in a newly-opened split buffer. 13) Using Control-Space for keyword completion.


title: Split git repository in two?

text: Nearly a year ago, I started writing a game. I was just messing around at the time, but now I'm pretty serious about it. As it's grown, it's taken on the responsibilities of a major game engine, as well as the game logic of an actual game. At some point, I decided I should break the two out, and designate a game and a game engine. I kept this separation in mind as I programmed for about the last 8 months, but I never did actually separate them. Now I intend to finally move forward with this. The project is all in one git repository right now. I'd like to have two repositories; one for the game engine and one for the game. I have two concrete questions: 1) How should I split the repository? I'd like to maintain history, so I'm thinking I'll just cp the repository, prune the two, and then check in. Any better ideas? 2) Should I add my game assets (models, images, sounds..) to the game repository, or should I make a third for these? I have quite a few assets, and many are subject to change, so it could create an inconvenient amount of noise.


title: Can I use CodeSynthesis XSD (C++/Tree mapping) together with a GPLv3-licensed library?

text: Is it possible to write an open source project that uses generated code from CodeSynthesis XSD (C++/Tree) and then link it to a third-party library that is licensed under the **GPL version 3**? Some background information: CodeSynthesis XSD is licensed under the **GPL version 2** but with an extra FLOSS exception (http://www.codesynthesis.com/projects/xsd/FLOSSE). C++ source code generated from CodeSynthesis XSD (C++/Tree) needs to be linked against **Xerces** (http://xerces.apache.org/xerces-c/) that is licensed under the **Apache License 2.0**. **Update** I posted a similar question on the xsd-users mailing list two years ago but I didn't fully understand the answers. In that email thread, I wrote: _I think it is the GPL version 3 software that doesn't allow itself be linked to software that can't be "relicensed" to GPL version 3 ( for instance GPL version 2 software ). That would also include XSD as the FLOSS exception doesn't give permission to "relicense" XSD to GPL version 3._


title: Is a genetic algorithm a correct approach to this problem?

text: I am trying to calculate a set of items that produce the highest damage output in a video game. There are about 50 different items, of which you can choose 6. There are all sorts of conditions that each item creates. I am writing a small app in javascript that calculates your damage based on the items. Could I utilize a genetic algorithm to find out which item combinations are the strongest? Or is brute force acceptable for this size of a problem? Or is there another way?


title: Where to start a software Analysis & Designing?

text: I am starting a big database-oriented software project to develop. I have full picture of the software in mind. I need to do the designing using UML. As there are various tools in UML such as usecase, class diagram, statechart, component diagram, deployment diagram, activity diagram and so on, where should I start my designing. Should it be from Usecase or from Class Diagram, or from State Chart? Which approach will help me to put my mind's picture in to design?


title: What is the best toolkit for writing long technical texts?

text: I'm looking for a toolkit in the form of one or a couple of applications that can be used to write long technical texts (such as an introduction to a programming language).   * What applications (or combination of) are suitable for this?   * How should said applications be setup (for example how would one setup MS Word to best fit writing a technical text)?   * How do you deal with source code, syntax coloring and formatting?   * In the case of it being several applications, how do you interact between them?


title: Is there a more efficient way to filter large arrays than preg_match()?

text: I have a log that our web application builds. Each month it contains around 16,000 entries of a string with about the average sentence worth of text. To filter/search through these in our admin panel the script uses `preg_match()` but this seems to be taking ages and timing out on the 30sec limit. I have isolated that it is indeed the `preg_match()` that causes the time out. Is there a more efficient way to search through values in a large array for a users input?


title: LOOP-computable functions

text: I was just reading a chapter about LOOP-computable functions and I have the following question: Is it possible to numerate every LOOP program with an algorithm? Formally: Is it possible to have a LOOP program M, s.t M(n,m)=P_n(m) (input is n,m. output is P_n(m), where P_n is the numeration of the loop programs).


title: Application workflow

text: I am in the planning process for a new application, the application will be written in PHP (using the Symfony 2 framework) but I'm not sure how relevant that is. The application will be browser based, although there will eventually be API access for other systems to interact with the data stored within the application, again probably not relavent at this point. The application manages SIM cards for lots of different providers - each SIM card belongs to a single provider but a single customer might have many SIM cards across many providers. The application allows the user to perform actions against the SIM card - for example Activate it, Barr it, Check on its status etc Some of the providers provide an API for doing this - so a single access point with multiple methods eg `activateSIM`, `getStatus`, `barrSIM` etc. The method names differ for each provider and some providers offer methods for extra functions that others don't. Some providers don't have APIs but do offer these methods by sending emails with attachments - the attachments are normally a CSV file that contains the SIM reference and action required - the email is processed by the provider and replied to once the action has been complete. To give you an example - the front end of my application will provide a customer with a list of SIM cards they own and give them access to the actions that are provided by the provider of each specific SIM card - some methods may require extra data which will either be stored in the backend or collected from the user frontend. Once the user has selected their action and added any required data I will handle the process in the backend and provide either instant feedback, in the case of the providers with APIs, or start the process off by sending an email and waiting for its reply before processing it and updating the backend so that next time the user checks the SIM card its status is correct (ie updated by a backend process). My reason for creating this question is because I'm stuck !! I'm confused about how to approach the actual workflow logic. I was thinking about creating a Provider Interface with the most common methods `getStatus`, `activateSIM` and `barrSIM` and then implementing that interface for each provider. So `class Provider1 implements Provider` \- Then use a Factory to create the required class depending on user selected SIM card and invoking the method selected. This would work fine if all providers offered the same methods but they don't - there are a subset which are common but some providers offer extra methods - how can I implement that flexibly ? How can I deal with the processes where the workflow is different - ie some methods require and API call and value returned and some require an email to be sent and the next stage of the process doesn't start until the email reply is recieved ... Please help ! (I hope this is a readable question and that this is the correct place to be asking) **Update** I guess what I'm trying to avoid is a big `if` or `switch` / `case` statement - some design pattern that gives me a flexible approach to implementing this kind of fluid workflow .. anyone ?


title: URL Encryption vs. Encoding

text: At the moment non/semi sensitive information is sent from one page to another via GET on our web application. Such as user ID or page number requested etc. Sometimes slightly more sensitive information is passed such as account type, user privileges etc. [EDIT: I may have worded this wrong, I'm not passing sessionID or actual user privileges, just simple NON-sensitive data - I just don't want the user to see the words easily, does not matter if a more technical user can read it as they cannot do any damage and cause security concerns. _readthe chat with @delnan_] We currently use base64_encode() and base64_decode() just to de-humanise the information so the end user is not concerned. Is it good practice or common place for a URL GET to be encrypted rather than simply PHP base64_encoded? Perhaps using something like, this:               $encrypted = base64_encode(mcrypt_encrypt(MCRYPT_RIJNDAEL_256, md5($key), $string, MCRYPT_MODE_CBC, md5(md5($key))));          $decrypted = rtrim(mcrypt_decrypt(MCRYPT_RIJNDAEL_256, md5($key), base64_decode($encrypted), MCRYPT_MODE_CBC, md5(md5($key))), "\0");      Is this too much or too power hungry for something as common as the URL GET.


title: Can you get in trouble using programming forums or Q&As at work?

text: **Can you get in trouble using programming forums at work?** I'd like to know when it is an acceptable practice and how much is **too much** when it's going to using StackOverflow, or Programmers.SE, for example. Developers and managers may have a different perspectives when it comes to that.


title: Why is Scheme my first language in university?

text: I hear about C, C++, Java every day whenever people starting talking about computer science, but in my first computer science class we are asked to write in Scheme (DrRacket). Why is that? What differences will this make to my future understanding of programming? UPDATE: I have finished my first term, but not completely done with Scheme. In my second term (which is now) we got in to C programming. It was frustrated to learn pointers at first, but now I feel much better. There's not much more to say than that. I'm trying to teach myself Java (or C++?) for the OOP part which I'm missing. So far, I still like functional programming best. Lambda is just fascinating. :)


title: Generalize, or Fix The Problem?

text: Which of these two programmers is "better", from a managerial standpoint? The first programmer is Albert. You tell Al to make a system that will pass you the salt at the dinner table. He does it in less than a day. It works fine. The second programmer is Ben. Ben is _told_ to make a program to pass the salt, and after two days, he's still working on it. ![The General Problem](http://i.stack.imgur.com/FZKx7.png) It will save time in the long run...if you need pepper, ketchup, etc. There isn't any clear indication that there will be a need for this, but it's not improbable. Who's the better programmer to have working under you, as a manager?


title: How to allow filtering Films in my app intuitively? (GUI design)

text: I am not sure if this is the right place to ask this but I wrote an app that shows all the movies in one's computer with the appropriate info such as genre, director, rating, etc. I am wondering how can I make it so that the user can filter them based on criteria such as genre, rating, etc? Most of them are enums, and I was thinking of using a `ComboBox` for these but they should be able to specify more than 1 genre. So should I use `ListBox` controls for these? Then it will be harder to present all these options in listboxes. I haven't seen any examples of apps doing similar things, that's why I am not sure. Any ideas? ![enter image description here](http://i.stack.imgur.com/FXk8Q.png)


title: Designing complex query builders in java/jpa/hibernate

text: I need to build complex sql queries programatically, based on large filter conditions. For example, below are few sample/hypothitical filter conditions, based on which i need to fetch users Country: india States: Andhra Pradesh(AP), Gujarat(GUJ), karnataka(KTK) Districts: All districts in AP except 3 district, 5 any districts from GUJ, all district from KTK except 1 district Cities: All cities in AP, all cities except few, include only 50 specific cities from KTK Villages: similar conditions like above with varies combinations... Currently, we have a query builder, which is very complex in nature, and not easy to modify/re-factory for improvements. So, thinking of complete re-design of it. Any suggesations on how to build this kind of complex query builders programmatically using some best practices/deisgn patterns?


title: Exploiting creativity with "free time"

text: Some companies have discovered, to their surprise and profit, that programmers are very creative people. I think of Google and Atlassian, for example, who allow regular (monthly, I believe) "free days" where programmers get to work on whatever they want (with approval) and the company reaps the rewards. Examples cited were new products, bug fixes that no one had wanted to fix before, new teams forming, etc. Another result (and perhaps the original goal) is that for the remaining days between free time programmers have more motivation. Is there more backing to this theory, that allowing a "controlled" creative output is good for motivation and morale, or more examples of successes with this approach?


title: Can I change the name of a project in codeplex before publishing?

text: I started a project repo on codeplex and haven't publicly published it yet. I realized that the name I gave to it is not appropriate and would like to change the name of the project before publicly releasing it (they have a 30 day deadline). The name of the directory that hg clone needs, i.e., `dirname` in `https://hg01.codeplex.com/dirname` is ok, but the project shows up in a different name in codeplex, and that is the name I want to change. Is this possible?


title: CSS for Visually Impaired people?

text: So while I was learning HTML I encountered CSS. It's interesting because with CSS you can make a webpage cool or more beautiful. But since it's more about colors, designs, styles etc., I can't know the results of my CSS codes. As someone who is visually impaired, why should I learn CSS if sighted people can always design a webpage better than me because they can see?   1. Are there blind programmers here who write CSS? How did you do it?   2. Should I disregard CSS all together and leave it to sighted programmers? Or there are some things in CSS that I can do without asking people to look at my page to know if it has good design?


title: Programming for the iPhone

text: Whats the best way to get started on iPhone development if you are an expeienced C++ or C# programmer? Most books either assume you know nothing or something. What are the steps to achieve this? For eg: first learn objective C (let's say), next learn cocoa... I am interested in books/resources. I read Getting started with iPhone development from Oreilly (the missing manuals book) but that just provided an over view on the programming and concentrated more on getting your app into the app store. I need resources that will help me start coding. Other questions: How much of objective C do you need to know? How do I start learning the cocoa framework? Can I directly start on cocoa touch or do I need to know the MAC cocoa framework first? Inputs from someone who was in the same situation (Know c++/c# but no clue about mac programming/objective c/cocoa) would help greatly.


I have worked as a developer for over 10 years now. During that time I have had my own small projects where I have developed tools, applications and games. I have not found any robust solution to store my work. It’s always fun to get back to your code and see how you did before and how you would do it now. It’s just work that is unfortunate to lose. There are SVN solution such as Google’s Project Hosting. However I’m not interested in sharing my code or making it open source. Currently I’m hosting my own SVN server. So here comes my question: How and where do you store your private work/sourcecode? Requirements:   * Sourcecode versioning   * Backup   * Prefers free   * **Edit:** Remote access **Edit:** I have used Dropbox + TrueCrypt + SVN. Unfortunately you are limited to 5gb.


title: When using Java Persistence API (JPA), which layer owns the entities?

text: When working with annotations on entities in JPA, do these entities belong to the model layer or the persistence layer? Does there have to be some kind of clone of the entities (simple JavaBeans) in the model layer so it could be decoupled entirely from JPA? What is the best practice here?


title: Is programming or computer science in general, all about algorithms?

text: As a grad student, I find it more and more common for prestigious companies (like Google, Facebook, Microsoft,...) to put algorithm questions in their test and interviews. A few startups I applied to also asked about algorithms. I wonder if algorithms fluency is the most important thing for software developer in those companies? If the answer being yes, what are the best method or resources for one to learn & practice about algorithms effectively? I can't seem to get interested in solving seemingly too complicated problems found in most textbook or websites. Though easily understand basic algorithms (like quicksort, bubblesort,...), I find it immensely difficult to remember and reuse them later. Thanks. P/S: If you ask me what I like, it's building good softwares to solve users' problems innovatively. I suppose that does not necessarily mean the software has to be very complicated.


title: Should I require users to register to use my app?

text: So I'm very close to releasing an app I've been working on, and the server I integrate with allows me to register users. So I was wondering if I should require users to register with the app before they use it. The app wouldn't "need" the registration for any of the features (although I have some ideas about future updates where the user's data could be saved to their account in the cloud), but it would still be nice to have a list of registered users. One reason I think I should require users to register is because when the app launches for the first time, the user must accept my privacy policy and terms of use; so if I made a registration screen, it might be an easier and more straightforward, rather than bombarding the user with the thick legal language. But I'm afraid requiring the user to register will cost me some users. I once downloaded an app, and it wanted me to register, but I was lazy never did. Is that a legitimate fear with requiring registration? Thanks! **Edit:** To clearify, if I was to require registration, what info should I collect: name, email, password? other? And we wouldn't be spamming them with emails at all. We also have a very strong privacy policy and would store all data securely.


title: How hard would it be for Microsoft to support deployment of .net apps onto OSX and linux

text: Given the announcement of the windows 8 tablet edition and more details on the app store, it would be amazing if this infrastructure could be leveraged for the OSX desktop and or MonoTouch. http://www.wired.com/gadgetlab/2011/09/windows-8-experience/ Technically how hard would it be for Microsoft to do this? Is the only problem strategic? I know all about Mono, this is a question about microsoft supporting it directly from Visual Studio.


title: Why it is called "hash table", or "hash function"? Hash doesn't make any sense to me here

text: It's now about 4 years of development that I'm using, hearing, talking about, and implementing hash tables and hash functions. But I really never understand why it's called hash? I remember the first days I started programming, this term was kind'of **cumbersome terminology** to me. I never figured out what is it, **based on its name**. I just experimentally understood **what it does** and **why and when should we use it**. However, I still sometimes try to figure out why it's called **hash**. I have no problem with **table** or **function** and to be honest, they are pretty deductive, rational terms. However, I think better words could be used instead of hash, like **key** , or **uniqueness**. Don't **key table** or **uniqueness table**. According to my dictionary, hash means:   1. Fried dish of potato and meats (highly irrelevant)   2. # symbol (AKA number sign, pound sign, etc.) (still irrelevant, maybe just a mis-nomenclature)    3. Apply algorithm to character string (still has nothing to do with **uniqueness** , which is the most important feature of a hash table)   4. Cut food   5. Another term for hashish Does anyone know why it's called hash?


title: What are the consequences of Hash-Life running in O(log n)?

text: After reading about the HashLife algorithm, I found that it runs in O(log n). The Game of Life is also Turing Complete, so in theory we should be able to run any algorithm on a "computer" constructed in GoL. As a consequence of HashLife's time complexity, could algorithms run faster? e.g. if an algorithm takes 10 seconds to run on a pc, could it run faster in HashLife on that same pc? An example: An algorithm running takes a 1000 instructions to run. A certain computer can process 1 instruction per second. So that algorithm takes a 1000 seconds to run. Now, if we take that same algorithm and run it on the "computer" in GoL. It would, because of HashLife being O(log n) take 3 seconds? (assuming O(log₁₀n)) I'm probably overlooking something, since this would be a very important discovery, but I still thought I'd ask about it here.


title: testing: which code layers should I aim to test?

text: Say I have this code:               Design     {         public function load()         {             $this->loadProduct();             $this->loadService();             ...         }              public function loadProduct()         {             try             {                 $this->product = new Product();                 $this->product->spec = $this->product->loadSpecs($this->a, $this->b, $this->c);             }             catch (\BadFunctionCallException $e)             {                 $this->error = true;                 $this->emsg = $e->getMessage();             }         }     }      Questions:   1. Do I test `loadProduct` function only?   2. Do I test `Product` class only?   3. Do I move `loadProduct`'s code into `load` (thereby removing `loadProduct` function from existence, and test the larger `load` function (as part of `Design` class)? Say I may want to do this as part of clean up/reorganization of legacy code.   4. Something else?


title: Resizing an image with a non-integral conversion factor

text: I'm resizing an image based on a non-integral conversion factor (a bmp image, in fact). I understand how resizing works, just non with a decimal number. For instance, if the factor were 2, I would simply write the individual pixels twice to the output file. You can't really write 1.5 pixels if the factor were, say, 1.5. Conceptually, how might this play out?


title: What is the difference between releasing code under the BSD license and releasing it as public domain?

text: You are free to use BSD licensed code for **anything** , even commercial, closed source software. How is that any different than just releasing it as public domain?


title: Can Win32 message loops survive being ported to native linux?

text: I would like to port a large Win32 DLL to native linux in C++. I don't think I can use Wine for a DLL like mine, because users of the DLL would then also have to be in Wine, and then they would all whine... As a Windows C++ programmer, I don't (yet) have any familiarity with the GUI front-end services in linux, but if it logically runs on anything like win32 message loops, fonts, bitmaps, invalidation regions, getmessage( ) calls and so forth, it should be a fairly straight forward remapping of my existing code. So what am I looking at here, a remap or a rewrite? The path for such things must be well worn by now.


title: Which to implement first: GUI or backend?

text: So, I can code both, but which should I use a base for development? In terms of TDD, should minimal aspects in the GUI be used as the seed from which to grow towards backend logic? or should the backend give rise to the logic controlling the GUI?


title: How to data model more than one 'last name'?

text: In spanish speaking countries we use more than one last name, like: > First name ↘                           ↙ Last name   >                  **Pedro Arturo Rodríguez Loyola**   >          Middle name ↗                               ↖ (?) I'm trying to model data for patient name, in our country it's important, so I can't neglect the second last name, but I would like to build an application that can makes sense to other developers, specially from English speaking countries. * * * I created a similar question on English.SE, it has some insights about why it's important to persist both values.


title: Am I doing it wrong with Hibernate DAO layer? i.e. Feature Bloat

text: For quick prototyping I have been actively using Hibernate. Recently I came back to an old project and I wondered why I had a lot of DAOs with what I suspect is commonly named feature bloat. E.g. I have a DAOs for single entities that contains from 15 to 20 methods each. Recently I have been using Hibernate Generic D.A.O. Framework but I still think that the same problem arises when I'm trying to create custom data access logic and my code Olfaction starts to detect bad smells. Is there a guideline for this scenarios?


title: Are there any standards for separating different kinds of comments (explanatory, debug, to-do, etc.)?

text: For a while now I've been in the habit of differentiating different kinds of comments in my code.               //this is an explanatory comment          //!this line was commented out for debug purposes, DO NOT SHIP WITH THIS COMMENT IN PLACE          //?this code was tested, and executed properly in 2.3 uS      This has saved me a lot of trouble, as I can quickly differentiate between debug comments and explanatory comments. It's especially nice to be sure that all my debug comments are gone, and none were accidentally left in place before publishing my code. Is this a common practice? If so, is there a standard way of differentiating comments? Or are there perhaps better ways of achieving what I'm trying to achieve?


title: Need help on understanding few OOP & programming related concepts

text: I been struggling to understand few concepts but no success yet. Can someone help me to understand that with simple example and definition please. 1 - Delegates in .NET 2 - Abstraction 3 - Three tier architecture Thanks


title: Equality between arity and degree concepts in relational theory

text: I've been reading the book "SQL and Relational Theory: How to Write Accurate SQL Code" by C. J. Date. I have no formal background in CS, much less relational theory. Combined with the fact English is not my first language, I'm having a little trouble to understand a statement. At one moment (page 17) the author states: > ... the number of attributes in the heading is the degree (sometimes the > arity) ... Does this means that the concept "degree" is equals with the concept "arity" (ie. I can use those words interchangeably) or this means that sometimes those concepts are equals (but not always)?


title: Classes naming: singular or plural?

text: It is always difficult for me to choose between singular and plural forms for classes names: > >     CustomerRepository vs. CustomersRepository >     CustomerService vs. CustomersService >     CustomerController vs. CustomersController >   And for composite names it is even more difficult: > OrderCustomerRepository vs. OrderCustomersRepository vs. > OrdersCustomersRepository What approach do you prefer and why?


title: Java's Boolean class - why not an enum?

text: It seems to me that the Boolean class is an ideal candidate to be implemented as an enum. Looking at the source code, most of the class is static methods which could be moved unchanged to an enum, the rest become much simpler as an enum. Compare original (comments and static methods removed):               public final class Boolean implements java.io.Serializable,                                           Comparable<Boolean>     {        public static final Boolean TRUE = new Boolean(true);       public static final Boolean FALSE = new Boolean(false);        private final boolean value;        public Boolean(boolean value) {            this.value = value;        }        public Boolean(String s) {            this(toBoolean(s));        }        public boolean booleanValue() {            return value;        }        public String toString() {            return value ? "true" : "false";        }        public int hashCode() {            return value ? 1231 : 1237;        }        public boolean equals(Object obj) {            if (obj instanceof Boolean) {                return value == ((Boolean)obj).booleanValue();            }            return false;        }        public int compareTo(Boolean b) {            return compare(this.value, b.value);        }     }      with an enum version:               public enum Boolean implements Comparable<Boolean>     {        FALSE(false), TRUE(true);        private Boolean(boolean value) {            this.value = value;        }        private final boolean value;        public boolean booleanValue() {            return value;        }             public String toString() {            return value ? "true" : "false";        }     }      Is there any reason why Boolean couldn't become an enum?


title: How to log configuration or code behaviour changes in non-disruptive way

text: We've probably all been in the situation where you'd like to alert your team members to some change ("I changed X, so now it's running every hour instead of every day"). But the change is non-urgent, and email can be disruptive - or get tuned out. Anyone have any techniques where the team can have a running log of changes that everyone should be aware of, that they can peruse at their leisure - or at least, when they suspect something is up?


title: Has whitespace in identifiers ever been idiomatic?

text: C# style suggests using CamelCase in identifiers to delimit words. Lisp tradition suggests using-dashes-instead. Has there ever existed a programming language where using spaces in identifiers was not only allowed, but a commonly used idiom when employing multi-word identifiers? It's possible to have identifiers with spaces in some Scheme implementations, but it's not a widely seen practice. Here's an example:               Petite Chez Scheme Version 8.4     Copyright (c) 1985-2011 Cadence Research Systems          > (define |hey there| 100)     > (define |x y z| 200)     > (list |hey there| |x y z|)     (100 200)


title: Ideal data structure for storing map data?

text: I was asked this in an interview test. I did okay on the test but didn't know enough to answer this question. I am curious to know what data structures I can use to query the data quickly. Basically the idea is there would be road sections (lines, made up of points) stored in some kind of data structure. It should be quick to query which road sections (or points) are within a certain distance from a point (radius).


title: Is declaring STL variables in a class definition too revealing?

text: If you are trying to hide implementation, would declaring STL variables be too revealing?               // in Word_Bucket.h     class Word_Bucket {     private:         std::vector<std::string> contents;              ...etc     }      ... but then if you wrap it up, to hide the implementation, won't you have to reveal it in the wrapper's interface anyway?               // in Word_Bucket.h     class Word_Bucket {     private:         Bucket contents;              ...etc     }          // in Bucket.h     class Bucket {     private:         std::vector<template_stuff> contents;              ...etc     }


title: What if the client needs the ability to retrieve passwords?

text: I've currently inherited an application at work and to my dismay, I have realized that the user passwords stored in the database are encrypted using an in house encryption function, which also includes the ability to decrypt. So all someone really needs to do is copy the user table and copy the encryption assembly (anyone with database production access) and then they would have access to 100,000 email addresses and potential passwords for them. I'm trying to explain to the business why this is not a good idea, but the security concepts seem to go over their head as they are not that technically minded (it's for government). Plus there are actually existing functionality within the application for admin users to retrieve user's passwords in order to log in as them and do stuff (which they have said, they require). So they don't understand the security implications. And in order to implement a stronger security policy (hashing passwords so they can't be easily retrieved), I have to remove existing functionality for them. What should I do? I didn't build the password system in the first place, so it's not like I can be blamed if anything does go wrong. On the other hand, I don't feel good about it and I also don't want to have access to 100,000 potential email logons.


title: How to profile a Perl + FastCGi + StarRunner web program?

text: I've written an extension to RequestTracker for a client, but he says the performance isn't good enough. I'd like to do some profiling, but I'm not sure how to connect up a profiler (say NYTProf, for example)? I tried what the man page says and put `PerlModule Devel::NYTProf::Apache` in my apache config, but all I get in the results are Apache2:XSLoader, Devel::NYTProf::Apache and ModPerl::Util modules in the results, and neither my own nor RT's modules.


title: Database version management on mobile apps

text: I am about to start building a mobile (iOS/Android) app that uses a local database (probably sqlite). Since this is my first "real" mobile app, I am wondering what the standard approaches are to version management of the DB. My thinking is I would do this:   * include a base creation SQL script in the resources of the app. This would include the creation of a `versions` table, which would have one record for every version of the app.   * for every new version of the app, include a corresponding upgrade SQL script. At a minimum, that script would insert a new entry into the `versions` table   * write a data store management service. This service would be responsible for creating the initial DB (via the create script), reporting the current version of the DB, and upgrading it if necessary (via the upgrade scripts)   * leverage the data store management service during application initialization to create/upgrade the database as necessary. This would of course be done asynchronously and with UI telling the user what is happening Is this approach reasonable? Am I overlooking anything obvious?


I recently started learning to write code, and in my book I came across this question. "Why is a Boolean value stored as a byte inside of a computer when it only requires one bit?" can someone shed more light on this question?


title: DRY on API specifcations?

text: When developing a new RESTful application, I generally:   * Define tests   * Define routes [ e.g.: RESTful CRUD; namespaced on `/api/users` ]   * Define models [ e.g.: "Users" ]   * Define forms [ e.g.: in JavaScript (AngularJS), HTML5 and CSS ] Currently thinking about throwing an API explorer into the mix… which would be another bit of double-typing. * * * The best way I can think of for moving forward is:   1. Define new schema once; using JSON-schema notation   2. Engineer a code-generator to generate tests; and some random data with correct types for input   3. Develop a code-generator to create RESTful routes from JSON schema   4. Utilise something like metawidget to generate frontend forms from decoupled backend * * * Is this the best way of encouraging DRY; is there a better/alternate way you can think of / industry best practise?


title: Why Java does not allow function definitions to be present outside of the class?

text: Unlike C++, in Java, we cannot have just function declarations in the class and definitions outside of the class. Why is it so? Is it to emphasize that a single file in Java should contain only one class and nothing else?


title: Importing java.awt.* does not automattically imports java.awt.event.*?

text: In the Java programming language, why does importing of java.awt.* does not automatically import java.awt.event.* too? Now, you guys may say that it's because it's java.awt.* and not something like java.awt. _._ but when any nice, proper java application requiring java.awt.* also requires java.awt.event.* then why not have them as a single entity?


title: Why is sizeof called a compile-time operator?

text: Originally, this is a part of another question. Why is `sizeof` called a compile-time operator? Isn't it **actually** a run- time operator? And if it is indeed a compile-time operator, how does it help in producing portable code which runs the same in different computers ? Please explain in detail.


title: Is the C programming language still used?

text: I am a C# programmer, and most of my development is for websites along with a few Windows application. As far as C goes, I haven't used it in a long time, as there was no need to. It came to me as a surprise when one of my friends said that she needs to learn C for testing jobs, while I was helping her learn C#. I figured that someone would only learn C for testing only if there is development done in C. In my knowledge, all the development related to COM and hardware design are also done in C++. Therefore, learning C doesn't make sense if you need to use C++. I also don't believe in historic significance, so why waste time and money in learning C? Is C is still used in any kind of new software development or anything else?


title: Authentication for 'participants' vs 'users'

text: I'm building a site that lets users schedule interviews/conferences with third parties and I'm wondering what's the best way to provide security around the participant experience while providing the smallest usability barrier possible. Currently, I send an email with a link and a 5 digit auth-code. The link opens a page, the participant types in the auth-code and is temporarily logged in for the duration of the interview/conference. From a security standpoint, I think the auth-code is redundant and introduces friction for the participant, who may never have cause to visit my site again and may not be technically proficient. The link I send as part of the invitation contains a random string, so I could just increase its length by 5 characters and have the same size search space for potential attackers. The downside is that I would potentially have to rate-limit the responses for the invitation URLs, so I'm not sure there's any benefit from a complexity/lines-of-code perspective. The non-auth-code feels less secure, but I know that's irrational. Any thoughts on what the best approach would be?


title: What's wrong in returning hashtable from public method and when does it make sense to do so?

text: What are the design problems in returning a hashtable from a public method when you want to return multiple items instead of creating a class and returning object of that? If it does have problems then under what circumstances it makes sense to do so? How does the answer to this question change depending upon whether the language is dynamic or not? **Edit:** This is to clarify that the keys would be constant and are part of code, not data. Something that we typically create a class for. The question is why would it be wrong to use hashtable instead if creating a class indeed does seem to be the right choice.


title: How to implement DRY principle when using 'using' keyword?

text: Consider these methods:               public List<Employee> GetAllEmployees()     {         using (Entities entities = new Entities())         {             return entities.Employees.ToList();         }     }          public List<Job> GetAllJobs()     {         using (Entities entities = new Entities())         {             return entities.Jobs.ToList();         }     }          public List<Task> GetAllTasksOfTheJob(Job job)     {         using (Entities entities = new Entities())         {             return entities.Tasks.Where(t => t.JobId == job.Id).ToList();         }     }      Using block is the same and has been repeated 3 times here (of course, more than 100 times in the real application). How is it possible to implement DRY (Don't Repeat Yourself) principal for `using` block? Is it considered a breach of DRY principal at all? Update: I'm not talking about what has been implemented inside the `using` block. What I actually mean here, is the `using (Entities entities = new Entities())`. This line is repeated 100 times or more.


title: Which layer should service errors be handled in?

text: I am coding in a multitier architecture in Java, and I perform a query to a web service. Is it better form for the errors returned by the service be handled in the data access layer or in the business layer? For example, the service records a response something like this:               <?xml version="1.0" encoding="UTF-8"?>         <ReturnCode>[integer]</ReturnCode>         <ReturnMessage>[String correponding to ReturnCode]</ReturnMessage>         <UpdateTimestamp>[dateTime - only present if ReturnCode == 0]</UpdateTimestamp>         <UpdateUser>[string - only present if ReturnCode == 0]</UpdateUser>     </xml>      If I handled the errors in the data access layer, my Java code would like something like this: Error logic in DAO. (notice the data type doesn't have `returnCode` or `returnMessage` fields) If I handled the errors in the business layer, the code would look like this: Error logic in BO. (notice the data type has `returnCode` and `returnMessage` fields)


title: Should a competent programmer be able to come up with his own shortest path algorithm?

text: I'm suffering a crisis of confidence in my ability as a computer programmer. Yesterday I tried to come up with my own shortest path algorithm for a graph and after some hours I simply threw in the towel and learned Dijkstra's algorithm. Is this the kind of thing a good programmer should be able to "reinvent" in a couple of hours or am I being unrealistic? Oh well, at least I was able to reinvent bubble sort :D


title: Handling Deployment to Multiple Environments

text: How should I handle deploying web applications to multiple servers? **Constraints** I have a dev, test and prod environment. No build server is available. Developers can't deploy to prod. The people that do deploy to prod copy files from test to prod. They don't have VS installed. **Currently** The way it's handled is using web.config transform. However, to deploy to prod involves putting prod code on the test server where it's copied over. **Problem** Sometimes simple mistakes are made, such as forgetting to change test back to the right environment after deployment. Or the test config gets moved to prod instead of the prod config. **Solution** So the question is, what is the best way to prevent mistakes from happening? My first thought is let the app determine which server it's on at runtime and use the appropriate settings/connection strings/etc... However, the server names could change in the not too distant future. So if multiple apps are hard coded, that would mean updating all of them. The easiest way to handle that situation would be to place a DLL in the GAC that determines the environment. Are there any drawbacks or possible complications that this would cause? Or is there a better solution to the problem than this?


title: How to you solve the problem of implicit locking and parallel execution?

text: Where the code is:               function A()     {         lock()         doSomething()         unlock()     }      We can call `A` safely from multiple threads, but it never be executed in parallel . For parallel execution, we have to evade all of this code. But the problem is we never know the `A` is getting lock or not. If we have source code (maybe lucky case), we have to decode all code to know locking is happening or not. This sucks. But even worse is we normally have no source code. And about the case of the lock is exist on base library? It's obvious this kind of hidden locks will become bottleneck of parallel execution even all the other parts are designed for parallel. And also, (1) With locks, execution cannot be parallel. (2) And I can't know whether the locks are used or not in any code. (3) Defensively saying, I can't make parallel anything! This facts drives me crazy. How do you solve this problem?


title: What you should do if your junior did not adopt your suggestion?

text: I am leading a team of 3-4 junior developers. My job-- besides writing code-- is to provide supervision and guidance for the juniors. But, I fully understand how much developers cherish autonomy in their work, and I don't want to destroy their intrinsic motivation by spoon-feeding them with my thoughts and my algorithms; I want them to explore the problem in their own ways, and think about it themselves and only come to me when they are really facing insurmountable issues. When they do come to me, sometimes I would have to propose a completely different algorithm to solve the problem because their algorithm isn't robust enough ( remember, I am the senior and I have seen more than them). Of course I would explain this in a nice manner so as not to hurt their feelings, and I would gently outline how my solution is vastly superior than theirs, no condescending tone or condemning words. But still, they are sometimes reluctant to accept my suggestion, partly because they have invested so much in their own algorithm, or partly because of the fear that using a new method would entail more learning time and make them appear to the management as if they are going nowhere. But deep in my heart I know very well that my algorithm is much better than theirs and they should just adopt it. What should I do if they didn't adopt my suggestion? Should I just ask them to follow my way, or should I just let them have their heads banged on the wall many many more times and wait for them to come back to me? Doing the former makes me into a dictator, but doing the later would cost us precious development time and incur bug fixing cost. I am really in a dilemma here.


title: Designing communications for extensibility

text: I am working on the design stages of an application that will a) collect data from various sources (in my case that's scientific data from serial ports), keeping track of the age of the data, b) generate real-time statistics (e.g. running averages) c) display, record, and otherwise handle the data (and statistics). I anticipate that I will be adding both data producers and consumers over time, and would like to design this application abstractly so that I will be able to trivially add functionality with a small amount of interface code. What I'm stumbling on is deciding what communication infrastructure I should use to handle the interfaces. In particular, how should I make the processed data and statistics available to multiple consumers? Some things I've considered: * Writing to several named pipes (variable number). Each consumer reads from one of them. * Using FUSE to make a userspace filesystem where a `read()` returns the latest line of data even if another process has already read it. * Making a TCP server, and having consumers connect and request data individually. * Simply writing the consumers as part of the same program that aggregates the data. So I would like to hear your all's advice on deciding how to interface these functions in the best way to keep them separate and allow room for extenstions.


title: What steps should I follow to start developing website applications?

text: I've been developing **desktop applications** for about 4 years, using .NET, C++, C, and a little of Python. I've covered lots of topics while developing my applications, and even web technologies (cookies, GET/POST methods, when programming some scrapers/crawlers). I've been always waiting to start developing websites, preferably using **PHP** \+ **MySQL** , although other advises will be welcomed to make this question more useful and generic for others. I know I could use a **CMS** instead of starting from scratch, but sometimes I don't need an entire CMS to do minor things... **What steps should I follow to create a website?** Let's suppose I have a web designer. First of all, the designer designs the entire website (CSS, etc) and then I do the programming stuffs, like loading dynamically things from databases, doing some client-side stuffs with javascript, etc? Or how is the best way to do it? **Edit** :   I'm not looking for tools/frameworks/languages suggestions. What I want to know is how a team (or a developer with a designer) starts creating a website. The **steps** they do, what tasks they do first, how they integrate the work, etc. An example of an answer could be: 1) Design the entire website with good CSS practices, using containers instead of tables in some cases, etc. 2) Use that design and develop the logic or the functionalities of the website. Of course, that's just an example. I'm looking for a good way to approach it, because I've been wanting to start on it but don't really know how exactly to organize the job :/


title: Should I ditch AJAX in client side web development when I've got a web-socket open?

text: I was thinking that maybe I should forget AJAX (HTTP) requests when I've got a web-socket open between client and server, but I decided I should ask here to check if this could be a bad practice for some reason that I'm not thinking of. Once the socket is open, there's less syntax (often meaning simpler error handling) involved in passing information between client and server with Socket.io (just one example of a web-socket). * * * Is there some obvious situation where a web-socket (Socket.io for example) isn't going to be capable of handling a functionality that an AJAX request could do easily?


title: Logging-in and database connectivity in Android

text: I am completely new to Android development and have been reading many articles on **the Android site** and elsewhere. There are a lot of articles that give very specific examples, but I haven’t bumped into the articles explaining the following: **Logging-In:**   I haven’t noticed market applications forcing me to create login credentials (per se), only verification of access to types of permissions. However, they surely must need some kind of login credential. This means Android is providing this access (somehow). How? What process? **Database Location:**   Some articles I’ve read “imply” a copy of the applications database is located on the phone (itself), others imply a database located elsewhere (cloud etc.). Lastly, others imply they use both a local database for quick updates and a remote database for synching and error-analysis. Is there a common database available for everyone to use?   * I wouldn’t “think” so Do you generate the local copy automatically every time?   * Seems wasteful as you just have to re-create the whole thing and re-synch EVERY entity...but I’ve seen articles promote it. Which databases are you using? What best-practices do you use for synching? **Lastly:**   If this forum isn't the right one I will be happy to move this question. I looked at the **Android Enthusiast** forum and it didn't look like the correct one either.


title: How to politely decline recruiters?

text: Recently, I've received e-mails from tech recruiters inquiring about whether I'd like to interview for job interviews. The main problems I have with these emails are:   1. I'm a college student, and nowhere have I indicated that I want a full time job, but all these opportunities are for full time work.    2. The position descriptions are so vague that they could apply to many, many people.    3. In addition to #2, most of the e-mails seem to be machine generated, and I am wary of people who just send out mass emails. I don't want to disable the "receive emails from others option" and I don't have anything against technical recruiters, but I don't want to apply to the position and I definitely don't want to send my resume to them. In this thread on establishing relationships with unsolicited recruiters, there are a lot of negative points made about recruiters, and this especially stood out to me: > P.S. I once very unfortunately established "relationships" with two spam > centers called computerfutures and progressiverecruitment and haven't been > able to get my data out of their systems ever since. They periodically spam > irrelevant ads and ignore all my requests for data removal and compliance. > That's not a relationship you're seeking. :) > > P.S.#2. A piece of advice. Whenever you decide to publish your CV in the > wild, a good idea is to remove your phone number from there. It will > effectively stop phone drones who depend on being able to harass and squeeze > you on the phone hunting for colleague names and references. They however > prove to be not inclined to waste time and engage in long email exchange > with you preferring to just move on to the next target. This will lower your > manual filtration efforts and save you hours of your phone time. It seems like talking to recruiters is a waste of time and potentially a big hassle, but I don't want to just ignore emails either. **How should you go about politely declining a recruiter such that you can contact them when you want but won't have to worry about being bombarded by them? Is that even possible, or is ignore and forget the best option?**


title: Buy TextMate or PhpStorm for developing?

text: i am going to buy TextMate or phpStorm. Before i do it i want to ask community which one is THE choice. I am maintaining existing php+xml+html+yaml code so as developing new functionalities for same existing system. Sometimes running posture queries, or creating views. I often work with Subversion, sometimes with Git. I use very often quick open for classes and files Following i write to tell what assumptions i have and find out which of them are correct, which are not, or thoughts i am missing Unfortunately i've missed my trial time with TextMate, so i can't test it for my work **TextMate** _Why to buy_   * every developer on Mac, i see has TextMate from which i draw about some qualities   * some of mine projects are in Rails which TextMate covers too _Why not to buy_   * i am missing jump to the definition   * it seems TextMate does not have integrated version controll (changed/new lines, diff between particular versions ), but it supposed to be integrated in some of future versions (but when it is?) **phpStorm** _Why to buy_   * integrated version control   * integrated db query tool   * phpDoc      * generation     * reading (methods completion, type of variable, etc) _Why not to buy_   * price


title: Are session aware Models a bad thing?

text: I'm thinking specifically in Rails here, but I suspect this is a wider question. In a Rails web application I'm using data from the session in models in order that the models know who is logged in. I use this in a method which filters out some data from the database depending on a very simple permissions system. The thing is: using sessions in models in Rails requires a bit of a workaround. It works, but I've a feeling that it's something that I shouldn't be doing and I'm worried there's a big gotcha I'm missing. I suppose the Right Thing To Do would be to return all the data and filter out the not-wanted bits in the controller before passing that to the view, but doing it in the model seems to avoid quite a bit of code duplication and so feels "cleaner." Can anyone tell me why or shouldn't do this? Or that it's not a problem?


title: What programming languages exist for mechatronics purposes?

text: Is there any specific language which is designed for mechatronics programming? I know about LabView, which is a data flow language, but not sure about its main platform. Could you recommend to me, some languages apart from c/c++? Any language which is used in the topic of mechatronics( robotics, sensor programming, etc ).


title: What's special about currying or partial application?

text: I've been reading articles on Functional programming everyday and been trying to apply some practices as much as possible. But I don't understand what is unique in currying or partial application. Take this Groovy code as an example:               def mul = { a, b -> a * b }     def tripler1 = mul.curry(3)     def tripler2 = { mul(3, it) }      I do not understand what is the difference between `tripler1` and `tripler2`. Aren't they both the same? The 'currying' is supported in pure or partial functional languages like Groovy, Scala, Haskell etc. But I can do the same thing (left-curry, right-curry, n-curry or partial application) by simply creating another named or anonymous function or closure that will forward the parameters to the original function (like `tripler2`) in most languages (even C.) Am I missing something here? There are places where I can use currying and partial application in my Grails application but I am hesitating to do so because I'm asking myself "How's that different?" Please enlighten me. EDIT: Are you guys saying that partial application/currying is simply more efficient than creating/calling another function that forwards default parameters to original function?


title: MVP: Multiple Page-Controllers for a page?

text: I'm refactoring a big-scale ASP.NET application written with WebForms which has a very unflexible design of view+code-behind. For this refactor, I'm using MVP Architecture (Model-View-Presenter), which uses a Page Controller approach for pages and controls. Writing a controllers for pages, I've faced a problem of reusability. The following diagram expresses a small sample which will illustrate my problem: ![http://i61.tinypic.com/atoltt.jpg](http://i.stack.imgur.com/LZo8i.jpg) RegistrationView is a view with a form that allows a user to register (introducing data like Name, Address, Country... and then modifies this data through the controller). EditAddressView retrieves already-existing data about the user, allows for modification and then modifies the data back to the model. As you may see, there are some parts in common in the controllers (more specifically, the storage of data). I'd wish to reuse the part of the code where data is stored, so I considered a three options to deal with this:   * Create a superclass that includes the code to be reused, and then make controllers inherit this class and use the store algorithm.   * Create a kind of "library" layer (i.e. UserManagerLibrary) which both controllers would make use of and make respective calls to it.   * Implement a somewhat component system and create controllers that would manage these "components". This diagram illustrates my approach: ![enter image description here](http://i.stack.imgur.com/ttzt5.jpg) NOTE: CountryRetriever obtains a list of countries to populate a dropdown menu. In this approach, I make views to conform to several interfaces, which, together, define a view. Then I bind each view with several page-controllers depending on the interfaces the views implement. This way, I think I could easily create new views and expand functionalities of existing ones (for instance, I could expand the EditAddressView with deletion functionality by making it implement a IUserDelete interface). I think that this approach would allow me to maximize my code reusability and Single Responsibility Principle in a MVP architecture, yet I have the feeling I'm somehow violating the Page-Controller pattern, and the feeling that this approach may have a big drawback in the future for me (I don't know, that's why I'm asking if my solution is good). Can anyone enlighten me on this matter? Thank you


title: Reflecting on finished project with no other technical criticisms?

text: I'm a coop (in college but I work 3 months, then do classes for 3 months, work again for 3 months, etc until I graduate) at a company in their IT department. My job usually has to do with writing software but we are not a software company and much of the software that is is written in India. This work term (3 months) I was given a large project, to design some software to visualize data pulled from another one of our systems. I ended up at the end of this term with two pieces of software for, one 100% done (the data pulling back end) and the other 80% done (the graphical front end). I had fun and learned a lot as always, but I'm not too happy with the results code wise. I have never gotten a chance for a code review or a chance to do any learning about design and analysis strategies for the reason I mention above in the year that I've been here (4 terms). Here's how the project went, and it reflects how I have done pretty much every project to date, although it's more clear in this project as this is the biggest thing I've done so far. The first thing I did was diagram out how the whole system would operate from a high level. I don't usually do this but I was asked to by my boss. Then, I dove right into the problem and start banging away. To me, I find that it helps (and is more fun at the same time) to get something down and working to revise for organization shortly after so that I can continue in an organized fashion. From there the building slowed down a bit as the project got bigger. I would get more confused but also start diagramming more things out first, stopping to think about how what I'm currently building will fit into the entire system. This continued on for a while until my 3 month term was almost up. Here, **I started rushing to get things done. I started destroying some of the organization in favor of quick things so that I could get a working prototype** (I was only asked for a prototype so I figured this was alright and if the project went forward I could always revise it). This is where my entire thing started to fall apart as I didn't really have time to properly think through how a lot of what I was coding would affect everything else. I feel like now, at the final stage, I have a lot a mix of loosely and tightly coupled code with a barely working prototype. In hindsight, here's what I see:   * I did a good job on the original overview and it helped me too because I could break down the entire thing into a few main chunks. Problems started to arise when I got into specifics of each chunk. **There was a good set idea on what each piece would do, but not the specific parts that made that piece work** (I don't know what I could have done more though to explain each piece though. I find when it comes down to specifics like this, I find out as I go).   * There were many things about the system that I was pulling data from that I did not know at the very start and I should have gotten a lot more insight onto how the system works as a whole. However, at the start of the term I'm always shy and tend to not ask questions. This probably also contributed to why I usually don't know the specifics of each piece until I'm actually doing them.   * I was also a victim of a bit of scope creep as few features were added to the todo list with about a month and a half to go.   * I never seem to know exactly where I want to go on specific parts. I try something and if that doesn't work, I try something else until it works or I get something that's neater. Is this the right way to do things? My questions: **What could I have done better?** I know no one here will know the specifics of my project but there's no one else with coding knowledge who could tell me how I could grow in this situation.   **How could I review myself better?** Since I never really have anyone else reviewing my coding and I'm not working with any other coders directly, how could I have reflected better on my own project, both after, and during the project?   The question about what I could do better is directed mainly at the bolded portions of my explanation where I feel most concerned about how I approached the problem.


title: Is there a valid case for two components to depend on each other?

text: Dependencies are services required by an object to perform its responsibilities. In OOP context it can be thought as a parameter in a constructor. In my experience I've never found a case for a valid cyclic `A <--> B` dependency. Every time I find this it turns out to be one of two cases:   * `A` and `B` should actually be a single component (`AB`)   * one of components violates single responsibility principle and should be divided into separate ones (`A1 --> B --> A2`) To be clear, I'm not talking about cycles in objects used for data structures. I'm interested in components which provide behavior and collaborate between themselves.


title: OO Design related questions in technical interviews

text: I've been attending quite a few interviews recently and have been asked by companies to answer "design a [insert model]" questions more than a few times.   1. Is this normal in the industry nowadays? I've been in the software world for more than two decades and have attended my share of interviews, but I am seeing this pattern in interviews emerge only recently.   2. I feel the question is very open ended. For example: I was asked to draw a class diagram to "Design a parking lot". I am not sure what level of detail the interviewer is expecting. This was in an online test where I was expected to attach a visio diagram, so I couldn't ask them what their expectations were.   3. Do you use these kind of questions in your interview process? Are they related to only class diagrams or do you also ask sequence, flowcharts and ERDs (ofcourse based on the nature of the position) Have they been effective in your hiring process? *** Edit for Kevin's response *** For example: A complete question could be "Design a parking lot management system that can be used to find vacant slots" I can be done with 2 classes, `ParkingLot` and `Slot` or I could go on to add `IVehicle` and `Vehicle` and `Car` and `Motorcycle` classes. Where do I draw the line?               public class ParkingLot     {        IVehicle Vehicle {set; get;}             List<Slot> GetEmptySlots() { };     }          public class Vehicle : IVehicle     {       Slot SlotNum {set; get;}     }          public class Slot     {       int Row {set; get;}       int Column {set; get; }     }


title: Javascript and proprietary algorithms

text: I'll be quite to the point, is there any way to make Javascript a bit more concealed than it usually is or is Javascript always out and open if you look in the source code ? This is about hiding proprietary algorithms that would dispense a service that does not exist yet (to my knowledge) on the market and is not really straightforward. I know that patenting is possible but let's leave this out of the question.


title: Is the capability to overwrite functions in JavaScript strength or weakness?

text: I recently came across the following code (from liferay.js) when I was working with Liferay:               ....     if (!Liferay._ajaxOld) {         Liferay._ajaxOld = jQuery.ajax;     }          if (Liferay._ajaxOld) {         jQuery.ajax = function(options) {             if (Liferay.Util) {                 options.url = Liferay.Util.getURLWithSessionId(options.url);             }             return Liferay._ajaxOld(options);         };     }     ....      As you can see, the code above overwrites the function "jQuery.ajax" to modify "options.url". One may say this is a strength of the language since we can easily overwrite and customize existing functions. However, I would imagine this capability can easily lead to a problem. For instance, my code can overwrite the same function "jQuery.ajax" to modify "options.url" differently from the code above. As a result, any code that expect the behavior defined by "liferay.js" may no longer function as expected. I see this as a weakness of the language as it does not provide proper encapsulation. What are the consensus about this feature/capability of the language in the field?


title: Locking techniques

text: Delphi RAD libraries implement many thread friendly objects in a way which forces one to declare another object for storing the reference returned by that object's locking method. The object thus essentially encapsulates the prime object which is returned on locking. For example;               List := ThreadList.Unlocklist;     // do something with List     ThreadList.LockList;      Why is this approach taken? Why is inheriting from the prime object, adding the locking object, overriding constructors and destructors, discouraged? For example the following implementation adds a TMREWSync to a list;               IMREWS = interface            ['{5B6DE5FA-847B-42D5-8BF4-9EB20A452C54}']            procedure BeginRead;       function  BeginWrite: Boolean;       procedure EndRead;       procedure EndWrite;          end;          TThreadList = class ( TList, IMREWS )     private            FLock : TMREWSync;          public            constructor Create;       destructor  Destroy; override;            property Lock : TMREWSync read FLock implements IMREWS;          end;          constructor TThreadList.Create;     begin       FLock := TMREWSync.Create;       inherited;     end;          destructor TThreadList.Destroy;     begin       inherited;       FLock.Free;     end;          // Usage:          ThreadList.BeginWrite;     // Do something with ThreadList     ThreadList.EndWrite;


title: What's the term for "while(true)" loop with "break" inside?

text: Suppose I have a loop in C++ or C# that goes like this:               while( true ) {         doSomething();         if( condition() ) {             break;         }         doSomethingElse();     }      This is commonly called "infinite loop". Yet it is not technically infinite - it will stop once control flows through `break`. What's the term for such loop - that has "loop forever" loop control statement and "break" inside?


title: Several enum classes that declare constants with the same names

text: I'm working on a Java library for sorts for Magic: the Gathering. Well, without going into a lot of detail, in the game there are five different colors of magic: `white`, `blue`, `black`, `red`, and `green`. That's easy enough, that's a textbook example of an enum. However, there's a problem: there are several variations on these colors. There are your standard variants, the "monocolored hybrid" variants, and the "Phyrexian" variants (don't ask). So, my question is, which of these is a better approach? Idea 1:               enum Symbol {       WHITE,       BLUE,       BLACK,       RED,       GREEN,            MONOCOLORED_HYBRID_WHITE,       MONOCOLORED_HYBRID_BLUE,     ...       PHYREXIAN_WHTIE,       PHYREXIAN_BLUE,     ...     }      Idea 2:               interface Symbol {       method1()       method2()     ...     }     enum Primary implements Symbol {       WHITE,       BLUE,     ...     }     enum MonocoloredHybrid implements Symbol {       WHITE,       BLUE,     ...     }     enum Phyrexian implements Symbol { ...      I've been using the first way for a while, but I've been starting to think the second way might be better. It shows more clearly that these classes of symbols are different, yet still compatible, since they implement the same interface. It will cause a little bit of boilerplate code (just a couple fields), but my main issue is I have three enum constants called `WHITE`. Now, I'd always be referencing them by their class name, e.g., `Primary.WHITE`, but this still seems a little awkward. But perhaps it's better than the "Smurf naming" I'd have to do in the first technique. (I also can't use them in EnumMap/ EnumSet in the second way, but I think I'm okay with that.) So, which is the better approach? Is it okay to have a bunch of enum classes all declaring constants with the same name? Is there a third alternative that's even better?


title: Meta-licensing of applications

text: I'm currently evaluating license management solutions for our customized and project-based applications, which are supported by a single server in the intranet of the customer. The applications use common functionality provided by the server (session handling, data synchronization, management capabilities, etc) and are installed on mobile devices. We allow our customers to run the applications on X devices and want to check on the server, whether the customer sticks to this limit (based on the sessions). We don't want licensing software to be installed on the devices itself (for example providing X serials to the customer) nor do we want to host an additional server for licensing in the intranet of the customer. If a client connects, our server should load the license for the application running on the client and verify, that there are sessions left. The licensing managers I looked at (12 products so far) focus on the application itself and don't allow me to implement such a floating behavior as described above. For example, this software could easily be used to create a "Standard Edition" or a "Professional Edition" of our server software, which is not our intention. In XHEO DeployLX there is a "Session Limit", which allows to limit the license to the currently established sessions in ASP.NET, which comes very close to my needs. I'm currently thinking of implementing a custom solution, which allows me to load and enforce custom-defined licenses per application on the server-side and a simple editor to define such licenses (which would contain a type and the limit itself), but I would appreciate an existing, easy to integrate commercial solution. I think it could be possible to use DeployLX for this task, but I would spend a lot of money for implementing most of the solution myself (except for the editor). Thanks in advance for any suggestions or hints. Gene


title: Programming around email address case sensitivity

text: Like many websites, we use email addresses as user identifiers for logins. RFC 5321 [#2.3.11] states that the local parts of email addresses: > MUST be interpreted and assigned semantics only by the host specified in the > domain part of the address This means that applications processing email addresses can't second guess, for example, the way that GMail will ignore dots when determining usernames. It also means that applications must treat email address local-parts as case sensitive, since that's how the local part is specified. However users are stupid, and in a recent case a user who had signed up with an uppercase email address (and had successfully received and clicked the verification email) found they were unable to log in because they were now using the lowercase format of their email address. I've never come across an email server which enforced case-sensitivity on its inboxes. I don't doubt that some exist somewhere, but I'm questioning whether there isn't a bigger benefit to dropping case-sensitivity for our email usernames than there are problems keeping it. I wouldn't go so far as to emulate GMail's dot processing, or any kind of plus-addressing, because those don't seem to be as ubiquitous or as automatically-assumed as case-sensitivity. However, I'm aware it's not a black and white scenario so I'm interested if anyone knows how widespread case- sensitive email addresses actually are.


title: Should code comments have scope?

text: I am asking this because I have seen places where, whoever coded initially had provided proper comments, but later on modifications were made to the code but the comments were left untouched. I remember reading somewhere " Don't get suckered in by the comments, debug only code". So is it a good/ relevant/ practical idea that tells the scope of the comments so as to prompt the developer for editing the comment. Your thoughts.


title: The equivalent of a "Memorandum of Understanding" for programmers?

text: When one business acquires another, they use a Memorandum of Understanding, which is basically an agreement outlining the duties of each party, etc. I am about to begin a massive web development project for a client - What is the equivalent agreement I would use with them?