How to make this design closer to proper DDD?

I've read about DDD for days now and need help with this sample design. All the rules of DDD make me very confused to how I'm supposed to build anything at all when domain objects are not allowed to show methods to the application layer; where else to orchestrate behaviour? Repositories are not allowed to be injected into entities and entities themselves must thus work on state. Then an entity needs to know something else from the domain, but other entity objects are not allowed to be injected either? Some of these things makes sense to me but some don't. I've yet to find good examples of how to build a whole feature as every example is about Orders and Products, repeating the other examples over and over. I learn best by reading examples and have tried to build a feature using the information I've gained about DDD this far. I need your help to point out what I do wrong and how to fix it, most preferably with code as "I would not recomment doing X and Y" is very hard to understand in a context where everything is just vaguely defined already. If I can't inject an entity into another it would be easier to see how to do it properly. In my example there are users and moderators. A moderator can ban users, but with a business rule: only 3 per day. I did an attempt at setting up a class diagram to show the relationships (code below): ![enter image description here](http://i.stack.imgur.com/lVonP.png)               interface iUser     {         public function getUserId();         public function getUsername();     }          class User implements iUser     {         protected $_id;         protected $_username;              public function __construct(UserId $user_id, Username $username)         {             $this->_id          = $user_id;             $this->_username    = $username;         }              public function getUserId()         {             return $this->_id;         }              public function getUsername()         {             return $this->_username;         }     }          class Moderator extends User     {         protected $_ban_count;         protected $_last_ban_date;              public function __construct(UserBanCount $ban_count, SimpleDate $last_ban_date)         {             $this->_ban_count       = $ban_count;             $this->_last_ban_date   = $last_ban_date;         }              public function banUser(iUser &$user, iBannedUser &$banned_user)         {             if (! $this->_isAllowedToBan()) {                 throw new DomainException('You are not allowed to ban more users today.');             }                  if (date('d.m.Y') != $this->_last_ban_date->getValue()) {                 $this->_ban_count = 0;             }                  $this->_ban_count++;                  $date_banned        = date('d.m.Y');             $expiration_date    = date('d.m.Y', strtotime('+1 week'));                  $banned_user->add($user->getUserId(), new SimpleDate($date_banned), new SimpleDate($expiration_date));         }              protected function _isAllowedToBan()         {             if ($this->_ban_count >= 3 AND date('d.m.Y') == $this->_last_ban_date->getValue()) {                 return false;             }                  return true;         }     }          interface iBannedUser     {         public function add(UserId $user_id, SimpleDate $date_banned, SimpleDate $expiration_date);         public function remove();     }          class BannedUser implements iBannedUser     {         protected $_user_id;         protected $_date_banned;         protected $_expiration_date;              public function __construct(UserId $user_id, SimpleDate $date_banned, SimpleDate $expiration_date)         {             $this->_user_id         = $user_id;             $this->_date_banned     = $date_banned;             $this->_expiration_date = $expiration_date;         }              public function add(UserId $user_id, SimpleDate $date_banned, SimpleDate $expiration_date)         {             $this->_user_id         = $user_id;             $this->_date_banned     = $date_banned;             $this->_expiration_date = $expiration_date;         }              public function remove()         {             $this->_user_id         = '';             $this->_date_banned     = '';             $this->_expiration_date = '';         }     }          // Gathers objects     $user_repo = new UserRepository();     $evil_user = $user_repo->findById(123);          $moderator_repo = new ModeratorRepository();     $moderator = $moderator_repo->findById(1337);          $banned_user_factory = new BannedUserFactory();     $banned_user = $banned_user_factory->build();          // Performs ban     $moderator->banUser($evil_user, $banned_user);          // Saves objects to database     $user_repo->store($evil_user);     $moderator_repo->store($moderator);          $banned_user_repo = new BannedUserRepository();     $banned_user_repo->store($banned_user);      Should the User entitity have a `'is_banned'` field which can be checked with `$user->isBanned();`? How to remove a ban? I have no idea.


Why is bitbucket popular in eastern europe?

I was looking at google trends for bitbucket and github, and it seems bitbucket leads github in Romania, Bulgaria, and Latvia. Why is this so? Are there any historical reasons for this?


What is a T&R cycle?

I have seen the following in a job offer: "The Business Analyst is expected to determine an appropriate IT strategy, potential IT solutions and support the submission into the T&R cycle." Does anyone known what the T&R cycle is? Never heard of it and googling does not help.


If I use Ruby Migrations, do I have to use the rest of Ruby on Rails?

I'm currently trying to come up with a database migrations strategy for my organization. This includes getting the database scripts into source control, managing versioning, managing releases to QA / Production, managing branching and merging across different release branches, etc. Ruby Migrations seems to offer solutions to a lot of those problems. But, from looking at the Ruby on Rails docs, it is unclear to me whether Ruby Migrations can be separated from the rest of the framework. I work in a primarily .NET shop, but with a lot of other technologies, and with multiple DBMS platforms (SQL Server, Oracle of various versions). Ruby is not present in our portfolio at all right now, and we have no plans to use it. If I was to use Ruby Migrations, it would be the only piece of the Ruby on Rails framework that we would want to use. Can Ruby Migrations be effectively used to manage database changes independently of the rest of the Ruby on Rails framework? Are there any docs or articles out there that describe this workflow? (Yes, I know there are other options such as Liquibase but I'm specifically trying to learn about Ruby Migrations with this question.)


How does Python compile some its code in C?

I read that some constructs of Python are more efficient because they are compiled in C. https://wiki.python.org/moin/PythonSpeed/PerformanceTips Some of the examples used were map() and filter(). I was wondering how Python is able to do this? It's generally interpreted, so how does some of the code get compiled while another is interpreted - and in a different language? Why not just compile the whole thing?


Should a web developer know how to do slicing?

I am a web developer. I'm doing all kinds of web-sites and web applications. It's very strange for me that a lot of customers do not know the difference between a web developer and a slicer. They just want to "give you the PSD" and expect you to give them a web site with a DB back-end and so on... I'm just asking here: am I wrong in my thinking? Of course, a web developer MUST know html and css but I don't think that he should slice the PSD and do all the work a css guru can do... I would like to hear your opinions on this.


What is the significance of 10 characters in this Uncle Bob post?

In this blog posting by Uncle Bob http://blog.8thlight.com/uncle-bob/2012/04/20/Why-Is-Estimating-So-Hard.html Author states a possible solution to the problem at hand. He writes "Try this. Break some long string of text up into columns that are 10 characters long. Each time you break a line, record the position of the break, and why you decided to use that position." The problem is about breaking the Address into 13 character columns, so where does 10 come into play? Or is he using that as another example unrelated to the Gettysburg one? I'd like to present this to my team in a presentation I have to do soon. I plan to describe the posting, describe the problem and ask my team members for their estimates. After I would go on to explain the rest of the postings premise about why estimations are often blown. Feel free to offer suggestion on how I can make this a good presentation. I can visualize most of it but towards the end it feels light. After the quick survey, I focus on the problem of estimating the wrong thing and then offer the solution.


How can I evaluate a candidate's knowledge of Html/CSS during an interview?

I am trying to determine some good interview questions to assess the ability of people coming in for a Html/CSS job, however that topic is extremely broad, and I'm not sure what sort of questions I can ask to properly evaluate someone's HTML/CSS knowledge. What sort of questions can I ask to evaluate a candidate's Html/CSS abilities during an interview? Ideally I would like to ask few questions and then give them a real life scenario to combat.


How can I find the shortest path between two subgraphs of a larger graph?

I'm working with a weighted, undirected multigraph (loops not permitted; most node connections have multiplicity 1; a few node connections have multiplicity 2). I need to find the shortest path between two subgraphs of this graph that do not overlap with each other. There are no other restrictions on which nodes should be used as start/end points. Edges can be selectively removed from the graph at certain times (as explained in my previous question) so it's possible that for two given subgraphs, there might not be any way to connect them. I'm pretty sure I've heard of an algorithm for this before, but I can't remember what it's called, and my Google searches for strings like "shortest path between subgraphs" haven't helped. Can someone suggest a more efficient way to do this than comparing shortest paths between all nodes in one subgraph with all nodes in the other subgraph? Or at least tell me the name of the algorithm so I can look it up myself? For example, if I have the graph below, the nodes circled in red might be one subgraph and the nodes circled in blue might be another. The edges would all have positive integer weights, although they're not shown in the image. I'd want to find whatever path has the shortest total cost as long as it starts at a red node and ends at a blue node. I believe this means the specific node positions and edge weights cannot be ignored. ![enter image description here](http://i.stack.imgur.com/d568B.png) (This is just an example graph I grabbed off Wikimedia and drew on, not my actual problem.)


Software design vs physical products design

I got a bunch of questions to answer to prepare for an exam and this one I'm actually not sure what's the clear difference : "Explain the difference between designing software and designing physical products" I have an opinion on this, but the more I think about it the more it feels like there's no real difference except that the tools and formula's used when making physical items has been established hundreds of years ago and the heuristics/models have been in place since forever. I also thought that, once you design a spoon and make it, it doesn't evolve with time, it fulfills it's requirements and that's that, while for software new requirements come in all the time so you have to consider certain quality attributes in that regard. This is from my software architecture class if you guys need a context. What are the differences between software design and physical design, and am I off the mark with my answer?


Could I have a real-world example of using the Spring scripting module in your Java application?

The Spring framework supports the use of scripting languages (specifically JRuby, Groovy and BeanShell) whereby a script in any of these can call Java code and vice versa. I have read that a possible use of this feature is when some modules require frequent changes and it would allow to modify your application without having to redeploy it. I have been trying to visualize a possible usage but this sounds too vague to me. I tend to associate things that can change with configuration, data or rolling a new feature in an application, but not with an existing module whose behavior can change frequently. In summary: when did you benefit from using Spring scripting or at least what would be a realistic, concrete example?


How do purely functional languages handle modularity?

I come from an object oriented background where I've learned that classes are or at least can be used to make a layer of abstraction that allows for easy recycling of code which can then either be used to make objects or be used in inheritance. Like for example I can have an animal class and then from that inherit cats and dogs and such that all inherit many of the same traits, and from those sub-classes I can then make objects that can specify a breed of animal or even the name of it.   Or I can use classes to specify multiple instances of the same code that handles or contains slightly different things; like nodes in a search-tree or multiple different database connections and what not. I'm recently moving into functional programming, so I was starting to wonder:   How do purely functional languages handle things like that? That is, languages without any concept of classes and objects.


Data access for composable applications

I'm wondering if anyone can share their thoughts, experience and guidance on how to approach the data access layer for a composable application? By composable application, I mean an application with the domain layer made up of modules. The goal is to make the application highly extensible by 'plugging in' additional (or replacement) modules. Each module encapsulates (and isolates) a set of related functionality. My dilemma is the right approach for the data access layer to support this composability (modularity) while still providing isolation from the back-end database. Because each "module" can implement its own set of domain objects, there really is no way that I see an ORM like EF working unless I simply create one mega data context or make changes to the data access layer each time a new module is introduced (which isn't possible if the module is added by a 3rd-party or as a post-deployment extension). For what it's worth, this is an enterprise-scale application with a database containing over 200 tables and a ton of sproc, udfs, etc. What advice can you share? **UPDATE** I confirmed today that we will be using a legacy data store for the solution that utilizes stored procedures and user-defined functions for the majority of the data access operations. Our hope is to evolve away from this as time goes by, but the budget and timeline for the project dictate the we build on top of the existing databases. Does that change your thoughts?


How to apply dynamic programming to optimization problems with 2 constraints

Suppose you have a collection of blocks, each with a certain height and a certain weight. For example:               Sample input:     (190, 190) (120, 40) (100, 10) (90,130) (70, 40) (60, 70) (30, 30) (10, 90)          Sample output:     4      You want to find the maximum number of blocks you can pile, with 2 constraints: each block must be lighter than the one below it and it must also be shorter than the one below it. How do you solve it? My approach was to solve it more or less like the knapsack problem. I order the blocks from light to heavier, and I start at the end of the array. Then for each block I am considering, I find the maximum between piling that block and don't piling it, and return it. Here's the C code:               int maxPile(Blocks array[], int block, int maxHeight, int maxWeight){              /* base case with just 1 block left to consider */         if (block==0){             if ((array[0].height < maxHeight) && (array[0].weight < maxWeight))                 return 1;             else                 return 0;         }              /*case where current block can be piled, check the max between piling or not*/         if ((array[block].height < maxHeight) && (array[block].weight < maxWeight))             return max(1+maxPile(array,blockk-1,array[block].height,array[block].weight),maxPile(array,block-1,maxHeight,maxWeight));              /*case where current block can't be piled, so move to next*/         else             return maxPile(array,block-1,maxHeight,maxWeight);     }      The algorithm above seems to solve the problem correctly. The problem, as you might have guessed, are the overlapping sub-problems, so the complexity is exponential. The usual way to solve this is dynamic programming, but I am having a hard time to implement it, specifically because of the 2 constraints. If there was a single constraint, say weight, I would build a 2-dimensional array where the rows would represent the sub-set of blocks you are working with, and the columns would represent the max weight available. But with 2 constraints I would need to have a 3-dimensional array to store the solutions of the subproblems, and as soon as the dataset grows a bit this becomes unfeasible. Another idea I considered was to take the 3 factors (current block, max weight and max height), pass them through a hash function and store the result in a hash table. For some reason this is not working. Any ideas on how to add dynamic programming to the above solution? (or on how to solve it more efficiently?). **Update** : It seems that it's also necessary to sort the array by the second constraint (i.e., height in this case) and run the function again, cause with this order the maximum might be larger.


What is the scope of a Bdd Scenario particularly when specifying changes to an existing application?

We have been working with BDD for sometime now and one issue that keeps cropping up is related to the scope of our scenarios. Particularly when it come to making a change to existing functionality. As a developer I see the scenarios as being akin to a spec, ie. this is the change that is required. However often they seem to stray into regression or acceptance testing. So scenario 2 wont require any code changes itself but might indicate a function that also needs testing following a change made by scenario 1 (regression testing). Or Scenario 2 might provide an alternative test to the same function as scenario 1 (acceptance testing). On the face of it this doesnt seem unreasonable however it greatly increases the number of scenarios which makes them more time consuming to write and makes it harder for the developers to see the wood for the trees. What should the scope of scenarios be when making a change to exising functionality? Can we have a scenario that specifies a change in generic terms rather than having a seperate scenario for each related function?


Where to add the license file?

I have written an application in Python using Tkinter and want to distribute under the WTFPL license. But I don't understand where to add the copying.txt file that needs to be added in the folder that is distributed. **Please** clarify.


Microsoft certifications

When looking through job postings I noticed some employers listing MCSD or MCAD certifications. Are these certifications correct ones for web developers? Which track should one choose?. I also noticed looking at MCSD that most certifications are "retired". So how are suppose to take the exam it it's no longer offered?? thanks


Will a Bachelor of Science in something other than Computer Science hurt a career in software development?

I have a BSc in Geology. Once I was half-way through my bachelors only, I found where my real talents are. Will my basic degree be a problem for me to progress in the Software field (I feel lot of leading companies are considering the basic degree)? Also what would you recommend to put my self in an equally competent position against a person with a strong BSc in computer science. Thanks in advance.


Why do programming languages allow shadowing/hiding of variables and functions?

Many of the most popular programming languges (such as C++, Java, Python etc.) have the concept of **hiding** / **shadowing** of variables or functions. When I've encountered hiding or shadowing they have been the cause of hard to find bugs and I've never seen a case where I found it necessary to use these features of the languages. To me it would seem better to disallow hiding and shadowing. Does anybody know of a good use of these concepts? **Update:**   I'm not refering to encapsulation of class members (private/protected members).


Low Coupling: Single Responsibility Principle vs Cohesion

I've read several articles on _SRP_ and _cohesion_ , and they seem to contradict each other as far as _low coupling_ is concerned. Articles on _cohesion_ argue that putting closely related responsibilities together in a class `Highly_Cohesive_Class` reduces coupling, while articles on _SRP_ would argue that we'd reduce coupling by removing these closely related responsibilities from class `Highly_Cohesive_Class` into separate classes ( such that each class only has single responsibility/reason to change ). Don't the two claims contradict each other? Namely, BTW - I'm aware of the fact that class adhering to SRP principle is also considered highly cohesive class, but in this post the term _highly cohesive_ refers to a class that has several closely related responsibilities thank you


Does any know of a Algorithm that allows for a figure like this image?

Does anyone know how to create an algorithm capable of making the figure just like in the picture, when given a set of specific points (3D array) ![enter image description here](http://i.stack.imgur.com/9P1t0.jpg)


Storing the EOF (End of File) character in a char type

I read in the Dennis Ritchie's _The C Programming Language_ book that `int` must be used for a variable to hold EOF - to make it sufficiently large so that it can hold EOF value - not `char`. But following code works fine:               #include<stdio.h>           main()  {        char c;        c=getchar();        while(c!=EOF)  {          putchar(c);          c=getchar();        }      }       When there is no more input, `getchar` returns EOF. And in the above program, the variable `c`, with char type, is able to hold it successfully. Why does this work? As per the explanation in the book above mentioned, the code should not work.


Entites in Invalid State

I'm looking into developing my entities so that they cannot be in an invalid state. In particular I'm starting with my Customer entity. This would have fields like:   * Title (enum)   * FirstName (string)   * LastName (string)   * Address (value object with another 6 fields)   * MainTelephone (string)   * AlternateTelephone (string)   * EmailAddress (string) I've added methods such as ChangeOfAddress() to facilitate the changing of address, which will ensure a valid address is entered as a replacement. In the UI, I consider most fields (except for AlternateTelephone and EmailAddress) as 'required', encouraging users to complete fields such as Title to make addressing mail shots easier in the future. For methods like ChangeOfAddress() the concept of 'invalid state' is an easy one, as I can apply validation on the new Address value object, but for the construction of a new Customer object I'm not as sure. I guess my question is, should the bare minimum for the construction of a Customer entity include all the fields I feel are 'required' from the perspective of the UI? I can't imagine how creating a Customer with only a FirstName and LastName (without any contact details), would be valid in the business sense I intend to use the Customer object in. Although in a sense FirstName and LastName are good starting points for a minimum description of a Customer and I guess the Customer wouldn't be 'invalid' it'd just be lacking enough information to be useful to my business needs (which would be, to be able to contact them). Hope this makes sense, I'd be interested to hear any opinions, as I'm still learning as I go.


First of the The Ten Commandments for C++ Programmers by Steve Oualline correctly transcribed?

I do not have the book “Practical C++ Programming” by Steve Oualline but I was reading his Ten Commandments for C++ programmers at http://code.rkevin.com/2010/07/the-ten-commandments-for-c-programmers/ and I was wondering if the first has been correctly transcribed? For reference the transcription is: "1. Thou shalt not rely on the compiler default methods for construction, destruction, copy construction, or assignment for any but the simplest of classes. Thou shalt forget these “big four” methods for any nontrivial class." He seems to be advocating manually defining copy construction and copy assignment. Is that a correct interpretation of his first commandment? Edit: Although at present I am leaving Adrian's answer as the accepted one I would like anyone who views this question to read Jerry's. I did specifically ask whether the above text is accurately transcribed and not about its merit (which is probably a more interesting discussion). But Jerry does make some good points about its merit (or lack thereof) which are similar to my opinions of it. I just wanted to make sure I had the quote right before I constructed a thorough argument of why I disagree with it.


Starting with 3D programming

I will be working on a 3D project and i need to learn c++ and opengl fast. as i have heard it is the best combination to do graphics. I would also like your recommendation on this book I came across: Angel E, Interactive Computer Graphics: A top-down approach with Open GL, 5th Edition, Addison Wesley 2008 what do you recommend? thanks!


Do we need a non-disclosure agreement (NDA)?

We're going to meet a potential new client today and between ourselves started discussing the need for a non-disclosure agreement (NDA) and whether we need one at this juncture. In this case we don't think we'll be talking about technical specifics as it's an initial meeting about who we are. Is there any precedent on when is the right time for small ISVs to insist on NDAs and when perhaps the insistence might appear over the top and precious. All ideas welcomed, though in our case we're interested in UK law.


What are the benefits of archiving?

I always see sites that only keeps fresh content on the home or subsections, and the rest of the content is kept in a separate section called 'archive'. Recently I have also heard that NoSQL DB's like MongoDB are good for archiving (which makes me think this is related to performance) So why do sites archive their content? What's the benefit over say, a simple paginator through which you could reach all the content? Is archiving done for performance? Or SEO? Or just user experience?


Is there any way around the field-of-use restrictions in Java?

Current field-of-use restrictions defined in "Oracle Binary Code License Agreement for the Java SE Platform Products" prohibit its use in embedded systems. > "General Purpose Desktop Computers and Servers" means computers, including > desktop and laptop computers, or servers, used for general computing > functions under end user control (such as but not specifically limited to > email, general purpose Internet browsing, and office suite productivity > tools). The use of Software in systems and solutions that provide dedicated > functionality (other than as mentioned above) or designed for use in > _embedded_ or function-specific software applications... are excluded from > this definition and _not licensed_ under this Agreement. Do these restrictions also apply to OpenJDK and other possible implementations? Is the only way to use Java in such an environment to acquire a separate license from Oracle?


Commented short fancy code vs. uncommented longer easy-to-understand code - which is preferred?

Sometimes an algorithm can be written in two ways:   * The short, fancy way; or   * The longer, easy-to-understand way. For example, here is a longer, easier way of copying a string `source` to `dest` in C:               *dest = *source;     while (*source != '\0') {         source++;         dest++;         *dest = *source;     } (true);      And here is a short, fancy way.               // Copy string source to dest     while (*dest++ = *source++);      I've always heard and read that fancy code should be avoided, and I tend to agree. But what if we take comments into account? **Assume that, as in the examples above, we have an uncommented, longer and supposedly easier-to- understand code, and a well-commented, short, fancy code? Is the non-fancy code still preferred?** **EDIT:** Many have commented on variable names, so I've modified the example code as to not make that a factor when preferring on over the other. I tried to remove the double assignment in the first example, but that only made the code less readable. Perhaps this wasn't the best of examples because many find the 'fancy' code more readable and understandable than the longer code. The idea was to have one longer code which was much easier to understand than a very short but complicated code. **EDIT2:** Here's a new examle I got from SO: **Commented fancy version:**               //direct formula for xoring all numbers from 1 to N     int Sum = (N & (N % 2 ? 0 : ~0) | ( ((N & 2)>>1) ^ (N & 1) ) );      **Non-commented long version:**               int Sum = 0;     for (int i = 1; i < N; ++i)     {        Sum ^= i; //or Sum = Sum ^ i;     }


AGPL-compatible license

I am using a java library licensed under AGPL3. However, I would like to license my own work as BSD, such that my code could then be integrated in proprietary projects if one strips the library. Will I be allowed to do that? So far, I couldn't find a clear answer for my problem on the net or in the license text(not a lawyer). Dual-licensing seems cumbersome and ugly. EDIT: What happens if I use other libraries which are licensed under BSD or anything else?


What project did you work on when you were a C++ beginner?

I need some ideas for projects that will help me improve my skills.   Here is the requirement for the project   1. It has to be in win32   2. I need something harder than just making a calculator


Software process of small company

I'm wondering how should testing take place in small teams (or start-up teams). I'm talking 5-10 developers that are assigned to multiple development tasks. From my experience there is little to none testing in the development process, but I also hear small teams **can** get through the initial level of software process maturity. How does QA and testing take place during development in a mature-but-small team? (please, if you can, describe the whole software process including who should be doing what) EDIT (more detail): I'm especially interested in a team developing a distributed processing- intensive back-end with a website as it's API. The two parts (back-end, front- end) are developed by two different groups of 3. I want to understand **who tests what, and when**. If I write a module and it's unit tests, do I write integration tests when completing the code? Should you assign a developer on such a small group to focus on testing?


Grading an algorithm: Readability vs. Compactness

Consider the following exam / interview question: * * * Implement the strcpy() function in C: `void strcpy(char *destination, char *source);` _The`strcpy` function copies the C string pointed by `source` into the array pointed by `destination`, including the terminating null character. Assume that the size of the array pointed by `destination` is long enough to contain the same C string as `source`, and does not overlap in memory with `source`._ * * * Say you were the interviewer \ examiner, how would you grade the following answers to this question? 1)               void strcpy(char *destination, char *source)     {       while (*source != '\0')         {           *destination = *source;            source++;            destination++;         }         *destination = *source;     }      2)               void strcpy(char *destination, char *source)         {            while (*(destination++) = *(source++)) ;         }      The first implementation is straightforward - it is readable and programmer- friendly. The second implementation is shorter (one line of code) but less programmer- friendly; it's not so easy to understand the way this code is working, and if you're not familiar with the priorities in this code then it's a problem. I'm wondering if the first answer would show more complexity and more advanced thinking, in the interviewer's \ examiner's eyes, even though both algorithms behave the same, and although code readability is considered to be more important than code compactness. It seems to me that since making an algorithm this compact is more difficult to implement, it will show a higher level of thinking as an answer in an exam. However, it is also possible that an interviewer \ examiner would consider the second answer not good because it's not readable. I would also like to mention that this is not specific to this example, but general for code readability vs. compactness when implementing an algorithm, specifically in exams \ interviews.


What does it mean for a sorting algorithm to be "stable"?

In reading about various sorting algorithms I've seen it mentioned that some are "stable" and some are not. What does that mean, and what tradeoffs are involved on that basis when selecting an algorithm?


How come there is still so much programming work?

I wonder why programming jobs haven't yet "dried up" because of the software evolution. For example, I am a developer myself, which means that I do care about software (I mean I am not of the type of guys that needs a computer mainly to just browse the Internet), and still I wouldn't mind if I never receive any more updates on my Ubuntu machine. I find that it provides everything I need, and while the updates provide various bug fixes/improvements, I wouldn't mind using it with its current state for the rest of my life. For two years of Ubuntu usage I have never bumped at a serious bug/problem. Another example is Windows. Almost half of its users still use Windows XP, which is practically ancient, yet they find it satisfying for all their needs (and I agree with them). I could go with many more examples, but by now you are understanding my point and my question. While new "trends" appears all of the time (like a new mobile OS) which runs on new platforms and requires some fresh development work, still the majority of the software effort goes in to what I consider as "completed projects", or at least a state of a project which is enough to be considered as completed. Do you have an explanation?


Is it reasonable to expect that a senior developer knows what OOP design patterns are?

I'm preparing questions for job interviews for a senior development position. The job would include object oriented design, and the existing software uses design patterns, so I'd like to ask the candidates to explain a few design patterns they know, they've used, how they've used them, why they've used them and so on. However, in previous interviews when I asked senior developers with at least 5-10 years experience about design patterns, almost none ever heard of them. I think two out of twenty developers could name a single design pattern (Singleton and MVC, respectively). So my question is: does it make sense to ask these questions? Or is this such an obscure subject that you cannot expect new hires to know them already? Should a senior developer have prior experience with design patterns, or would you say that design patterns are such a simple topic that every decent developer can pick them up during training? If so, what questions would you ask instead to gauge their design abilities? **Add** After reading the answers so far, I should give a few clarifications:   * The job is for a .NET developer with experience in OOP/OOD   * The existing code uses class names like `IParameterGraphVisitor` and `IStorageFactory` in many places   * How do you ask people about their past experiences with OO designs they created, if they don't have the vocabulary to explain their designs? That's what I want to do, and all I can come up with is "please you draw the design/object hierarchy of your last project on the whiteboard".


multi-clients web application,should I use custom user controls or a common user control

Say my company is going to build a complicated asp.net web form education system. One of the module is web based registration. To make it flexiable, we decide to use user control(ascx) with rule-engine (work flow) regulating all business logic behide them. Thus in future,for different clients, we can simply config basic existing rules or adding new rules.(Rules stored in db or XML per client). Now the question is how to deal with the user controls (ascx)? My opinion is for different client build diffrent user control from scratch. other voice is like reuse existing user controls.


Are functional languages better at recursion?

TL;DR : Do functional languages handle recursion better than non-functional ones? I am currently reading Code Complete 2. At some point in the book, the author warns us about recursion. He says it should be avoided when possible and that functions using recursion are generally less effective than a solution using loops. As an example, the author wrote a Java function using recursion to compute the factorial of a number like so (it may not be exactly the same since I do not have the book with me at the moment):               public int factorial(int x) {         if (x <= 0)             return 1;         else             return x * factorial(x - 1);     }      This is presented as a bad solution. However, in functional languages, using recursion is often the preferred way of doing things. For example, here is the factorial function in Haskell using recursion:               factorial :: Integer -> Integer     factorial 0 = 1     factorial n = n * factorial (n - 1)      And is widely accepted as a good solution. As I have seen, Haskell uses recursion very often, and I did not see anywhere that it is frowned upon. So my question basically is:   * **Do functional languages handle recursion better than non-functional ones?** EDIT : I am aware that the examples I used are not the best to illustrate my question. I just wanted to point out that Haskell (and functional languages in general) uses recursion much more often than non-functional languages.


Should you offer to remember the user on registration?

What is the typical pattern regarding remembering users for a website? Do you offer to remember the user at login and when they register, or at login only, or either depending on what mood you are in :) ? Not interested in implementation details, just the recommended practice?


Strategies for counting child objects

What is an efficient, OOP way to count child records of an object? In my current project, a _District_ may contain zero or more _School_ records. The _Districts_ object acts as a collection of District, and can perform a single query to get the data behind several _District_ in one go, rather than each District (Active Record) querying for its own data. District->schools() provides access to child schools. On the page in question, I want to list all the districts and a count of their child schools. This is getting very sluggish as the number of districts grows, as each district must again query the schools table. Additionally, the database driver we're using does not provide a row count for the record set, so that would be another query. Some things I've considered:   * An optional object available through a service locator which can provide counts.   * Storing the child count with the parent record. So, my current method of counting child records is pretty heavy. What are some ways I could lighten this load?


In scrum, how do you give an estimate for a backlog item that is primarily research?

A few sprints ago I was assigned a task that was primarily research. I had to figure out how to get our product to interoperate with a very complex black box that we did not develop. I couldn't think of a way to estimate this work. Even if I got the ball rolling and knew the immediate problem I faced, I could not get a sense of how many other problems I'd have to solve after that. I could never tell if I was almost done or far from it. How am I supposed to estimate a backlog item like this? * * * I want to elaborate the nature of this assignment. I knew what calls I had to make to interoperate with the black box. That was the easy part. But the API took a very, very complex object as a parameter. Calling the API would throw an error and it was not easy to figure out what that error was trying to tell me. The black box wouldn't tell me all the problems wrong with my request, it would just tell me the first problem it found. This made it very difficult to know how much work I had left.


Database structure for various items

I'm building a sqlite database for an android app which will hold a list of items, each of which have different characteristics. Some of the characteristics are available for all objects, some are only relevant for a subset of objects. For example, all my items have a name, a description, an image. Some items will also have an expiration date, others wont. Some will have a size, some wont. Etc... How should I build my Database, as I don't know how many characteristics may be added in the future, and knowing I should be able to filter the list by any characteristic ?


Using git correctly in a small team

What would be the easiest way to use git correctly in a small team of about 5 developers, with one server running the live application?


I Quit my job but took back my resignation during the notice period... Did I made a mistake?

Inspired after reading an article from Lifehacker, I would like to explain, what I went through few weeks back. I am currently working for an MNC in India for the last 4.5 years and on the 14th of last month I decided to resign from here due to various options given below:   1. Multiple responsibilities on my head and along with that normal programming with less pay.   2. No Opportunities in going to onsite working with the onsite project team.   3. Worked almost 3 out of 4 weekends in a months and too much of work related pressure due to adhoc changes in the requirements.   4. Almost burned out and no work life balance.   5. No Vacations. Month end Pay was my major concern for my decision to quit because I believe that for the amount of work I do and the kind of responsibilities I take, I should be paid given a market competent pay. But a huge MNC like my company, the appraisal and hikes happen only once in an year. With all these above reason, I quit 2 weeks back. But, since I was critical to the project, the management tried to retain me back by agreeing to processing my H1B visa, which I agreed with no double thought because my major concern (Money) is been taken care. But rest all my concerns still persist and the management is putting everyone under deliverable pressure by giving tough timelines and adhoc requirement changes. Now I feel like quitting again... I am confused. Any advice here please...


Development Teams - Can One Bad Apple Spoil the Bunch?

> ...One of the most important features a new employee should have is > compatibility with the spirit of the people who already work there.   >  {...}   >  I am convinced that gaining insight into the developer's real personality > is just as important as checking for professional competence, because **one > bad fit can destroy an entire team.** from Hiring Developers - You're Doing It Wrong Is this true? And, if so, is it true for managers too?


Paranoid Encryption

Call me paranoid, but I really like to keep my stuff secret, but readily available on the cloud. So, asking this question.   1. How safe and reliable is encryption software (e.g., truecrypt)? The reason I ask is that, what is I encrypt my data today with this software and after a couple of years, the software is gone ! What happens to my encrypted data?   2. Is it equally safe to AES encrypt using 7-zip? Will it provide the same level or equivalent level of encryption as truecrypt or other encryption software? (I agree truecrypt will be better because of the container encryption it gives.) And what happens if 7-zip shuts down after 5 years? I am sorry if I am sounding paranoid, but I am coming back to my original question... Is there any application/software independent encryption? Meaning, can I encrypt with one software and decrypt with another so that I will not be dependent on just one vendor? I want my encryption to depend ONLY on the password and NOT on the encryption program/software? The next question, can I write my own program that does AES/stronger encryption when I give it a passphrase, so that I don't need to depend on third party software for encryption? If yes, which language supports the same? Can someone give me a heads up as to where to look for in case of writing my own encryption program?


Is there any good reason why lines with only whitespace should be truncated?

Typically, when you hit Enter in a smart editor, it copies the indentation of the last line by inserting the same amount of spaces, so if you don't delete them, the code looks like this:               sub sum {         my @numbers = @_;                  my $sum = 0;         foreach (@_) {              $sum += $_;         }                  return $sum;     }      (Yes, the example is silly; that sub could be written in two or three lines. :)) To be honest, these lines make my cursor feel dizzy, so I tend to clear them out. (I admit, that this behavior generates commit noise + inconsistency.) Plus, the whitespace are unnecessary bytes. Well, probably none of these does matter, at least in most obvious ways. So I wonder if there is any better (i.e. less subjective and less over-pedantic) reason why the lines should be blanked (by `s/^\s+$//`). **Note:** And please try not to point me to the style guide. Imagine I'm the one writing the style guide: should I inherit rule "delete the extra spaces" or just bravely fight my intuition and leave those peaceful `\t`'s and ``'s alone?. Or I just want to improve my "own" guide, which I can use where "official" guide is silent or missing.


Java: how can I make the return type, of an inherited method in a subclass, the same as the subclass?

I am rather inexperience in Java, and I'm having a problem in forming a subclass of a class I have created. The class I have made, called `Vector2D`, contains methods, such as `add(Vector2D addend)`, that takes a `Vector2D` object as an argument, and returns a `Vector2D` object. This method in particular is designed to add two vectors, and return the sum. Then, I started coding a subclass, called `Position2D`, which I intend to have all of the functionality of the `Vector2D` class, except have additional functions, and have any usage of `Vector2D` inside the preexisting classes, be it as an argument, return type, etc., replaced with `Position2D`, so that the `add(Position2D addend)` function adds two `Position2D` vectors together, and returns the sum as a `Position2D`. The issue arises that, when `Position2D` inherits from `Vector2D`, such functions continue to work in terms of `Vector2D` objects, spitting out an error as soon as a `Position2D` object is passed through it. The relevant code for the `Vector2D` class is as follows:               public class Vector2D{              //Field Variables         private double x; //The vector's x-coordinate         private double y; //The vector's y-coordinate              //Constructors         public Vector2D(){             //Constructs empty vector.             setX(0);             setY(0);         }              //Methods         public void setX(double newX){             //This method is not problematic when inherited for the subclass.             x = newX;         }              public void setY(double newY){             //This method is not problematic too.             y = newY;         }              public Vector2D add(Vector2D addend){             //Adds two vectors and returns the sum.             //This method, however, does pose a problem.             Vector2D sum = new Vector2D();             sum.x = x + addend.x;             sum.y = y + addend.y;             return sum;         }          }      The only work-around I can currently think of as to what the code in `add(Position2D addend)` in `Position2D` could be is:               public Position2D add(Position2D addend){         //Adds two position vectors and returns the sum.         Position2D sum = new Position2D();         sum.x = x + addend.x;         sum.y = y + addend.y;         return sum;     }      i.e., repeat the method from `Vector2D`, and manually modify it. This, of course, is not efficient and wastes time, especially so whenever the same has to be done for similar methods, and more so whenever I intend to make more subclass, e.g. `Velocity2D`. Therefore, I am looking for a much cleaner and efficient means of doing this.


What are Dependency Injections and why are they useful?

I have heard of ninject and I have to build a lot of apps that have to integrate with other tools. SO i was wondering what this was and how it is used.


Are there any studies on the Efficiency/Effectiveness of Agile vs Waterfall

In a meeting the other day a claim was made that agile was only 60% as efficient in development time when compared to waterfall. I am not looking to validate or refute this claim. I am interesting in finding out if there have been any studies comparing the 2 methodologies. Are there any studies out there comparing the two?


Using regular Java classes in Java web apps

I'm work on a simple blogging web application using Java and MySQL as the database backend. I'm implementing the whole application using plain HTML and servlets. I'm using a Java class with static methods that are called from within servlets to handle communicating with the database. Is this a good design? Or what should I do instead?


Practices for domain models in Javascript (with frameworks)

This is a question I've to-and-fro'd with for a while, and searched for and found nothing on: what're the accepted practices surrounding duplicating domain models in Javascript for a web application, when using a framework like Backbone or Knockout? Given a web application of a non-trivial size with a set of domain models on the server side, should we duplicate these models in the web application (see the example at the bottom)? Or should we use the dynamic nature to load these models from the server? To my mind, the arguments for duplicating the models are in easing validation of fields, ensuring that fields that expected to be present are in fact present etc. My approach is to treat the client-side code like an almost separate application, doing trivial things itself and only relying on the server for data and complex operations (which require data the client-side doesn't have). I think treating the client-side code like this is akin to separation between entities from an ORM and the models used with the view in the UI layer: they may have the same fields and relate to the same domain concept, but they're distinct things. On the other hand, it seems to me that duplicating these models on the server side is a clear violation of DRY and likely to lead to differing results on the client- and server-side (where one piece gets updated but the other doesn't). To avoid this violation of DRY we can simply use Javascripts dynamism to get the field names and data from the server as and when they're neeed. **So: are there any accepted guidelines around when (and when not) to repeat yourself in these situations? Or this a purely subjective thing, based on the project and developer(s)?** Example Server-side model               class M      {         int A         DateTime B         int C         int D = (A*C)         double SomeComplexCalculation = ServiceLayer.Call();     }      Client-side model               function M(){         this.A = ko.observable();         this.B = ko.observable();         this.C = ko.observable();         this.D = function() { return A() * C(); }         this.SomeComplexCalculation = ko.observalbe();         return this;     }l     M.GetComplexValue = function(){         this.SomeComplexCalculation(Ajax.CallBackToServer());     };      I realise this question is quite similar to this one, but I think this is more about almost wholly untying the web application from the server, where that question is about doing this only in the case of complex calculation.


How much money do frameworks like Django and RoR generate?

The developers of these frameworks must be generating some kind of money, no? They aren't all just regular old joes with full-time jobs developing web- frameworks in their spare time for the love of programming? Do the sites themselves generate any kind of income? Or do they make money off giving talks? Writing books? Would like to see some numbers/statistics if you have any.


Can a CS degree benefit an older programmer?

Is there any benefit in getting a CS degree in ones mid 40's _career wise_? Would the increased likelihood of getting past the HR filter be worth it? It's something I might actually enjoy doing, and I wouldn't mind solidifying my fundamentals, but I would be reducing my earning capacity during the years it would take to complete the degree, and by the time I'm done, I'll have maybe 15 years left in my career. (I currently have no college degree)


What could be the advantages and disadvantages of decay of Nd arrays to N-level pointers?

I have been thinking of a couple of possible extensions to the C language which I'd like to know the opinion of others about.1 This one is about multi- dimensional arrays. Imagine the following situation in C:               void matrix_mul(double **res, double **a, double **b, size_t n, size_t m, size_t r);      You cannot pass a `double mat[4][4]` (for example) to this function. If you define the function as:               void matrix_mul_N_M_R(double res[N][R], double a[N][M], double b[M][R]);      You'd just be wasting a perfectly written fine algorithm on a certain size of matrices. What came to me (in shower obviously), was decay of multi-dimensional arrays to multi-level pointers. This is an extension to decay of 1d arrays to pointers. Semantically, this would allow the first type of function to work on any two- dimensional array. Technically, this is how it would be implemented. The following code:               double a[3][5];     double b[5][4];     double c[3][4];     ...     matrix_mul(c, a, b, 3, 5, 4);      would be equivalent to:               double a[3][5];     double b[5][4];     double c[3][4];     ...     double **__a_decay = {a[0], a[1], a[2]};               /* generated by compiler */     double **__b_decay = {b[0], b[1], b[2], b[3], b[4]};   /* generated by compiler */     double **__c_decay = {c[0], c[1], c[2]};               /* generated by compiler */     matrix_mul(__c_decay, __a_decay, __b_decay, 3, 5, 4);  /* first three arguments decayed */      Is the application for such an extension very limited? Are there pitfalls? Could this possibly lead to insecure code where not using this feature wouldn't? Where else could such a feature come in handy? 1 Note that I'm not going to make another language myself, but would like to be sure of the feature's benefits and pitfalls before trying to suggest them to the C Standard Committee.


How to document unlimited argument parameters?

In PHP you can have a function take an infinite number of arguments like                 /**        * Do abc...        *        * @since   1.0        * @param   mixed $arg1       Arg description        * @return  string            Results        */     function abc($arg1 = null){       $args = func_get_args();       // do smth with $args     }      How should I illustrate this in my DocBlock ?


Give open-source developers a free license for my commercial software?

I am creating a software package that will be useful to programmers, engineers and scientists. List price will be in the region of $1,000 -- way beyond the budget of most open-source developers, hobbyists and enthusiasts. So I am considering two things, the first generous, the second maybe a little greedy:   1. Offering a free license to individual open source developers upon proof of their credentials and details of their project. Possibly also academics too.   2. Making the free license conditional on the developer granting me a commercial license to use the open source code they write in my own projects. In the academic case, it's trickier, perhaps just a credit, a copy of papers, etc. How would (1) and (2) be received? Are there any examples of best practice here, or good precedents I can follow?


C++ Class Initalization

I'm a python programmer who sees a lot of C++ code but doesn't know the language and there seems to be two ways to initalize a class. I was hoping that someone can tell me the difference.               class Point {             int x, y;          public:             int get_x();             int get_y();             Point(int, int);     }          // ok we are going to leave the methods and constructors unimplemented for brevity     // now here's the part that puzzles me     Point p(5, 5); // ..or     Point p = new Point(5, 5);      What's the diffrence between the two?


Web development — 100% code separation vs flexibility

This is probably a holywarish topic, but nevertheless. In a perfect content management system of your dream, would you rather want a templating system that is completely, 100% separate from your code, and uses declarative syntax to produce (X)HTML (such as `<your code>` -> DOM/XML -> XSLT -> HTML), or would you rather choose a system that lets your code cook HTML fragments, and then runs some template assembly to put these pieces together to output a complete page? Thanks in advance. **EDIT** To make it probably a bit more clear, I mean that HTML is a declarative 'language', whereas most of the dynamic stuff is done in imperative/functional languages. Templates glue the two together, but the way they do it isn't always clean (as in clean separation of paradigms).


CMS vs homebrew system for implementing an image slideshow

There is a basic website (homepage and 5 subpages) with static content, we want to add something like a slideshow of current offers with custom images that would change every month. We also want to include an image gallery with effects like Lightbox. The person who is going to add/modify/delete the images in the two new modules doesn't want to deal with FTP. According to your experience, should we install a CMS (Joomla/Drupal) for this or just create a our own basic image management system to upload/select/delete the images?


How do you name your personal libraries?

I'm pretty bad with naming things. The only name I can every generically come up with is 'helper'. Say, if I have a header file that contains helping functions for manipulating paths, I tend to put it inside my "helper" directory and call it "path-helper.hpp" or something like that. Obviouslly, that's a bad naming convention. :) I want to have a consistent naming scheme for my folder (and namespace) which I can use to always refer to my own headers and libraries, but I have trouble finding names that are easy to type or remember (like `boost`)... so I end up calling some of them "helper" or "stdext" or whatnot, which isn't a great idea. How do you find names for your libraries that are easy to remember and easy to type, and which aren't too generic (like "helper" or "std" or "stdext" or the like)? Any suggestions on how to go about doing this?


Launching web-app with database without static ip

I have created a small web-app and want to deploy it. I have used struts2 and mysql for the database. The problem is that I do not have a static ip to run the app on my machine. Can anyone suggest me hosting services that host java pages and mysql? Since this is a project I am not doing for money, I would prefer free servers even if they are allowing usage for a short period of time.


What should a tester (Quality Assurance) person do on a scrum team?

Coming from a scrum environment with no integrated testing support and an independent minded QA staff, how is a tester (QA person) best integrated with a scrum team? What should they do? For reference some test functions are: * Unit Testing * Integration Testing * Functional Testing * Performance Testing * Acceptance Testing


What is the standard for naming variables and why?

I'm going through some training on objective-c. The trainer suggests setting single character parameter names. The .NET developer in me is crying. Is this truly the convention? Why? For example,               @interface Square : NSObject     {       int size;     }          -(void)setSize: (int)s;      I've seen developers using underscores `int _size` to declar variables (I think people call the variable declared in `@interface` ivar for some unknown reason). Personally, I prefer to use descriptive names. E.G.               @interface Square : NSObject     {       int Size;     }          -(void)setSize: (int)size;      C, like C# is case sensitive. So why don't we use the same convention as .NET?


Is there a difference between multi-tasking and time-sharing?

Just going over my school notes, my teacher identifies _multi-tasking OS_ , and _time-sharing OS_ as two different things.   I really don't see a difference between the two.   **MULTI-TASKING** : You load a number of programs in the memory and execute them. You execute another program if the time quantum allocated to the current program expires OR if it goes on to do I/O and leaves the CPU OR if it finishes execution.   **TIME-SHARING** : the same,again.   The same applies in case of _serial processing_ and _batch processing_. Although they are the same, I guess the only difference would be the way in which control information is passed to the CPU. Maybe, and again MAYBE, in serial processing you need to provide the punch cards with all the processes while in batch, the entire batch uses the same set of control information.   Like all the print jobs would have the same control information.


which pattern to use - if at all

I am fairly new to using patterns and although I understand some of them to a point I find it difficult to work out which one(s) to use in a particular situation. I am trying to wrap up an existing db schema into a number of objects and am not sure if I should simply be using inheritance or a mixture some patterns I have an options table, holding the base properties for an item thus:               id     type     code     name      These options also has availability - stored in another table               id (from option table)     fromdate     todate      and prices in another table               id (from option table)     validfrom     fromdate     todate     price      and lastly a booked table this time keyed on the option id and the person who has booked it               id (from option table)     personid     bookedPrice      Just to add more into the mix, there are also a couple of particular option types which have additional properties that are unique to them. Thinking maybe I should use inheritance for the most part - as the price/availability bits are used for ALL option types and then decorate the unique options with these extra bits in those particular cases. So in different circumstances this data will need to be loaded into various objects I wonder if its best to inherit from the base option - making an AvailabilityOption and a PricedOption etc and extending the base option like that or decorating the base option with the extended properties. Not sure if there is enough information here to answer that. I wonder if someone could explain the benefits and pitfalls of each so I don't end up getting myself into a cul de sac?


How safe is it to rely on thirdparty Python libs in a production product?

I'm new to Python and come from the write-everything-yourself world of PHP (at least this is how I always approached it). I'm using Flask, WTForms, Jinja2, and I've just discovered Flask-Login which I want to use. My question is about the reliability of using thirdparty libraries for core functionality in a project that is planned to be around for several years. I've installed these libraries (via pip) into a virtualenv environment. What happens if these libraries stop being distributed? Should I back up these libraries (are they eggs)? Can I store these libraries in my project itself, instead of relying on pip to install them in a virtualenv? And should I store these separately? I'm worried that I'll rely on a library for core functionality, and then one day I'll download an incompatible version through pip, or the author or maintainer will stop distributing it and it'll no longer be available. How can I protect against this, and ensure that any thirdparty libraries that I use in my projects will always be available as they are now?


Why is free software good for programmers?

When I say Free Software I mean it in the FSF terms. Free as in Free Speech, not as in Free Beer. Why is it a good idea for programmers to use _and_ write Free Software?


Why is polling accepted in web programming?

I am currently working on a Ruby on Rails project which shows a list of images. A must-have for this project is that it shows new posts in realtime without the need of refreshing the web page. After searching for a while, I've stumbled upon some JavaScript solutions and services such as PubNub; however, none of the provided solutions made sense at all. In the JavaScript solution (polling) the following happens:   * User 1 views the list of photos.   * In the background the JavaScript code is polling an endpoint every second to see if there is a new post.   * User 2 adds a new photo.   * There is a delay of 50 ms before the new cycle is triggered and fetches the new data.   * The new content is loaded in the DOM. This seems odd when translated to a real world example:   * User 1 holds a pile of pictures on his/her desk.   * He/she walks to the photographer every second and asks if he has a new one.   * The photographer makes a new photo.   * This second when he/she walks in, she can take the picture and put it on the pile. In my opinion the solution should be as following:   * User 1 holds a pile of pictures on his/her desk.   * The photographer takes a new picture.   * The photographer walks to the pile and puts it with the rest. The PubNub solution is basically the same, however this time there is an intern walking between the parties to share the data. Needless to say, both solutions are very energy consuming as they are triggered even when there is no data to load. As far as my knowledge goes there is no (logic) explanation why this way of implementation is used in almost every realtime application.


"UML is the worst thing to ever happen to MDD." Why?

William Cook in a tweet wrote that: " _UML is the worst thing to ever happen to MDD. Fortunately many people now realize this ..._ " I would like to know the reasoning behind that claim (apparently, I'm not referring to his personal opinion). I've noticed that many people out there don't like UML that much. Also it is worth mentioning that he is in academia, where UML is preety much the holy grail of effective design and modelling.


Working for free?

I came across this article Work for Free that got me thinking. > The goal of every employer is to gain more value from workers than the firm > pays out in wages; otherwise, there is no growth, no advance, and no > advantage for the employer. Conversely, the goal of every employee should be > to contribute more to the firm than he or she receives in wages, and thereby > provide a solid rationale for receiving raises and advancement in the firm. > > I don't need to tell you that the refusenik didn't last long in this job. > > In contrast, here is a story from last week. My phone rang. It was the > employment division of a major university. The man on the phone was > inquiring about the performance of a person who did some site work on > Mises.org last year. I was able to tell him about a remarkable young man who > swung into action during a crisis, and how he worked three 19-hour days, > three days in a row, how he learned new software with diligence, how he kept > his cool, how he navigated his way with grace and expertise amidst some 80 > different third-party plug-ins and databases, how he saw his way around the > inevitable problems, how he assumed responsibility for the results, and much > more. > > What I didn't tell the interviewer was that this person did all this without > asking for any payment. Did that fact influence my report on his > performance? I'm not entirely sure, but the interviewer probably sensed in > my voice my sense of awe toward what this person had done for the Mises > Institute. The interviewer told me that he had written down 15 different > questions to ask me but that I had answered them all already in the course > of my monologue, and that he was thrilled to hear all these specifics. > > The person was offered the job. He had done a very wise thing; he had earned > a devotee for life. > > The harder the economic times, the more employers need to know what they are > getting when they hire someone. The job applications pour in by the buckets, > all padded with degrees and made to look as impressive as possible. It's all > just paper. What matters today is what a person can do for a firm. The > resume becomes pro forma but not decisive under these conditions. But for a > former boss or manager to rave about you to a potential employer? That's > worth everything. What do you think? Has anyone here worked for free? If so, has it benefited you in any way? Why should(nt) you work for free (presuming you have the money from other means to keep you going)? Can you share your experience? Me, I am taking a year out of college and haven't gotten a degree yet so that's probably why most of my job applications are getting ignored. So im thinking about working for free for the experience?


Trying to learn how to use WCF services in a WPF app, using MVVM

We're working on a major re-write of a legacy VB6 app, into a WPF app. I've written several WCF services, which are meant to be used with the new WPF app. We want to use the MVVM design pattern to do this, but we don't have experience at that. So, in order to learn MVVM we've watched a video on WindowsClient called How Do I: Build Data-driven WPF Application using the MVVM pattern. This is a great introduction, and we refer to it a lot, but for our situation it doesn't quite give us enough. For example, we're not certain how to use datasets returned by my WCF services in our new WPF app using the ideas that Todd Miranda introduced in the video I referenced. If we did as we think we're supposed to do, then we should design a class that is exactly like the class of data returned in my WCF service. But we're wondering, why do that, when the WCF service already has such a class? And yet, the class in the WPF app has to at least implement the INotifyPropertyChanged interface. So, we're not sure what to do.


Does a mobile app need to poll external data sources or can it receive data in other ways?

I'm beginning the design stages of a mobile application. I'm looking for knowledge about common practices for user notifications. I understand that the SDK for the device will expose methods which will allow me to notify a user how and when I need it to. What I'm not sure about is how my application gets notified from a external data source. Is it common practice to poll a web service for data periodically? Or is it more likely that my application will have the facility to receive data at any time? For example: I have a website which asks users to fill out a contact form. I would like my mobile app to display a notification when one of these forms gets filled out. Should my app be polling my data server for updated records or should my site be notifying my app somehow of a new record? Any opinions or advice are welcomed. Thanks.


Why use an OO approach instead of a giant "switch" statement?

I am working in a .Net, C# shop and I have a coworker that keeps insisting that we should use giant Switch statements in our code with lots of "Cases" rather than more object oriented approaches. His argument consistently goes back to the fact that a Switch statement compiles to a "cpu jump table" and is therefore the fastest option (even though in other things our team is told that we don't care about speed). I honestly don't have an argument against this...because I don't know what the heck he's talking about.   Is he right?   Is he just talking out his ass?   Just trying to learn here.


Why should I push if I'm working alone in a local repository?

I'm interacting with Git through GitHub for Windows, which is funny since I'll never push my repository to GitHub. I'm working on it alone and it's intended to be used only by me. I noticed that my commits are listed under "unsynced commits" and under "history" it says "no commits". Which brings me to the question, what will I achieve by pushing except my commits listed under "history"?


What legal considerations do I need to have when programming?

Recently I worked with a group to create a logging system for tutoring labs to track Tutor hours, and usage of the labs. We had to change the design a fair amount to be in compliance with FERPA. My question stems from the curiosity that in my course of study there has never been a real mention of how people in this field have to deal with complying with the law in their work. So I would like to know how much programmers have to consider the law in the work they do.


Interface method signature not restrictive enough

I wrote a piece of code at my job sometime ago. While writting the code I wrote few interfaces who would allow me to add more flexibility and at that time I was also trying to understand OOP concept more deeper. So in the interface I wrote I have a method signature similar to this :               void Add(ImyBase objToAdd)      And then I have few class implementing this interface. But what is bothering me is that I find myself doing this kind of thing pretty often in this `Add` method               public void Add(ImyBase objToAdd)     {         if(!(objToAdd is ImyBaseDeviation))             throw new ArgumentException("blablabla");              //do stuff     }      At the time it was a smell to me but I didn't really bothered with it simply because I'm solo on this projet and this piece of code is only used within my compagny and there only 2 IT guys in there (me + some one else) and this is not near to change. Anyway I recently came back to that piece of code and from my previous reading (actually more than that but this one is pretty similar) it now actually really look bad to me and I'm trying to figure out the best way to improve this piece of code. I don't like the code as it stand now because the interface allow more than the concrete type generally allow so basically the concret implementation doesn't respect the contract given by the interface. I tough of a few solutions First simply delete the `Add` method from the interface since anyway calling `Add` have a high chance to throw an exception. So to call `Add` you need the concret type anyway. So here the object would still have a `Add` method but with the accepted type as a parameter. Secondly add a method who would look something like this in the interface               bool IsValidToAdd(ImyBase objToTest)      But that doesn't satisfy me. So I'm seeking advise from more advance people like you to help me to figure out what would be the best way to implement this so it stay the cleanest possible. Sorry I'm not a native anglophone so if my question need editing or grammar fixing please go ahead. Thank you


Is there any complications or side effects for changing final field access/visibility modifier from private to protected?

I have a `private final field` in one class and then I want to address that field in a subclass. I want to change field access/visibility modifier from `private` to `protected`, so I don't have to call `getField()` method from subclass and I can instead address that field directly (which is more clear and cohessive). Will there be any side effects or complications if I change `private` to `protected` for a `final` field? UPDATE: from logical point of view, it's obvious that descendant should be able to directly access all predecessor fields, right? But there are certain constraints that are imposed on `private final` fields by JVM, like 100% initialization guarantee after construction phase(useful for concurrency) and so on. So I would like to know, by changing from `private` to `protected`, won't that or any other constraints be compromised?


Structure of a Git repository

Sorry if this is a duplicate, I looked. We're moving to Git. In Subversion, I'm used to having \trunk, \branches and \tags folders. With Git, switching between branches will replace the contents of the working directory, so am I right to assume that the way we used to work just doesn't apply with Git? My guess is that I'd have a repo folder with maybe a gitignore and readme.txt, then the folders for the projects that make up the repo, and that's it.


Library to fake intermittent failures according to tester-defined policy?

I'm looking for a library that I can use to help mock a program component that works only intermittently - usually, it works fine, but sometimes it fails. For example, suppose I need to read data from a file, and my program has to avoid crashing or hanging when a read fails due to a disk head crash. I'd like to model that by having a mock data reader function that returns mock data 90% of the time, but hangs or returns garbage otherwise. Or, if I'm stress-testing my full program, I could turn on debugging code in my real data reader module to make it return real data 90% of the time and hang otherwise. Now, obviously, in this particular example I could just code up my mock manually to test against a `random()` routine. However, I was looking for a system that allows implementing any failure policy I want, including:   * Fail randomly 10% of the time   * Succeed 10 times, fail 4 times, repeat   * Fail semi-randomly, such that one failure tends to be followed by a burst of more failures    * Any policy the tester wants to define Furthermore, I'd like to be able to change the failure policy at runtime, using external knobs or switches that can be removed (along with the rest of the library) prior to shipping the code. (If the component is loaded by a dependency injection framework, we could provide the mock as one implementation in the testing release and withhold it from the shipped build.) In pig-Java, I'd envision a `FailureFaker` interface like so:               interface FailureFaker {         /**             Return true if and only if the mocked operation succeeded.             Implementors should override this method with versions consistent             with their failure policy.          */         public boolean attempt();     }      And each failure policy would be a class implementing `FailureFaker`; for example there would be a `PatternFailureFaker` that would succeed N times, then fail M times, then repeat, and a `AlwaysFailFailureFaker` that I'd use temporarily when I need to simulate, say, someone removing the external hard drive my data was on. The policy could then be used (and changed) in my mock object code like so:               class MyMockComponent {         FailureFaker faker;              public void doSomething() {             if (faker.attempt()) {                 // ...             } else {                 throw new RuntimeException();             }         }              void setFailurePolicy (FailureFaker policy) {             this.faker = policy;         }     }      Now, this seems like something that would be part of a mocking library, so I wouldn't be surprised if it's been done before. (In fact, I got the idea from Steve Maguire's _Writing Solid Code_, where he discusses this exact idea on pages 228-231, saying that such facilities were common in Microsoft code of that early-90's era.) However, I'm only familiar with EasyMock and jMockit for Java, and neither AFAIK have this function, or something similar with different syntax. Hence, the question: Do such libraries as I've described above exist? If they do, where have you found them useful? If you haven't found them useful, why not?


Why are "class" variables misspelled?

I have started to see variable initialisations like that in Java libraries:               Class clazz = new Class();      or               Class klass = new Class();      Is there a particular reason for people to misspell the word "class" when declaring these variables, and to use a "kool boyz" sort of writing style? Also what is wrong with using something like `cls` or something similar?


How do you keep the size of your application down (memory usage and physical storage size)?

I have a personal project that I'm working on although it's quite audio and graphic-intense and I was wondering if you guys had any suggestions or solutions as to how one could keep the size and memory-usage of their application to a minimum? My application is an iPhone application and, as Apple always make clear, the application is only allowed to use a certain amount of memory (in terms of performance and actual size).


How to handle bugs that I think I fixed, but I'm not entirely sure

There are some types of bugs which are very hard to reproduce, happen very rarely and seemingly by random. It can happen, that I find a possible cause, fix it, test the program, and can't reproduce the bug. However, as it was impossible to reliably reproduce the bug and it happened so rarely, how can I indicate this in a bugtracker? What is the common way of doing it? If I set the **`status`** to fixed, and the **`solution`** to fixed, it would mean something completely fixed, wouldn't it? Is it common practice to set the **`status`** to fixed and the **`solution`** to open, to indicate to the testers, that "it's probably fixed, but needs more attention to make sure" ? **Edit:** most (if not all) bugtrackers have two properties for the status of a bug, maybe the names are not the same. By **`status`** I mean _new, assigned, fixed, closed, etc._ , and by **`solution`** I mean _open (new), fixed, unsolvable, not reproducible, duplicate, not a bug_ , etc.


A client wants us to screen work machines for pornography. Is it possible?

A long-time client has asked us to help screen their work machines for pornography. They're worried about liability if sensitive materials were found. Their main concerns (for obvious reasons) are video, audio, and image files. If possible, they'd also like to scan text-based documents for inappropriate content. They have a hierarchy of not-for-work content starting with blatantly illegal (I don't have to list details), moving down to obviously offensive, and also including things that may be offensive to some - think lingerie ads, joke cards featuring butt cracks, and anything related to Howie Mandel. My questions are:   * Is this ethical? I think it is since every employee legally agrees that their work machine belongs to the company and is subject to search. The screenings are not to occur on personal machines brought to work.   * Is it feasible? I've done a lot of image processing/indexing but this seems like a whole new world of complexity.   * Any references to successful techniques for discovering porn?   * Is it appropriate for me to archive the results when something is discovered?


What types of programming contest problems are there?

Basically, I want to make a great reference for use with programming contests that would have all of the algorithms that I can put together that I would need during a contest as well as sample useage for the code. I'm planning on making this into a sort of book that I could print off and take with me to competitions. I would like to do this rather than simply bringing other books (such as Algorithms books) because I think that I will learn a lot more by going over all of the algorithms myself as well as I would know exactly what I have in the book, making it more efficient to have and use. So, I've been doing research to determine what types of programming problems and algorithms are common on contests, and the only thing I can really find is this (which I have seen referenced a few times):               Hal Burch conducted an analysis over spring break of 1999 and made an amazing discovery:      there are only 16 types of programming contest problems! Furthermore, the top several      comprise almost 80% of the problems seen at the IOI. Here they are:              Dynamic Programming         Greedy         Complete Search         Flood Fill         Shortest Path         Recursive Search Techniques         Minimum Spanning Tree         Knapsack         Computational Geometry         Network Flow         Eulerian Path         Two-Dimensional Convex Hull         BigNums         Heuristic Search         Approximate Search         Ad Hoc Problems          The most challenging problems are Combination Problems which involve a loop (combinations,     subsets, etc.) around one of the above algorithms - or even a loop of one algorithm with      another inside it. These seem extraordinarily tricky to get right, even though      conceptually they are ``obvious''.      Now that's good and all, but that study was conducted in 1999, which was 13 years ago! One thing I know is that there are no BigNums problems any more (as Java has a BigInteger class, they have stopped making those problems). So, I'm wondering if anyone knows of any more recent studies of the types of problems that may be seen in a programming contest? Or what the most helpful algorithms on contests would be?


Should unit test be in separated repository?

Should I put unit testing stuffs in a separate repository, not in the same repository as the programming library? So I reference the programming library as submodule. But most open source projects that I have seen do not organize the projects like what I mention above. Can anyone explain which approach is better?


BEST Format/Protocol for RESTful SOA

Which is the best protocol / format for SOA designs using REST. Here are some options but i can't decide...   * XML   * JSON   * YAML   * ProtoBuf   * _... anything else i might have missed_ These are my requirements...   * should be lightweight and less bandwidth guzzler   * should have existing client libs in Python and PHP   * should scale VERY WELL _**\-- UPDATE --_** We have two machines (one is Python -- our middletier) and the other is PHP (front end -- used for rendering different HTML for old browsers, HTML 5 browsers and our Adobe AIR client). We need a communications pipe between the Python and PHP machine -- and we think a RESTful service pipe will be a good idea -- we just can't decide on the format.


How to automate the API Diff document?

We can use doxygen to do the documentation, but how can I do the API Diff? Any open source or free solution for that? Or I need manually prepare? Thanks.


How does contenteditable work?

I recently came across an article where if you enter               data:text/html,%20<html contenteditable>      into the address bar of a browser that supports HTML5, you can type in the window.   I managed to figure out that with this you can basically write html in the address bar (it would be rather cumbersome) but I do not understand how or why it works. What are the other functionalities of this command?


Changing message without redeploying / restarting application

Question: In java application, How to change error message or simple alert text without redeploying / restarting application Closest answers I could think up **(1)** is to have a new error messages in specific file in specific location say `"\root\resources\messages.txt"`and to create a file object for it like.               File msgFile = new File("\root\resources\messages.txt");      `msgFile.exist()` will return true or false based on the result we can display pre-define message defined else where in application or use this message **(2)** having _a property file_ can sound the same but it'll be loaded only once when application is started so we have to restart Is there anyother way to achieve this? what better place to ask than here..


How to get started with Github (for me)?

I registered myself in github a few days ago. Mainly for starting projects to share some of my ideas with others as well as get the source available from anywhere. This is my first open-contribution site. I mean, I haven't used sourceforge or Google Code. Now the client software installation and other setup process are not done yet. Because I found it a bit confusing. Probably the cause is, I have very little idea about git as a source control system. I have only used perforce with a GUI(p4v) in the workplace and knows the very basics like get a revision/open for edit/commit/revert etc. Moreover I shall be mostly working with C#. And I shall be using Visual Studio and Windows. I have found in internet that there are other clients for visual studio. May those will suit better for me. So, what are your suggestions? How can I get started and proceed?


ASP.NET MVC WebService - Security for Industrial Android Clients

I'm trying to design a system that will allow a bunch of Android devices to securely log into an ASP.NET MVC REST Web service. At present neither side are implemented. However there is an ASP.NET MVC website which the web service will site along side. This is currently using forms authentication. The idea will be that the Android devices will download data from the web service and then be able to work offline storing data in their own local databases, where users will be able to make updates to that data, and then syncing updates back to the main server where possible. The web service will be using HTTPS to prevent calls being intercepted and reduce the risk of calls being intercepted. The system is an industrial system and will not be in used by the general Android population. Instead only authorized Android devices will be authorized by the Web Service to make calls. As such I was thinking of using the Android devices serial number as a username and then a generated long password which the device will be able to pick up - once the device has been authorized server side. The device will also have user logins - but these will not be to log into the web service - just the device itself - since the device and user must be able to work offline. So usernames and passwords will be downloaded and stored on the devices themselves. My question is... what form of security is best setup on the web service? Should it use forms Authentication? Should the username and password just be passed in with each GET/POST call or should it start a session as I have with the website? The Android side causes more confusion. There seems to be a number of options here Spring-Android, Volley, Retrofit, LoopJ, Robo Spice which seems to use the aforementioned Spring, Retrofit or Google HttpClient. I'm struggling to find a simple example which authenticates with a forms based authentication system. Is this because I'm going about this wrong? Is there another option that would better suite this?


The present and future of programming in local languages

Can programming become language-independent? Will we always program in English? Will we ever be able to program in our local languages? Is there any research that addresses the matter? Are there any such developments?


Abstraction Layer over ORM Generated Entities

I am learning LINQ to SQL (and planning to learn Entity Framework). Initially I used a abstraction layer to convert LINQ to SQL entities into a domain objects. Later I discovered the “Inheritance Mapping” option and removed the abstraction layer and started to use ORM entities directly as domain objects. After some time, I got a road block when I don’t use abstraction layer. Please read it here: http://stackoverflow.com/questions/11470037/get-all-associate- composite-objects-inside-an-object-in-abstract-way   1. Is it possible to achieve all tasks without using Abstraction layer over ORM?    2. What are the rationale to decide have/not have abstraction layer? **REFERENCE** :   1. http://martinfowler.com/bliki/OrmHate.html


Where can I get beta testers for a software library?

There are a few similar questions to this one already. But mine differs enough to warrant being asked separately. I've written an authentication ASP.Net library and I'm looking for beta testers. I've posted to the forums I frequent, but they are not forums commonly used by .Net people. I've tried inviting friends, but honestly I don't personally know a whole lot of people that use ASP.Net. I'm afraid that posting such a request to http://asp.net/forums would be marked as spam and deleted. What else can I do to find developers to test my library?


With a highly bespoke responsive website, will it be most effecient to customise bootstrap / use something else (pure-io?) / roll my own rules

I've got a few non trivial responsive website builds coming up. They are not platforms or apps, but large marketing / brochure websites where eye for detail is important. I've used bootstrap extensively as well as pure.io, as well as my own rules. I'm wondering what is the most efficient way to build these. I am planning on starting with bootstrap and customising, but I chose pure.io in the past, as I had to make so many changes to bootstrap to get a very fiddly design into it (ie it went against bootstrap conventions) Does anyone have any advice on this?


Unit Testing: Should we care about distinguishing between Mocks and Stubs?

There's been a lot of talk in various blogs, forums and on StackExchange about the distinction between Mock and Stub objects (most of them specifically referencing the Rhino Mocks framework). These include posts from Martin Fowler and a chapter in Roy Osherove's "The Art of Unit Testing". I'm currently looking at how to write more maintainable, readable tests, and in doing so have been looking at alternative isolation frameworks to Rhino. I've looked into the nSubstitute library, which just references "Substitutes" rather than "Stubs" or "Mocks". This post from Ayende suggests that he may head in a similar direction for RhinoMocks 4.0 My question is - while there seems to be a concensus about the distinciton betewen the purpose of a Mock and a Stub, is it really worth caring about? Does distinguishing between the two lead to more maintainable/readable tests, or does it just introduce unnecessary complexity?


what licence for an application that uses libraries with different licences

I have developed .NET software that uses two libraries:   * Library A has MIT licence and I'm using my own version of it as I edited the source code of this library.   * Library B has Ms-PL licence and I use only the binaries. My application will be distributed freely in binaries and source code(including the source code of library A). Since it is my first time to distribute a public application I want to know few things:   * what Licence I should choose.   * a part from the to-be-chosen licence Eula presented to the user in the installation , what else I should do for the binaries ?   * for the source code, what should I include exactly ?


What to look for in an outsourced partner

I'm working in a small startup as the sole developer in my spare time. We might need some more development help and are looking at an Indian company which comes recommended by someone we know (although they are not very technical). I'll be having an informal chat with them, and thought I'd see if people here had some wisdom regarding what to look for and good questions to ask. At least I thought I'd try to get some:   * Code examples   * Info on any policies they might have regarding documentation of code   * Some background on the people we will be working with If you guys can think of anything else I should be particularly on the lookout for, or have any other tips to run the conversation, your input would be much appreciated! ** **Update** ** To be clear: I have some about what questions to ask a sole developer/freelancer. In this instance I will be talking to a an Indian company offering outsourcing services. I'm curious to know whether there is any particular issues I should be aware of, and if someone with this kind of experience have any hard earned wisdom to share. See MainMa's answer for one such point, although it's not developer-specific. I see the title of the question has been slightly modified so it no longer correctly conveys what I was trying to ask.. maybe this was the wrong place for this question. :/


Was getting a computing science degree easier 10 years ago

I am currently a 3rd year computing science student at a Canadian University. I find it quite challenging, and extremely interesting. One thing that i have noticed is that each person i speak to that took a class 3 or so years ago learned much less than i did in the same class, and people who are taking 1st year classes are doing more than i remember doing in my 1st year classes. Is this just me remembering stuff bad, or do you believe that getting a computing science degree was easier 10 (or even 5) years ago?


Does it make sense and is it to acceptable to say ".NET code"?

There is C# code, VB.NET code... **Can I also say ".NET code" as an umbrella term that covers all the languages you can use with the .NET framework?** I've seen people using it as well as people saying it shouldn't be used...


How can I improve my skills while working on actual projects, in the absence of more experienced developers?

I'm the lead developer at a small company, working with C# and ASP.Net. Our team is small, 2-3 people, without much experience in development and design. I don't have the opportunity to learn from more senior developers, there is no one in my team to guide me and help me choose the best approaches, as I take care most of the projects myself. How can I improve my software development skills while working on actual projects, in the absence of more experienced developers?