DDD / Layers and legacy systems

I have to refactor a complex C# app (many dialogs, mixed logic and so on). There is a part managing the communication with special hardware equipments (sending commands and receive data via asynchronous c# callbacks). The code is "spaghetti" with mixed UI/Logic/Communication/etc and my task is to split the layers in a DDD sense. So, to which layer belongs a callback driver routine? The callbacks are creating "bubbles" in the system, up to the UI layer and because of this I cannot enforce the essential principle that any element of a layer depends only on other elements in the same layer or on elements of the layers "beneath" it.


Sell me on IoC containers, please

I've seen several recommend use of IoC containers in code. The motivation is simple. Take the following dependency injected code:               class UnitUnderTest     {         std::auto_ptr<Dependency> d_;     public:         UnitUnderTest(             std::auto_ptr<Dependency> d = std::auto_ptr<Dependency>(new ConcreteDependency)         ) : d_(d)         {         }     };               TEST(UnitUnderTest, Example)     {         std::auto_ptr<Dependency> dep(new MockDependency);         UnitUnderTest uut(dep);         //Test here     }      Into:               class UnitUnderTest     {         std::auto_ptr<Dependency> d_;     public:         UnitUnderTest()         {             d_.reset(static_cast<Dependency *>(IocContainer::Get("Dependency")));         }     };               TEST(UnitUnderTest, Example)     {         UnitUnderTest uut;         //Test here     }          //Config for IOC container normally     <Dependency>ConcreteDependency</Dependency>          //Config for IOC container for testing     <Dependency>MockDependency</Dependency>      (The above is hypothetical C++ example of course) While I agree that this simplifies the interface of the class by removing the dependency constructor parameter, I think the cure is worse than the disease for a couple of reasons. First, and this is a big one for me, this makes your program dependent on an external configuration file. If you need single binary deployment, you simply cannot use these kinds of containers. The second issue is that the API is now weakly and worse, _stringly_ typed. The evidence (in this hypothetical example) is the string argument to the IoC container, and the cast on the result. So.. are there other benefits of using these kinds of containers or do I just disagree with those recommending the containers?


How do you deal with teachers teaching the wrong stuff?

Today was my first university day, and my software engineering class left me with a bitter taste. The professor sure seems to know about design and design patterns and MVC and the like (it's going to be his topic), but when it comes to compiling and branch prediction he seems to be a little confused. At some point he started to explain us why object-oriented programs are slower than imperative programs because object-oriented programs are interpreted while programs written in a non-OO language like, say, C, are compiled to machine code. He then proceeded to explain how modern compilers, like C compilers, try to guess which branch in a condition will be executed most of the time, and puts the first instructions of these branches before the `if` block, and that's some kind of way of implementing instruction-level parallelism. He then told us that these compilers had to do educated guesses, but a JIT compiler, like modern Java JIT compilers, could profile your code and put the instructions of the most frequently used branch before the `if` block, without having to guess. This was inexact and confusing at best. It looked like a mashup of many things confused in ways so strange I can only be thankful it's not what the course is about. Students interrupted him a few times, asking rhetorically if he was talking about Java or OO in general (he agreed that he should have been more explicit about the distinction between the two, but still told several inaccuracies), but we remained silent while he went on with his explanations on branch prediction. So. How do you tell your professor he's not on the right track? Obviously, doing it in front of everybody is not a Good Thing™. But waiting the end of the class to tell him might do some serious damage to the understanding of other students. I suspect we won't hear this kind of stuff again, and the rest of what he told us did make sense, so filing a complaint is certainly not an option (especially after just one class). He seems to be in position of teaching design patterns, but he really went off-road with his talk about compilers and that stuff.


Is Dependency Injection worth it outside of UnitTesting

Given a constructor that will never, ever, have to use any different implementations of several objects that it initializes, is it still practical to use DI? After all, we might still want to unit test. The class in question initializes a few other classes in its constructor and the classes it uses are pretty specific. It will never use another implementation. Are we justified in avoiding trying to program to an interface?


Handling my antiquated coworker

I'm a fairly young programmer, and I work at a medium sized company's IT department. I have a coworker, and he is a really good Visual Basic 6 programmer. And I mean really good. Honestly. He can deliver working applications, containing very few bugs, in the time I need to get my first cup of coffee, and boot my machine. He is just that good. Thing is, we are working with a team, and his working style is completely antiquated. He doesn't believe in versioning software (if you just make sure your code is correct, you don't need all that nonsense). Doesn't believe in deployment (I can deliver a working executable. How that is deployed is for the sysadmins to figure out). Doesn't believe in abstraction. ('if you want to create a subroutine, go ahead, but don't call any subroutines from that subroutine. It gets messy that way, and the code is hard to follow. This way every one can follow every step on the way.' or 'yeah, sure you can use that library to do that for you, but that way you don't really understand what's going on') and certainly doesn't believe in OOP. (we work in VB.net) He is so good in what he does, he can deliver applications way faster than I can. But it just doesn't work in a team. Our other team member is quiet, and doesn't like to speak out, though he tends to agree. Our manager thinks I make valid points, but is not a programmer. I have a really hard time maintaining programs he has written, and it doesn't make for a good team atmosphere. What do you think is the best thing for me to do?


How to "neutralize" those who write bad code on the team?

I always loved this article on JoelOnSoftware called "Getting Things Done When You're Only a Grunt" . I could especially relate when I was newbie (and still feel like I will ALWAYS be one). About #4, neutralizing the bozo's. What advice do you have for actually implementing this in real situations at work? It doesn't seem to be as easy (at least on our team) as simply logging a bug against someone's bad code. What works for all the rest of you out there?


When will be safe to choose Multi-thread design without dead lock?

Sometime we really need to choose a multi-threaded design, because single- threading will block the UI or block another thread. But sometimes using multiple threads is just one of the choices, for example, you may able to replace multi-threading with timer. In that situation, you may want to avoid the effort of investigating the performance risk of using timer and directly go to the multi-threaded design. But as we know, threading has a lot of drawbacks:   1. Sync issue.   2. Debugging is tough for sync issue.   3. Deadlock issue. The #1 can always resolved by adding locks, and #3 is the hardest to resolve, it may need design level changes. So let's focus on when will be safe to choose multi-threaded design without having deadlock issues. I use the Following rules to judge it is safe or not:   * The component only has input data and entry function call interaction.   * Or the component only has output data and exit function call interaction.   * Or you have entry and exit data or function call, but you can make sure all the data that goes in can be handled asynchronously. (I cannot think out of case, because you almost always need to syncronized to push the data into an queue.) Does that make sense to you, any thought is welcome.


Are optional parameters helpful or a hindrance to application maintenance?

As stated in the title, are optional parameters, such as those used in C# helpful or are they a hindrance to application maintenance and should be avoided as they can make the code harder to understand?


Live search/filter as you type in client approach

As an exercise for myself to practice my JavaScript "skills" I'm trying to write a client-side filter. It should be able to filter "content blocks" as the user types. By "content block", I mean a list of DomElements that each contain at least one text node - it is possible that they contain more, and even a different amount of text nodes, nested inside other nodes, etc. I've thought of 2 approaches:   1. On page initialization, scan all nodes and store all the text in some kind of Map or a tree.   2. Simply iterate over every item and check whether it has the string to search/filter for. One could add performance here by caching, only filtering the current remaining items if text is added, etc. Obviously, if the number of nodes is really big, option 1 will take a while to build the 'index' but it will perform faster once it is built. Option 2 however will be available right on page load since no initialization is performed. But of course it will take longer to search. So my question is: what is the best approach here? And how would one implement 'caching' and/or 'index'?


Software on Budget and on time?

We've all (almost all) have heard about the horror stories as well as perhaps studied about them. Its easy to find stories of software that is over budget and late. I wanted to hear from developers the opposite story: **Question:**   * Do you know, or have worked on a project that was on budget and on time?   * What is the most valuable lesson you learned from it?


How to apply verification and validation on the following example

I have been following verification and validation questions here with my colleagues, yet we are unable to see the slight differences, probably caused by language barrier in technical English. An example:   * **Requirement specification** User wants to control the lights in 4 rooms by remote command sent from the UI for each room separately.   * **Functional specification**     1. The UI will contain 4 checkboxes labelled according to rooms they control.     2. When a checkbox is checked, the signal is sent to corresponding light. A green dot appears next to the checkbox      3. When a checkbox is unchecked, the signal (turn off) is sent to corresponding light. A red dot appears next to the checkbox. Let me start with what I learned here: **Verification** , according to many great answers here, ensures that product reflects specified requirements - as functional spec is done by a producer based on requirements from customer, this one will be verified for completeness, correctness). Then design document will be checked against functional spec (it should design 4 checkboxes..), and the source code against design (is there a code for 4 checkboxes, functions to send the signals etc. - is it traceable to requirements). Okay, product is built and we need to test it, **validate**. Here comes our understanding trouble - **validation** should ensure the product meets requirements for its specific intended use which is basically business requirement (does it work? can I control the lights from the UI?) but testers will definitely work with the functional spec, making sure the checkboxes are there, working, labelled, etc. They are basically checking whether the requirements in functional spec were met in the final product, isn't that verification? (should not be, lets stick to ISO 12207 that only validation is the actual testing)


Who invented pointers?

Pretty simple question, but something I haven't been able to find out. Who was the first person to describe the idea of a pointer? The abstract concept itself?


.NET mulithreading and quad core processors

I have a single threaded application that runs on a machine with a quad core processor. The scheduled tasks that run VB.NET forms are too slow. I am new to multi threading and parallel computing. If you have a single threaded application that runs on a server with a multi core processor then does the application only ever use one of the processors? What happens if you have multiple scheduled tasks and multiple instances are in memory at the same time? I have read this question on Stackoverflow: http://stackoverflow.com/questions/607775/how-to-write-net-applications-that- utilize-multi-core-processors, but I am still not clear.


What does "programming concepts" mean?

I am recent graduate and I have applied for a job, but I'm stuck on how to answer one of the questions: > What programming technology, programming topics, and programming concepts > are you following at present? I am a little confused with this question as it's a bit vague. I know what programming technologies are—C#, Java, .NET, etc—but what are programming topics and concepts? I take it that programming topics are everything related to C# or related to programming in general? I'm not so sure what programming concepts are. How can I answer this question?


How do you version/track changes to SQL tables?

When working in a team of developers, where everyone is making changes to local tables, and development tables, how do you keep all the changes in sync? A central log file where everyone keeps their sql changes? A wiki page to track alter table statements, individual .sql files that the devs can run to bring their local db's to the latest version? I've used some of these solutions, and I'm tyring to get a good solid solution together that works, so I'd appreciate your ideas.


What do you do when you have nothing to do?

Let's say that you are idling. There is no ongoing project and you are left nothing to do sometimes. Or there are probably some project is running but you can't proceed. So, you have nothing to do and you are bored. In these kind of situations, what are the things that you will normally do to kill the time? What I normally do is:   * Read some books. But it makes me sleepy sometimes, and I got bored easily on some books.   * Browse SE sites and trying to answer some questions. This will probably kill some minutes.   * browse for anything that is interested to read on (things like physics, how things works, biology etc)   * programming puzzles. I'm probably running out of topic or things to do. And it's in an office, so, watching, facebooking, or gaming is not a good idea.


Can Agile/Scrum be used by 1 or 2 developers?

Everything I've been reading and researching up to this point describes how Agile/Scrum works great with teams of about 4 to 6 members, maybe even more. In my current shop, we have about 8 developers or so, but given the nature of the volume of projects and the number of departments we support, we never have more than 1 or 2 folks assigned to a given project. Can I still use Agile/Scrum with a team of 1 or 2 developers? I'm working on making the pitch to my manager to start working with this methodology, but I need to be able to explain how to scale things back for a small developer crew, or convince them to make sure we get more members on a given project.


What can be done to stop losing resources and unify Mercurial and Git?

Both Mercurial and Git were created as a replacement for the same program and to solve the same problem which you can read about in Martin Beckett's answer to How did Git and Mercurial develop so similarly at the same time? question. These two tools are very similar and borrow from each other according to Scott Chacon in his Hg and Git: Can't we all just get along? presentation at PyCon 2010. I think we, the people, do waste huge amount of resources by having these two tools which do the same, yet operate differently. Is it possible to unify Mercurial and Git and stop wasting our resources? What actions should be taken?


Is the cloud ready to replace core business systems?

Questions like this have been asked before (like here), but a lot can change in a year. My company is very interested in migrating core systems to the "cloud". Non- technical upper-management doesn't quite know what that means, but they are excited at the idea and have already started adopting cloud-based systems. Having gone through an ERP migration, and experiencing first-hand what a pain it is to deal with legacy systems, I'm really concerned that by going to the cloud, losing control of our data, we are going to begin a cycle of never- ending migration as cloud services come online and then blink out of existence. To say nothing of the technical demands of learning, programming, and keeping up with multiple non-stable APIs in order to get disparate cloud- based systems to talk with one another. I have other concerns such as privacy, uptime, data ownership, maintenance, etc. Is the cloud really ready for the prime time? If you were a business owner, would you choose to place your key, business-critical, systems on the cloud? As a programmer, do you trust the cloud and the companies providing those services to be reliable and have the longevity of a traditional software solution? If it is not ready now, when will it be, if ever?


Does this licensing clause allow redistribution of this application?

As a software developer, I find a frequent need to create icons for my applications. Nothing has ever worked as well as IcoFX for this purpose. Unfortunately, the program is no longer free - but I still have the installer for an older version. My question is whether or not I can distribute copies of the installer. The license agreement contains the following pertinent clauses:               6. All redistributions of the Software's files must retain all         copyright notices and web site addresses that are         currently in place, and must include this list of         conditions without modification.          7. None of the Software's files may be redistributed for         profit or as part of another Software package without         express written permission of the Author.          10. The Author reserves his rights to modify this agreement          in the future.      The first two clauses would seem to suggest that I can legally distribute verbatim copies of the installer but the last clause has me confused. If the author modifies the agreement and removes the ability to distribute copies, does it apply to my copy that I downloaded a while back?


What shall I include in a 10 week web technologies course?

In September I will be teaching a university module on web technologies. This session will be available to 1st year (freshman) students who don't necessarily have any programming knowledge or know how the web works. In the 2nd semester I will be teaching Flash, which is my specialism, so I know exactly what I am going to teach, but in the 1st semester I will be teaching them web standards technologies - HTML, CSS, JS, jQuery, PHP and MySQL. Where I need advice is how to proportion the emphasis for each part, and which parts of each technology to cover. Another real issue I'm struggling with is how much of the bad old ways should I teach them? Do they need to know about bold as well as strong, etc. UPDATE: based, on your feedback I will only be teaching the latest version of everything - CSS3, HTML5 etc. I'm not sure exactly how long the semester will be but I'm guessing about 10-12 weeks. Each session is a 2 hour lab. Obviously there's only so much I can cover in that time and it will be up to the students to go a research this stuff properly on W3 schools etc. My ideas so far were: Lesson 0 - Course intro and overview of the current tech landscape. What is out there, what will we be learning, what won't we. What is a web server, URL etc. Looking at different example websites and discussing how they work. Lesson 1 - HTML basics (head, body, title, img, table, a, lists, h1, strong etc) Lesson 2 - CSS for styling and layout - fonts, webfonts, float etc Lesson 3 - Intro to programming JS (variables, loops, conditionals, functions) Lesson 4 - more JS programming fundamentals, DOM manipulation Lesson 5 - jQuery - making things fly about and look cool Lesson 6 - XML and Ajax Lesson 7 - PHP basics - syntax, server-side principles Lesson 8 - PHP and MySQL - forms, logins, saving user info Lesson 9 - don't know Lesson 10 - don't know Please let me know if you think this is the right order, what have I missed, how to use any spare sessions etc. Thanks :) UPDATE BASED ON RESPONSES: Thanks for all your responses - some great stuff. To be absolutely clear, this is not a computer science course, it is a practical module on a creative technology course. The emphasis definitely has to be on making cool things work rather than understanding how the backbone of the internet works. That can come later, if the students are interested. At the end of the module I would like the students to be able to produce a web page or pages that does something cool, using some or all of the technologies I cover. Many of these topics are of course far beyond the scope of a 2 hour session, however I do not have the option of reducing the syllabus, I will just have to explain what the technology does and encourage the student to research it in their own time.


Are keyboard layouts inherently flawed for programmers?

Lately I've been noticing my keyboard usage more and more and how it affects my productivity. It brought to mind a question/problem that I believe has not been truly solved in the programming community (partially based on individual preferences). **Are all/most keyboard layouts inherently flawed for programmers?** What changes to your keyboard layout do you feel would increase your productivity most? _Edit_ Remember when answering that there are a number of different factors that could make a keyboard layout flawed. For instance, if you type as fast as you believe you need to, but hitting common keys is uncomfortable, said keyboard layout could be considered flawed.


Guidance choosing tools for developing cross-platform mobile app

I have no mobile application development experience, I don't even own a rich mobile device (I can send text messages with my cellphone :) I have strong web, .NET, and Java experience but am open to develop with any language / platform. I need to target at least iPhone, Android, and Blackberry devices. I am seeking some guidance on the right set of tools for developing an application targeting these devices given my requirement. An easy deployment model would be a big plus. I have some notion of the difference between native apps and mobile apps on devices, and the later seems like it may be a good choice in terms of cross-platform support and easy deployment, but I do need access to some device information. I currently have a fairly simple Java Swing application which is backed by JSON web services. The application is launched automatically when a user logs into their computer via a login script (it's deployed on corporate-like network). The user is presented with some html formatted information, and they click a button to answer a question. That's about it! Core Requirements   * Must be able to get user identification information from the mobile device and send it to the server; the Swing client sends the Windows account and domain name.   * Would very much like to retrieve the local date and time of the mobile device and send it to the server   * Must be able to have the GUI workflow described previously: present content to user, user "clicks" a button to respond.   * Must be able to communicate with the JSON web service; if needed, could use some other data encoding, but just need to be able to communicate over HTTP (unless things are very different in the mobile world and I don't know what I'm talking about!) Nice to Have Requirements   * Render HTML fragments for the content (if not possible, could strip it down to plain text)   * Be able to "click" on a link to send an email someway for help / feedback   * "Click" link to a web site with information on how well the user is responding to their questions; could also build this into the app if it is a mobile app.   * Be able to build some kind of user options "dialog"   * Render small pictures along with the content; currently the pictures are just http resources. Thanks in advance!


Why user threads are mapped to Kernel threads

Since user threads are mapped to kernel threads, why don't we create all threads as kernel threads that is a process with **zero** user thread. Doesn't mapping of user thread to kernel thread create overhead?


Does the MIT license allow me to make a product that's a front-end for another MIT-license product?

I've been struggling with timezones online for a few years now. Because I've had enough of it, I want to develop a Chrome extension that leverages moment.js so I can paste in a representation of a time and it will return the time in the user's current timezone. So this is basically a GUI front-end for moment.js. I would release this for free on the Chrome web store (and I'm surprised that such a Chrome extension does not exist yet). Does the MIT license allow this?


How to charge freelance projects?

I am new freelancer mostly on web development and my first project used (X)HTML/CSS/PHP/MySQL/jQuery for a small custom social network like system with search engine/contact form ready/admin system. I charged this project on hourly basis about $10/h Again this was my first freelance job and i really think that the price was way too low. So how would you suggest to me to move on with the charges?


Evaluating PHP namespaces

I'm at the pre-release stage of an open-source PHP project, one which I hope will be used by other developers in their own projects. The project doesn't currently support namespaces and I'm trying to evaluate if it should use namespaces or the PEAR naming convention of Dir_Subdir_Class, which seems to have all of the same technical benefits without some of the drawbacks. To be honest, it's not an easy choice. Some points of consideration against namespaces:   * One of the ways that my project is trying to differentiate itself by providing a simpler API than other similar projects. Because namespaces are new and also because they are more complicated than the PEAR naming convention, introducing them into the codebase will make my project less simple to use. By implementing them, I lose some differentiation in terms of ease-of-use.   * While I can see some benefits to namespaces, they don't seem to solve a problem that needs to be solved in a modern PHP product that uses the PEAR naming convention. Naming conflicts while using my project should be minimal if not non-existent.   * This article gives me some pause in adopting namespaces as their implementation has been less than stellar.   * I'm also hesitant to jump on a bandwagon that may not go anywhere. As namespaces are a new feature to PHP, I'm not convinced yet that they will become standard.   * Compatibility. Almost all of the PHP code that has ever been written does not use namespaces as it's a new feature. Other libraries would be incompatible without a conversion. Some points for using namespaces:   * Perception. If namespaces become standard and a best-practice, my project could quickly become viewed as unprofessional and obsolete without them.   * Competition. While some competing PHP projects are beginning to use namespaces in their latest versions, many have yet to make the leap. Doing so now could give my project a leg-up on other projects.   * Future work would be easier if I made the switch now before the project goes public rather than after, where I would have to support two versions of it for a while.   * I want to support best-practices and if namespaces become a best practice for PHP, my project should make use of them. From what I can tell, you must choose one way or the other; you can't do both. Are there any points that I haven't considered? Are there any objective signs (no flamewars, please) that point toward or against namespaces becoming the professional standard for PHP? I would appreciate any insight or resources that you would be willing to share as I need to make a decision soon.


What is a good way to represent a many-to-many relationship between two classes?

Let's say I have two object types, A and B. The relationship between them is many-to-many, but neither of them is the owner of the other. Both A and B instances need to be aware of the connection; it's not just one way. So, we can do this:               class A     {         ...              private: std::vector<B *> Bs;     }          class B     {         private: std::vector<A *> As;     }      _**My question is:_ where do I put the functions to create and destroy the connections?** Should it be A::Attach(B), which then updates A::Bs and B::As vectors? Or should it be B::Attach(A), which seems equally reasonable. Neither of those feels right. If I stop working with the code, and come back after a week, I'm sure I won't be able to recall if I should be doing A.Attach(B) or B.Attach(A). Perhaps it should be a function like this:               CreateConnection(A, B);      But making a global function seems undesirable also, given that it's a function specifically for working with only classes A and B. **Another question:** if I run into this problem/requirement often, can I somehow make a general solution for it? Perhaps a TwoWayConnection class that I can derive from or use within classes that share this type of relationship? What are some good ways to handle this situation... I know how to handle the one-to-many "C owns D" situation quite well, but this one is trickier. Edit: Just to make it more explicit, this question doesn't involve ownership issues. Both A and B are owned by some other object Z, and Z takes care of all ownership issues. I'm only interested in how to create/remove the many-to-many links between A and B.


Are types erased in Haskell?

Haskell has a notion of “generic functions” that has some apparent similarity with common lisp—having neither experience with Haskell nor with common lisp, I might be very approximative here. This means that one can define a generic `to_string` facility to define a string representation for all types. Of course, the facility has to be defined in the special cases but there is a `to_string` function whose signature is `α → string`. Are types erased in Haskell, as they are in OCaml? If yes, how does the implementation of “generic functions” in Haskell differ from that of common lisp, where types are dynamic, and thus not erased? I understand that implementation details are compiler specific, but there is probably provisions common to many or all implementations.


How do I test my code in Python other than by doing it by hand?

I am used to user testing in Java, and I also manually test each section of code I write, but now, I want to automate it. There is no GUI for this project, so user testing is not required and I can focus code testing. The fact is, I don't know how to test code other than by calling the methods by hand, passing different parameters to them, and check the return value. I suppose automation is a solution, but don't have a clue how to pass from manual testing to automated one. Are there tools which can create the relevant tests for me, or do I need to write tests manually? What can be automated? Here is an example of code I want to test. Do I need to transform it somehow in order for it to be unit tested?               def netInfoToSend(tm, our_or_ip_version, our_or_addr_len, our_op_ip, version_their_ips,                       num_their_ips, len_their_ips, their_ips):              cellNetInfopkt = struct.pack(">I", time.time())              #         Number of addresses    [1 byte]         # cellNetInfopkt += struct.pack("B", num_their_ips)         #         Their OR's addresses    [variable]         print "peerAddress", peerAddress         print "peerAddress type", type(peerAddress)              cellNetInfopkt += struct.pack(">B", 4)         cellNetInfopkt += struct.pack(">B", 4)         cellNetInfopkt += struct.pack("B" * len(peerAddress), *peerAddress)              cellNetInfopkt += struct.pack(">B", 1)              # Address format is a type/length/value         #         This OR's address     [variable]         cellNetInfopkt += struct.pack(">B", our_or_ip_version) # IPV4         cellNetInfopkt += struct.pack(">B", our_or_addr_len)         cellNetInfopkt += struct.pack("B" * len(ownAddress), *ownAddress)              return cellNetInfopkt


Is it a bad practice to keep database schema scripts (DDL) and manipulation (DML) scripts in different modules

we have a project structure like the following "module-shared" module depends on "module-database" module and some other modules depend on "module-shared" but no other module depends on "module- database". All the DML SQL scripts are stored in "module-shared" but DDL are stored in "module-database".   * The advantage of this design is that we don't have to release the database if changes are around DML in "module- shared" and use database integration tests to make sure they are still compatible.   * The disadvantage is that this creates some confusions on the versions. For example you can have "module-shared" 2.3.1 depends on "module-database" 1.4.2 and eventually we will forget which version is compatible with which. **Questions:** Would it be a better design if we have a "module-database" which contains both DDL and DML (and all other database operations if any) and module-shared contains everything it had except database operations? What's your experiences on having multi-tier architectures? do you always use modules to segregate tiers? Do you have experiences where you may have DAO and Services in the same module? If you do, where did you keep the DDL schema scripts? **_UPDATE:_** forget to mention that the DDL is versioned using database script versioning system such as flyway. So that all DDL changes are incremental Note: e.g. a module could be gradle module, maven module, etc. Note: I am trying my best to be not biased while asking this question. So please assume that I don't have any preference on either solution. :)


Passing in config values to a method using SOLID principles

I have an email helper class that has a method that sends email:               private static class EmailHelper     {         public static void SendEmail(string from, string to, string subject, string message)         {             MailMessage msg = new MailMessage(from, to, subject, body);             var client = new SmtpClient("my.smpthost.com"); //this will be moved to config.             client.Send(msg);         }     }      My smtp host string will be placed in my config file. Question is what's the recommended way to pass the smtp host to this method? Should I have a constructor in this class that takes in the smtp string? Or, should I pass the smtp as a 5th parameter? Or should this method directly read from the config? (I realize that there may be several different ways to do this, but I am trying to understand the recommended approach, or at least approaches that are NOT recommended, keeping in mind the SOLID principles.)


Reducing work in progress - should anyone really pick up any task?

I'm in a Scrum environment, and we get feedback from the PO that all stories should be closed that are currently in progress before bringing in more stories. The goal is reducing WIP and getting stories accepted, which is a good goal. But would it really be wise to have, for instance, a DBA run a manual test script in order to close a particular story, when the part timer who does various "grunt" tasks will be available tomorrow? It seems this is the direction our PO wants to head in, but seems inefficient to me. What happens is that tomorrow the part timer is available, but there are no tasks for them, the only outstanding ones being "above their pay grade". So it seems like a tension between reducing WIP and yet having people work on things that "make sense". Do you find its better for the team to have anyone work on any task? Or do you keep work open longer in order to have certain people do what they do best?


Do I check generated code in to source control or not?

I'm developing a .Net application that uses google protocol buffers. Historically the application used the approach, advocated by the protobuf-net team, of decorating the classes with attributes instead of using .proto files. I am now in the process of migrating part of the application's client to another technology and there is a strong desire to start using the .proto files as the authority so that the two technologies can inter-operate. My plan is to automatically generate the C# from the .proto, however, my question is should I check the resulting files back into source control? Note I expect the process of code generation to be fast. How do I choose appropriate approach for above case? What is considered the best practice?


Can I use a child class variables in its parent class?

I am programming in Objective C, iOS. I create a `Class A` which is a parent class, and `Class B` inherits to `Class A`. Now I have `Class B` variables which I also need to use in `Class A`. And also one another `Class C`, `Class A` add in `Class C` (not inherits), and I want to use `Class B` variables in `Class C`. How can I access? I have created object also but not working, is that possible to access?


Run On Sentences in Technical Writing

This is just a question to think about. When you write technical documentation and programming comments, do you ever find yourself writing run-on sentences in order to be more precise? Is packing more technical information into one sentence better than creating many little sentences each with a little bit of technical information? I know it's better to have lots of little classes in their own little files. Perhaps this doesn't apply to writing?


Plan variable and call dependencies

I'd like to write down the design of my program to understand the dependencies and calls better. I know there are class diagrams which show inheritance and attribute variables. However I'd also like to document the input parameters to method functions and in particular which calls the methods function executes inside (e.g. on the input parameters). Also sometimes it might be useful to show how actual objects are connected (if there is a standard structure). This way I can have a better understanding of the modules and design before starting to program. Can you suggest a method to do this software design? It should be _one-to-one_ to programming code structure so that I really notice all quirks beforehand (instead of high-level design where thing are hard to implement without further work). Maybe some special diagram or tool or a combination? It is _static_ dependency and call design rather than time dependent execution monitoring. (I use Python if you have any specialized recommendations).


What payoffs have you seen from taking care of technical debt?

This article on technical debt has some good points, including: > Working on the "technical matters" works best when it is driven by stories. > The code base is probably in need of work everywhere, but the payoff will be > received only where the code is going to be worked on for user-facing > reasons. If no stories are going to pass through some crufty area, working > on it is largely wasted. > > Therefore, I prefer the approach of taking stories as usual (but probably > fewer of them), and following the "boy scout rule" of leaving the campground > better than you found it. In other words, wherever the stories lead us, > let's write more tests, let's refactor more aggressively. > > This approach has at least these advantages: > >   * maintains "best sensible" flow of stories; >   * provides help from all team talent; >   * provides for whole team to learn how to keep code clean; >   * focuses improvement exactly where it is needed; >   * does not waste improvement that "may" be needed; > I've seen code quality have a very big effect on long-term productivity, so I am a believer that technical debt should be taken care of. I think the post above makes sense, but I'm not so sure about the last two points. I'm interested in finding out real experiences of benefits from cleaning technical debt, even if it was not related to user stories. **What positive benefits have you seen from cleaning up your code base and ridding yourself of technical debt? What methods did you use to get the work done?**


Difference between Handler, Manager and Controller

Is there any difference between naming a class "Handler", "Manager" or "Controller"? IE: `PurchaseManager`, `PurchaseHandler`, `PurchaseController`. Do these suffices convey the same meaning or is there a clear difference between them? If there isn't a language-agnostic answer, consider Java as the language.


How do I understand an open source project code?

I open the source code and it's folder upon folder of infinite files each with infinite lines of code which doesn't make much sense to me because I dont have the context, and half of it uses functions imported from other files just to make it more confusing. Is there any simple way to know the structure of an open source application's code?


How often is an average programmer expected to reach flow?

I have recently been reading about flow and, since I have experienced this state a few times, I wondered how often an average programmer is able to work in this very focused and balanced way. Do you know if there are any **empirical studies** on how often average programmers reach flow in their daily activity, and on how this can influence productivity? I am not asking for a mere list of references to the literature (although these would be interesting) but also for a short description of such studies, if any exist.


Concrete types - as described by Stroustrup - C++ Programming Language 4th ed

I'm having a hard time with this concept. What is Stroustrup getting at here? What is special about a class whose "representation is part of its definition"? What does a "concrete type" contrast with? (I assume it contrasts with "abstract type", but since, AFAIK, you can't even bring an instance of an abstract type into existence, it seems obvious you couldn't place _that_ on the stack, initialize it, etc.) Is there such a thing as a class I could instantiate that would NOT fit this description of a "concrete class"? Normally I find BS very easy to follow, but I'm missing the point here. > The basic idea of concrete classes is that they behave “just like built-in > types.” For example, a complex number type and an infinite-precision integer > are much like built-in int, except of course that they have their own > semantics and sets of operations. Similarly, a vector and a string are much > like built-in arrays, except that they are better behaved (§ 4.2, § 4.3.2, § > 4.4.1). > > The defining characteristic of a concrete type is that its representation is > part of its definition. In many important cases, such as a vector, that > representation is only one or more pointers to more data stored elsewhere, > but it is present in each object of a concrete class.... In particular, it > allows us to > > • place objects of concrete types on the stack, in statically allocated > memory, and in other objects (§ 6.4.2); > > • refer to objects directly (and not just through pointers or references); > > • initialize objects immediately and completely (e.g., using constructors; § > 2.3.2); and > > • copy objects (§ 3.3). > > Stroustrup, Bjarne (2013-07-10). The C++ Programming Language (4th Edition) > (Section 16.3 Concrete Classes; Kindle Locations 2373-2386). Pearson > Education. Kindle Edition.


Effective Strategies for Localization in .NET

I am developing the UI for a .NET MVC application that will require international localization of all content in the near future. I am very familiar with .NET in general but have never had a project that required such a significant focus on international accessibility. The projected is initially being done in English. What measures should I take at this point to make it easier to implement localization in the future?


Is the following diagrams correct for RAD and Agile methodologies?

I do not know if this would be the right stack exchange site to ask this question but I have been researching on RAD (Rapid Application Development) and Agile methodologies and was trying to find their diagrams but if I google images this, it comes up with many different diagrams. So based on the images I drew my own diagrams on this. The RAD diagram is similar to the one shown in wikipedia here but only difference is I change the bottom circle from cutover to implementation. For Agile method, as it is same as waterfall method but only difference is you can jump back to previous steps, I basically drew up a waterfall diagram but changed the arrows to indicate that you can go back. My question is the below diagrams suitable for the intended methodologies? RAD: ![enter image description here](http://i.stack.imgur.com/4MejT.png) Agile: ![enter image description here](http://i.stack.imgur.com/2Tlar.png) UPDATE: Waterfall Method: ![enter image description here](http://i.stack.imgur.com/xiA2v.png)


Is application-specific data required for good unit testing?

I am writing unit tests for a fairly simple function that depends on a fairly complicated set of data. Essentially, the object I am manipulating represents a graph and this function determines whether to chart a line, bar, or pie chart based on the data that came back from the server. This is a simplified version, using jQuery:               setDefaultChartType: function (graphObject) {       var prop1 = graphObject.properties.key;       var numCols = 0;       $.each(graphObject.columns, function (colIndex, column) {         numCols++;       });            if ( numCols > 6 || ( prop1 > 1 && graphObject.data.length == 1) ) {         graphObject.setChartType("line");       } else if ( numCols <=6 && prop1 == 1 ) {         graphObject.setChartType("bar");       } else if ( numCols <=6 && prop1 > 1 ) {         graphObject.setChartType("pie");       }     }      My question is, should I use mock data that is procured from the actual database? Or can I just fabricate data that fits the different cases? I'm afraid that fabricating data will not expose bugs arising from changes in the database, but on the other hand, it would require a lot more effort to keep the test data up-to-date that I'm not sure is necessary.


Things to take Control when Team not doing Well?

I'm working on an ERP Project where two Members(Freshers) in my team are not performing well (for small tasks). Their work is littered with bugs and other issues. As I'm a Team Lead in this Project, I end up having to write their code/tasks. This may be creating a heavy burden for me as I have to speed up things everyday to do my work and then theirs! > What would you do in this situation. Actually, I'm feeling comfortable in this position as I'm learning many things, but some times I cant tolerate this!


What do you call the test suite developers run before checkin?

I'm working on a project where we're adding automated testing to an existing project. We're starting with a central component, and setting up both unit tests at the code module level, and tests that run on the whole component, albeit in the developer environment. The intent is that this test suite must pass before code check-in, and will be run by a continuous integration system on each development branch. What should we call this? Right now we're calling it "dev unit tests", but the pedantic side of me says that's not quite right, because it contains more than unit tests. And our vision is that this suite will grow over time to include full-product acceptance tests. Any input here? Or should we stop arguing about names and go write tests? ### Update Everyone, thanks for good discussion! I think the conclusion I'm coming to is that there's not really a "common" definition - each project/team comes up with names that make the most sense for that project, depending on the technologies (Java, C#, ruby, etc) and methodologies (old-skool waterfall, Scrum, XP, etc) in use.


Do Programmers sometimes intentionally over complicate code?

It seems alot of times on stackoverflow, that people (programmers especially) tend to over complicate a solution to a problem to where the solution is vastly much more complicated then the original problem? Im not an expert by any means, but alot of times I try to go with the simplest solution that works (and obviously this doesn't work EVERYWHERE) but i've had pretty good success with suggesting simple solutions on the job that people seem to overlook for MUCH more complicated solutions? Is this like a normal thing for programmers.....or am I just not thinking in the correct perpective.


How to handle a workaholic Supervisor who is your good friend?

The biggest trouble anyone can ever face... which is the root case of the issue which I have mentioned in my previous question. This man was one of my best colleague I have worked with 2 years back where he was not having any responsibility of a team lead. After 2 year, I got a chance to work in a similar project under his supervision. I knew him during my old project days and he is a WORKAHOLIC but never even came in my wildest dream that he will be the same after becoming a supervisor and ruin my and my colleagues sleep. How do I handle his behaviors such as:   1. He believes that, we should preach our code every day and thats our bread and butter.   2. He treats all his sub-ordinate as inferior and his idea/solution is the final. A strong valid and fighting point(which mostly I come up with) can only change his mind.    3. I feel so pity for my co-developers when he treats them like slaves who writes code for living.    4. He never encourages any co-workers, he is doubtful on everyones work... for him 100% output is 100xN% effort put by the developer.   5. He never consider anyone individuality or freedom to express... de-motivates to the hell.   6. Weekends are his favorite working days... sends mails, review comments etc which give added pressure to the peer group.   7. He never mind how long we burn the night lamp... but we should be in office next day at 8:30 sharp.   8. He is the only person I have seen who works for atleast 8 hrs when he takes vacation and he expects others to work even if you are in vacation or at home.   9. Developer who are favorite for him are always right.. rest everyone are wrong.   10. If he can work for 10 hrs, he expect every to work along with him. If he is not sleeping at 12, then why should the developer sleep... they should stay awake with him. The only per who was able to handle him and with minimal experience like I mentioned above behavior from him is me, just because he is a good friend of mine. My peers and I find no use of giving feedback for his behavior because he always say that I am verystern and no one can change my decision. How can I help him to change his approach of work... or am I wrong here?


How to get a Web Application to communicate between users

I am developing a multipalyer web Application for Anti-Chess. It would be hosted on Google App Engine. I have a few questions: How do I get two different users who have opened the webapp on their browser to communicate moves with each other. P2P or through the server. If through the server, can I store some moves on it (specifically talking about GAE), to test bots later? How to implement this P2P/Server connection. As a developer I know jack about Networking. But I hav heard of things like Socket programming, HTTP request etc, what can/should I use. And where can I read up on that! If I don't go for GAE, would it cost me too much to get some server space and hosting capabilities? And people tell me that then deploying the application is tougher than on GAE. Is that so. Where can I read up on deploying the web Application on Servers. Where does the code for networking go? I will be using Django with python as the web framework, front-end would be HTML, CSS, and JavaScript. Should I make a separate module for the networking methods and then introduce a method calls wherever needed in the game play? Someone suggested me on using Unity software for developing. Is it good, Does it make it simple to do work? Will it cover all the parts of the development, the front end and the back end and the deployment? Note: I am a first timer in web Application, I have coded games before, but always without GUI. And also with no multiplayer over the network capabilities!


Can I convert ALL CAPS sections of an OSI license to regular case (and bold)?

**Update:** I've got a response from the FSF on this down in the answers From the answer to Can I remove all-caps and shorten the disclaimer on my License?, it appears that the APP CAPS sections of a software license are largely to provide extra legal ammo and increase the weight of those sections. On the flip side, ALL CAPS TEXT is more difficult to read in paragraph form. Furthermore, with formats like markdown, we can provide cleaner alternatives to all-caps "bolding" of text. So, I'd like to convert (for example) the warranty clause of the MIT license from:               THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR      IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,      FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE      AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER      LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,      OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE      SOFTWARE.      to (markdown):               **The software is provided "as is", without warranty of any kind, express or     implied, including but not limited to the warranties of marchantability,     fitness for a particular purpose and noninfringement. In no event shall the     authors or copyright holders be liable for any claim, damages or other      liability, whether in an action of contract, tort or otherwise, arising from,      out of or in connection with the software or the use or other dealings in the      software.**      Is this legally murky territory? (particularly w/ GPL?)


What is "syntactic delegation"

Steve Yegge mentions it in When Polymorphism Fails: > ... I think this implies that type is best represented via properties rather > than classes, because of the inherent inflexibility of classes. But in > "traditional" languages like C++ and Java, this makes code sharing a bit > harder, because of the lack of support for **syntactic delegation**. ... (emphasis added) A Google search turns up a State of the Onion address by Larry wall.


Proxied calls not working as expected

I have been modifying an application to have a cleaner client/server split to allow for load splitting and resource sharing etc. Everything is written to an interface so it was easy to add a remoting layer to the interface using a proxy. Everything worked fine. The next phase was to add a caching layer to the interface and again this worked fine and speed was improved but not as much as I would have expected. On inspection it became very clear what was going on. I feel sure that this behavior has been seen many times before and there is probably a design pattern to solve the problem but it eludes me and I'm not even sure how to describe it. It is easiest explained with an example. Let's imagine the interface is               interface IMyCode {         List<IThing> getLots( List<String> );         IThing getOne( String id );     }      The getLots() method calls getOne() and fills up the list before returning. The interface is implemented at the client which is proxied to a remoting client which then calls the remoting server which in turn calls the implementation at the server. At the client and the server layers there is also a cache. So we have :-               Client interface           |      Client cache           |      Remote client           |      Remote server           |       Server cache           |     Server interface      If we call getOne("A") at the client interface, the call is passed to the client cache which faults. This then calls the remote client which passes the call to the remote server. This then calls the server cache which also faults and so the call is eventually passed to the server interface which actually gets the IThing. In turn the server cache is filled and finally the client cache also. If getOne("A") is again called at the client interface the client cache has the data and it gets returned immediately. If a second client called getOne("B") it would fill the server cache with "B" as well as it's own client cache. Then, when the first client calls getOne("B") the client cache faults but the server cache has the data. This is all as one would expect and works well. Now lets call getLots( [ "C", "D" ] ). This works as you would expect by calling getOne() twice but there is a subtlety here. The call to getLots() cannot directly make use of the cache. Therefore the sequence is to call the client interface which in turn calls the remote client, then the remote server and eventually the server interface. This then calls getOne() to fill the list before returning. The problem is that the getOne() calls are being satisfied at the server when ideally they should be satisfied at the client. If you imagine that the client/server link is really slow then it becomes clear why the client call is more efficient than the server call once the client cache has the data. This example is contrived to illustrate the point. The more general problem is that you cannot just keep adding proxied layers to an interface and expect it to work as you would imagine. As soon as the call goes 'through' the proxy any subsequent calls are on the proxied side rather than 'self' side. Have I failed to learn or not learned something correctly? All this is implemented in Java and I haven't used EJBs. It seems that the example may be confusing. The problem is nothing to do with cache efficiencies. It is more to do with an illusion created by the use of proxies or AOP techniques in general. When you have an object whose class implements an interface there is an assumption that a call on that object might make further calls on that same object. For example,               public String getInternalString() {         return InetAddress.getLocalHost().toString();     }          public String getString() {         return getInternalString();     }      If you get an object and call getString() the result depends where the code is running. If you add a remoting proxy to the class then the result could be different for calls to getString() and getInternalString() on the same object. This is because the initial call gets 'deproxied' before the actual method is called. I find this not only confusing but I wonder how I can control this behavior especially as the use of the proxy may be by a third party. The concept is fine but the practice is certainly not what I expected. Have I missed the point somewhere?


I want an element to appear in case the website has not been used for a while and make it disappear after it is being used again. Is there any way to detect on a website if the mouse has not been moved for awhile?


How to handle interview questions on programming style

As a C++-programmer in interviews I repeatedly found myself in situations were the interviewer wanted to probe my knowledge of good programming style. These typically were centered around basic knowledge of OOP. I know OOP is useful to encapsulate concepts and I use it daily. However, since a language like C++ allows many different styles and some C++ approaches like TMP or STL algorithms are not OOP at all (but rather more like functional programming) I find myself stuck on how to best "sell" my knowledge of other approaches as well without coming across as arrogant or as somebody without appreciation of the basics. I fear this emphasis on OOP of the askers comes from them being socialized in the 90s where OOP was believed to be the cure- all, but that is an arrogant standpoint to take. How would I make the best of questions like this?


How do I communicate my role in a project to other team members?

Recently I worked on developing a new component with a coworker. I would say that our contributions were about a 80/20 split, myself having contributed 80% of the work toward the component. My coworker likes to spam the other developers in the department with information and updates about whatever he's been working on, including e-mails specifically discussing our new component. This behavior has resulted in my coworkers (including management) mistakenly believing that he is the primary and most authoritative contact for discussions about this component, despite the fact that he was the minority contributor. I feel that his constant updates have given him a higher profile than me with respect to this project. Can I recover from this, and if so, how do I do it? I don't think that out-spamming the spammer would be effective, nor do I like adding additional noise to my colleagues' inboxes. **EDIT:** Thanks for the answers so far, they are all really good. To help clarify the situation I'd like to follow up with some additional info about his communication. First of all, he typically does not tell me when he's about to send out an e-mail, much less run it by me for review before sending it out; I am unaware of these messages until they arrive in my inbox. Secondly, there has been more than one occasion where his communication contains information that is outright incorrect; he is not familiar with some of the code that he is discussing. I wouldn't mind him being the point of contact if it wasn't for the fact that he is essentially being given credit for the project because of it. Management is perceiving the situation as if he was the one who wrote the 80% and I wrote the 20%, when in reality it's the other way around.


A simple C library filling the gaps in standard (C, POSIX) libraries?

I'm looking for a C function library, which would contain a collection of _simple and plain_ utility functions "missing" from C or POSIX standards. I found this earlier question, but answers there list only full frameworks or libraries designed to replace/duplicate standard libraries instead of seamlessly fill the gaps. To give you an example of functions I'm often missing, and would like to find a lib with tested implementations:   * `afgets`, `afread`: read a line or entire file, like `fgets` and `fread`, except really reads all and returns a `malloc`ed buffer, in the spirit of GNU `asprintf`.   * A selection of string trimming functions   * `systemf`, `popenf`: Like `system` and `popen`, but take `printf`-like format string for command.   * `strjoin`: join multiple strings given as vararg/array (which is hard to do with `snprintf`)   * `struct timeval` arithmetic These are just examples of functions I often miss for quick stuff. Then some features I'd desire (not mandatory):   * Available on common Linux distros out-of-the-box, with man pages etc   * Works also on Windows/Visual C   * No extra dependencies, self-contained   * As usable as existing C lib functions in C++   * Preferably licensed under LGPL or BSD-like license, but GPL is ok too Stuff which I am _not_ looking for:   * A string library with its own string type   * A data structure library   * A framework library which has special initialization, maybe even event loop etc. So the question is, what is out there? Library name, homepage link, github link, duplicate question link... If you've made your own and have it at public repo, feel free to link to that too, if you dare expose it to many eyes.


Are the different available programming languages redundant?

Off course this do not apply to all languages. But I was wondering if some languages only exists due to the market culture of concurrence. For example, we all know that C is widely used for built in and light weight systems. And, as far as I know, no one bit them. But how about JAVA, C#, Ruby, PHP, ASP.NET, Python, Perl and son on? I know that PHP is much more light weight then ASP.NET and JAVA and some would say it is its differential, because you can deploy applications much faster. Others would say that, despite that, in the future, you'll realize that you'll need a more robust language. There are different cases, like in the twitter case, using SCALA. What would you say if, for example, tomorrow you wakeup in Garden of Eden, where everyone works together without competitors. Which programming languages would you merge or discontinue? My point is: Is there programming languages that exists only due to competition or all of them have very specific applications and cannot be thrown away or have their functionality merged? My question is somewhat equal to How big are the different programming "worlds"? but claiming another point.


Is there an equivalent to Build-Operate-Transfer for software development?

Is there an equivalent to Build-Operate-Transfer or Build-Lease-Transfer in software development? Does it even make any sense to operate such a project in software? Do you know of any projects in your experience that have been launched as such? Another way to put it is: for a large software system project, why wouldn't a company bid it out to third parties for them to build and operate for a period of time (i.e. the third party will be responsible for ongoing maintenance and operation of the system), until the concession is up? The third party recuperates expenses from software development through the running of the system; the original company might earn from residuals during this period, and then absorb income from the system once the concession is up. Does this even make any sense?


Summarize changes (insertions and deletions) in Git

I want to look at how my code base has grown over time. GitHub has a nice `+/-` display along the list of checkins which gives a sense of this. Is there something similar I can use with my Google Code hosted repo or offline?


Why does DataContractJsonSerializer not include generic like JavaScriptSerializer?

So the JavaScriptSerializer was deprecated in favor of the DataContractJsonSerializer.               var client = new WebClient();     var json = await client.DownloadStringTaskAsync(url); // http://example.com/api/people/1          // Deprecated, but clean looking and generally fits in nicely with      // other code in my app domain that makes use of generics     var serializer = new JavaScriptSerializer();     Person p = serializer.Deserialize<Person>(json);          // Now have to make use of ugly typeof to get the Type when I      // already know the Type at compile type. Why no Generic type T?     var serializer = new DataContractJsonSerializer(typeof(Person));     Person p = serializer.ReadObject(json) as Person;      The JavaScriptSerializer is nice and allows you to deserialize using a type of T generic in the function name. Understandably, it's been deprecated for good reason, with the DataContractJsonSerializer, you can decorate your Type to be deserialized with various things so it isn't so brittle like the JavaScriptSerializer, for example               [DataMember(name = "personName")]     public string Name { get; set; }      Is there a particular reason why they decided to only allow users to pass in the Type?               Type type = typeof(Person);          var serializer = new DataContractJsonSerializer(type);     Person p = serializer.ReadObject(json) as Person;      Why not this?               var serializer = new DataContractJsonSerializer();     Person p = serializer.ReadObject<Person>(json);       They can still use reflection with the DataContract decorated attributes based on the `T` that I've specified on the `.ReadObject<T>(json)`


Single responsibility vs procedural programming

Single responsibility (from SOLID) is like making me create classes with only one public method. But if it's so, it would be possible use static methods, and go back to procedural programming. What's the difference?


What percentage of bugs should be stamped out before a project can be accepted as a stable release?

We have been working with a shopping cart for DotNetNuke, and have had endless problems with the developer's releases of their product. Every release fixes one thing but new bugs pop up elsewhere. I know that bugs are inevitable and that we cannot squash all of them at the time, but can someone please tell me what percentage of bugs should be stamped out before a product can be accepted as a stable release?


How to Name Different Branches with Identical Functionality in Semantic Versioning

For a software, I have two different branches, that only differ in using different library versions of a package, that my software uses. The API of this library has changed between the versions in a non-compatible way. I am currently developping using both versions with the identical functionality in different branches, the only difference exists during building and loading of shared libraries. Should I release these packages with different version names using Semantic Versioning? In my opinion, yes, but what about the naming of these different versions? Currently I am using the "normal" numbering using the new version of the third-party library, e.g. 1.0.0, and a suffix for the version using the older third-party library, e.g. 1.0.0-json-c-0.10, see https://github.com/residuum/PuRestJson/releases


Web Farm access to pool of resources

I am learning how to structure an application using a web farm (for high availability rather than load). I have a pool of resources in which one user can access one element in the resource pool at any time. My constraints/requirements are:   * No database (Well, I do have access to this third party product's database. But we have zero control because of support issues etc, so assume no database)   * Pessimistic locking strategy   * Supports access from one or more sources   * No third party dependencies, I want to be in control of the development My current thought process is to have an archecture similar to the following: ![enter image description here](http://i.stack.imgur.com/jIrbg.png) In the above, I would have a central "lock server" which would deal with the locking from one or more sources. I would then have one or more slave's which would effectively take a copy of all the transactions in the case of a fail over scenario. The lock server would be a first come, first serve approach. My question, given my contraints/requirements, is this the best design for this problem? _If I can improve the question, please drop me a comment, thanks_


DRY with Dynamic SQL vs. prepared statements

When dealing with data, one finds that, essentially, the same code is repeated in various incarnations:               -- MySQL:     CREATE TABLE users (         id int NOT NULL auto_increment PRIMARY KEY,         name varchar(255) NOT NULL,         email varchar(255) NOT NULL,         UNIQUE KEY akUser (email)     )          // PHP     class User extends DBModel {         protected $id;         protected $name;         protected $email;              function __construct() {             $this->queries = array(                 'getById' => 'SELECT id, name, email FROM users WHERE id = :id',                 'addUser' => 'INSERT INTO users (name, email) VALUES (:name, :email)',                 'updateUser' => 'UPDATE users SET name = :name, email = :email WHERE id = :id',             );         }              public function loadById($id) {             $stmt = $this->getPreparedStatement('getById');             $stmt->bindValue(':id', $id);             $stmt->execute();             $stmt->setFetchMode(PDO::FETCH_INTO, $this);             return $stmt->fetch();         }         public function save() {             if ($this->id === NULL) {                 $this->add();             }             else {                 $this->update();             }         }         public function add() {             $stmt = $this->getPreparedStatement('addUser');             $stmt->bindValue(':name', $this->name);             $stmt->bindValue(':email', $this->email);             $stmt->execute();         }         public function update() {             $stmt = $this->getPreparedStatement('updateUser');             $stmt->bindValue(':name', $this->name);             $stmt->bindValue(':email', $this->email);             $stmt->bindValue(':id', $this-id);             $stmt->execute();         }     }      If you notice, the fields 'name' and 'email' each occur 7 times throughout PHP and MySQL. While this is not much of a problem with this small example, with large tables, and a large number of tables, this gets out of hand fairly quickly. _As a quick side-note: with PHP running as a web service, the application lifetime is very short. Many of the queries that get executed -- adding a user, for instance -- would get executed only once in the application lifetime, so prepared statements really don't offer much of an advantage. Even with connection sharing, the individual instances don't have access to the previously prepared statement (unless I'm missing something), so it would re- prepare the statement anyway._ With some basic database-level reflection (the results of which are either cached, or automatically generated before deployment), SQL statements can be created automatically, eliminating the need to code the basic SELECT/INSERT/UPDATE/DELETE statements individually - cutting down on code considerably.               -- (table create statement, of course, stays the same)          class User {         protected $id;         protected $name;         protected $email;              public function getById($id) {             return MyDb::getById('Users', $id, $this);         }         public function save() {             return MyDb::save('Users', $this);         }     }      **My question** : is the duplication of code worth the few CPU cycles and more complex code & maintenance needs?


How do you tackle really bizarre errors that keep you puzzled for more than 10 hours?

You know them, those errors that make NO sense. Where it seems like a gremlin just jumped deep inside your chips and messed up something. Do you take a walk, write stuff, call an uncle? I need help!!


Do compiler-writers actually need to 'understand' machine code?

Might be kind of an odd question. A guy writing a C++ compiler (or whatever non-VM language): Does he need to be able to read/write raw machine language? How does that work? EDIT: I am specifically referring to compilers that compile to machine code, not to some other programming language.


Watermarking an image with the text given as input

I want to create a simple web app where I can drag an image in, and watermark the corner with the given text. Where should I start for something like this? I have knowledge in Java and Ruby.


Scalable distributed file system for blobs like images and other documents

Cassandra & HBase both do not efficiently support storage of blobs like images. Storing directly on HDFS stresses the Namenode because of huge number of files. Facebook uses Haystack for images and attachments storage, but this is not open source. So is Lustre a good choice for distributed blob storage? I have read that Amazon S3 is used by many, but this would cost money and personally, I would not like to rely on third party system. What are other suggestions?


Reinventing the wheel because it doesn't exist

One of the languages I have to use at work is a very small, niche language called psl. One of the largest complaints I have about it as a language is that the libraries are very limited. While that's understandable for a small language developed by a couple of guys, it does cause me some dilemmas. Specifically, I find myself "rewriting" functions that are standard in other languages because they don't exist here. This is especially problematic when I'm attempting to write a function to solve a problem, and management doesn't want to spend the time to do so. They want me to use hard coded magic numbers instead, which I know will need to change multiple times over the life of the code. This doesn't quite fit the antipattern reinventing the wheel because it didn't exist here in the first place. What kind of anti pattern would this fit?


What is the origin and meaning of the phrase “Lambda the ultimate?”

I've been messing around with functional programming languages for a few years, and I keep encountering this phrase. For example, it is a chapter of "The Little Schemer, which certainly predates the blog by this name. (No, the chapter doesn't help answer my question.) I understand what lambda means, the idea of an anonymous function is both simple and powerful, but I fail to understand what "the ultimate" means in this context. Places that I've seen this phrase:   1. The title of chapter 8 of The Little Schemer   2. A blog: http://lambda-the-ultimate.org/   3. A series of "Lambda the ultimate X" papers: http://library.readscheme.org/page1.html I feel like I'm missing a reference here, can anyone help?


Alternatives for Agile Scrum

We started following the Agile Scrum methodology and we have completed about 10 sprints. One observation I had is that not all in the team are taking up the responsibilities of completing the tasks and user stories by themselves and everytime they have to be instructed or allotted with some tasks. Also the estimate they are giving are not very agile. There is always a need for someone to look after all the user stories, their completion status, tasks that are yet to be done etc and allot them to team members who are not occupied. I also feel that we would be able to deliver faster if we had one person who would create tasks and assign them to people along with deadlines to complete them (project manager role). And this is what I feel is missing in Agile Scrum. Given that the team is not taking up tasks and not risking to take up tight estimates, what are the alternates that we can look for? Or, are there any provisions in Agile Scrum to fasten things?


What is a recommended way to go about learning a .NET class on some regular interval?

Like anything in life, what you don't know doesn't help you and as a new developer, I know that the more I learn about the different .NET classes out there and their uses, the more I have in my toolbox. However, sort of like an ocean where you just not sure where to start, I thought I would asked the community, does anyone know:   * any recommendations on breaking down a .NET library per class (or smaller), where to start?   * A site that might do just that per article/blog Or any other recommendations on making it a regular (i.e. daily/weekly) practice to learn a new class in .NET? Which Library to start with...etc? **NOTE** : I read allot or regularly, but I thought an effort geared directly at learning about a new class and its uses on a regularly bases would help. Thanks,


Help me catch up on what I've missed since Java 1.4.2

I am about to start my first professional career position as a software developer, and I'm likely going to be writing a lot of Java code. I don't know that much about what specifically I'll be writing, and besides, I have fairly broad interests when it comes to code anyway. For reasons not worth discussing, my last internship had me coding only for the Java 1.3 and 1.4 SDK's. Also, my university education has focused mainly on algorithms, data structures, and other theory, not language features or libraries. So, with the above in mind, what features, classes, etc. in the current version of Java (what number are we on now, anyway?) would be worth my time to read up on and why? What have I missed since 1.4.2 that makes your life as a programmer easier? Examples and stories of how you discovered a particular package or some such and put it to use would also be great.


Why freeware (closed-source) instead of open-source?

I'm wondering why some people release software as freeware, yet they don't release the source code. Why is that? I can think of some reasons, yet most of them don't make very much sense. Why would you want to keep the source closed but let the program be freely available (free of charge, not free as in freedom)?


Advice for simple communication protocol (iPod and Arduino)

I connected iPod with Arduino using serial (UART) connection. Arduino sends 0-1023 number (so it's two bytes) as it's samples light sensor value. I'm asking about advice about simple and reliable communication protocol.   1. Do I need magic constants to start/stop communication.   2. Maybe I need sent data of small chunks. Now I have:               while (1)     {        data = getData() ;         // two bytes of 0-1024        Serial.write((data) & 0xFF)) ;         Serial.write((data) & 0x300)) ;      }      Any suggestion how to implement simple and reliable protocol ? Image of my device: http://cl.ly/image/051f370v3e0g Thanks


When should I stop committing to master on new projects?

Whenever a new project starts, it usually makes sense to start by committing straight to master until you've got something "stable", and then you start working in branches. At least, this is how I normally do it. Is there a way to immediately start branches from second commit? Does it make sense to do it this way? Obviously, "Initial Commit" will always be on master, but after that, when will I know it's the right time to start making branches for new features?


Is PHP a bad object oriented language?

I had a chance to have an interesting conversation with my co-workers. Most of them are flash action script or Java developers. We talked about how well php handles OOP. I said that PHP can handle almost every OOP stuff as of PHP 5.2 or 5.3. Am I wrong? I'm not trying to get yes/no answer, but I would like to hear more opinions from developers.


database replication or custom solution like creating enterprise "bus"

I'd like some input on how to keep databases that are running on different servers throughout our organization synchronized. We have a registration system of sorts, and when user "John Doe" registers on server 1, this registration information needs to be instantly available on server 2 and 3. Currently, our network administrators have set up postgresql replication to do this, and it seems to be working fine. When this solution is up and running full scale, we will have 2 databases being replicated to potentially 4 or 5 different servers. Two database because the registration information is saved into two different databases. One database is a CRM, the other is a reservation application. (BTW. This is all on a LAN, vs WAN) What I'm trying to figure out in my head is whether postgresql replication is the best way to do this or if we should be looking at a software solution. I saw one post here where someone was asking about ETL vs. REST API. REST may be a good option I guess. I'm not sure that it completely suits our needs ... I'll have to think about it some more.. But I'm also thinking about Enterprise integration software ... like iway or something like that where you would identify the source database, identify the taraget database... and then define the interval. The tool would then monitor the source database for changes every X minutes. Anytime there is a change, it would update the target databases. But I'm not sure I'm asking myself all the right questions to do a proper evaluation. Here are some I thought of so far:   1. How fresh does the data need to be on the servers? Has to be 'fairly' real-time... I would say within seconds.   2. What's the volume of information? several records could be created in the source database every few seconds.  What else should I be considering? Thanks.


What is the difference between a combinator and function chaining?

So from what I've read about combinators I can't quite tell how they're different from simply chaining function calls. I know I must be missing something but I'm not figuring out what I'm missing. I mean would g(f(x)) (where _f_ and _g_ are functions) effectively be a combinator if I gave it a different name?


Empirical study on activity distribution of a programmer?

I am searching for some charts, tables and other empirical evidence on how a typical programmer's activities are distributed (per day, per project, etc). Example activities are programming, phone calls, reading documentation, writing documentation, fixing bugs, requirements engineering, tests, meetings, etc. In particular I am interested in the amount of time a programmer actually works on _executable_ stuff.


Sponsors and Advertisement in winform apps

In a new winform app that I am still preparing, I got the idea that I could by sponsored or have some kind of logos of companies that want to place they logos there. The application is for sports training and completion management, carrier management, etc. As any one seen something like this? How can it be done? How can I interest the companies to sponsor the app? UPDATE ----------------------------------------- I have canceled this one. I asked a coupled of client of mine that deal daily with sponsors, and they make you do stupid thing in your project. Dow it would be nice to have some extra cask to lower the price of the App, and be able to get more market. I will pass this one out. The only intromissions I like in my projects come from the people o actually use it every day.


things to think of when moving into C-land

**Hello**   Over the years have I made a programming journey from C in 1990 to Pascal, C++ with I programmed commercially, java VHDL, C# and now I'm taking a look on F#. In the spring I will go back to study embedded programming in C in a university course so before I do that I will refresh my knowledge in C.   I don't remember much of the C that I learnt and I think I am thankful for that for probably learned some bad habits back then. I have some questions to get me on the way.   **\--edit--**   To clarify: I am thankful for tips that have been given regarding embedded programming but now I am more interested in relearning C in general. Sorry if my question was unclear,   1. Compiler, Debugger, IDE? As a microslave I was thinking about 2010 C++ Express, any alternatives?   2. Where do you find good libraries with code for C. I'm thinking something similar to Boost, POCO in C++   3. Source for procedural programming patterns and best practices. Where can you find good code learn from? Thanks in advance   Gorgen


Reflection and the LGPL

Simply, If I use reflection to add methods or functionality to a class defined in a LGPL'd library I'm linking to, does that count as a modification to the existing library and would my reflective code have to be released under the LGPL?


How to make sprint planning fun

Not only are our sprint planning meetings not fun, they're downright dreadful. The meetings are tedious, and boring, and take forever (a day, but it feels like a lot longer).   The developers complain about it, and dread upcoming plannings. Our routine is pretty standard (user story inserted into sprint backlog by priority >> story is taken apart to tasks >> tasks are estimated in hours >> repeat), and I can't figure out what we're doing wrong. How can we make the meetings more enjoyable? ... Some more details, in response to requests for more information: **Why are the backlog items not inserted and prioritized before sprint kickoff?** User stories are indeed prioritized; we have no idea how long they'll take until we break them down into tasks! From the (excellent) answers here, I see that maybe we shouldn't estimate tasks at all, only the user stories. The reason we estimate tasks (and not stories) is because we've been getting story-estimates terribly wrong -- but I guess that's the subject for an altogether different question. **Why are developers complaining?**   1. Meetings are long.   2. Meetings are monotonous. Story after story, task after task, struggling (yes, struggling) to estimate how long it will take and what it involves.   3. Estimating tasks makes user-story-estimation seem pointless.   4. The longer the meeting, the less focus in the room. The less focused colleagues are, the longer the meeting takes. A recursive hate-spiral develops. We've considered splitting the meeting into two days in order to keep people focused, but the developers wouldn't hear of it. One day of planning is bad enough; now we'll have _two_?! Part of our problem is that we go into very small detail (in order to get more accurate estimations). But when we estimate roughly, we go way off the mark! **To sum up the question:**   * What are we doing wrong?   * What additional ways are there to make the meeting generally more enjoyable?


How does using #define for loop and condition bounds in C increase security?

My program uses the following define statements:               #define LOWEST_PATIENT_ID 10000     #define HIGHEST_PATIENT_ID 99999     #define LOWEST_CRITICAL_STATUS 1     #define HIGHEST_CRITICAL_STATUS 100      used in this type of code:               do{        scanf("%d", &c_status);        }while((c_status<LOWEST_CRITICAL_STATUS)                ||(c_status>HIGHEST_CRITICAL_STATUS));      I'm unclear about how this is more secure. or is it the typedef statement that is secure?


What sort of questions drive the decision as to whether similar code is separate or common?

I have come across the following problem many times in various guises in my programming career. As a simple example, consider the following: Let's say there is a method (B) that could differ depending on customer requirements. This could be for any number of reasons. Common sense tells you that as things are now, you should write them as a common method and add branching code in the future to handle any future edge cases.               Customer 1: A-->B-->C          Customer 2: A-->B-->C      However, your experience tells you that this particular bit of code is likely to change so it would be easier to have separate methods (B1 & B2) and change the logic for one customer rather than continually add branching code making method (B) non-generic.               Customer 1: A-->B1-->C          Customer 2: A-->B2-->C      Are there any rules of thumb that can be applied in such cases or does every case have to be taken on its merits? As an aside, I've come across plenty of people who staunchly advocate one approach over the other and I can see the merits of both. But surely there is some middle ground that can be reached based on reasoned arguments?


How to do transaction management using Spring without Annotation?

I'm using Hibernate4.2 and Spring3.2 and I m doing transaction management using Spring without annotation (i.e. without `@Transactional`). How can I use Spring-transaction management without annotation and without any DaoSupport?


Managing multiple versions of a web application using Git

We have a family of apps, all having the same base. Until now I've been developing this base, and the Git workflow was very simple:   * Development is done in `develop` branch   * New features are developed in `name-of-the-feature` branch   * Releases are made in `release-**` branch Until now, the code was the same for every app of the family. Let's say the base they share is now complete, and from now on the code will be different for every app. I'm not sure how should I deal with **git** and this **multiple apps** that have the same base.   * Should each one of them have its **own git project**?   * Should they be on the same project, but each one in its **own branch**? The point is: if I put them on separate projects, every modification done in the **base** of the app will have to me repeated in each of the apps. I'm not very familiar with **git** , but if I store each project in a **branch** , will be possible to merge the base modification with each app? Does anyone have experienced a situation like this? I'm not sure how to proceed. Thanks! **EDITED** When I said **version** I didn't mean like version numbers. They are actually different apps that share the same base.


Is developing games the best way to learn programming?

I heard recently an instructor mentinon that developing games was the best way to learn programming. Besides the fact that everything had to be created in code, he said you really get to fully experience and implement OOP into your programs. In other words everything you make in a game is a literal object both technically and in concept. Is it safe to make this assumption? Or are there always exceptions when learning programming? **note** it was geared towards .net / xna / c# development.


What is the difference between the Controller in MVC and ViewModel in MVVM?

I can't see the difference between MVC and MVVM clearly. I feel the Command in a ViewModel is just like the Action method in a Controller. And both the Controller and ViewModel will notify the View to refresh itself after modifying the state of the Model through Data Binding. What is the main difference between the two patterns?


Why it is not recommended to post several defects in the same issue / ticket?

I am not sure if this is the place to ask the following conceptual question (Stackoverflow is definitely not). I saw this question in a multiple choice exam (single answer), similar to the ISTQB exams: > _Why it is not recommended to report several defects in the same issue / > ticket ?_ > > a. In order to keep the report concise and clear. > > b. Because the developers might fix only one bug. > > c. Because the testing group testers are rated by the amount of bugs they > find. > > d. Bugs management systems does not support this feature of multiple bugs. My sole opinion is that `a` is the correct answer. `b` \- can't be it as the _fix-feedback-resolved-closed_ should avoid that case. `c` \- Obviously wrong. `d` \- Redmine / Trac plugins supports multiple fields. The answer according to the answer sheet is `b`. Can someone explain why ? Comments with opinion about answers are welcome.


Design pattern for locking asynchronous operations in Objective-C

I'm writing my first Objective-C Class. It's responsible for interaction with an HTTP SSO authentication service. The process requires multiple HTTP transactions in order to complete. The Class acts as a `NSURLConnectionDelegate` for its own `NSURLConnection` object. The `NSURLConnectionDelegate` object operates asynchronously. I need to disallow an authentication attempt when another is in progress. I have an idea of how to do that myself, but want to know of design patterns for this situation. My existing idea is to check an instance variable to see if an authentication is underway and if so simply not start another. However, I'm unsure how to communicate this back to the calling Class. My method presently returns void. Should I use an NSError and return that if another authentication attempt is underway?


Design Question: Keep 1000 newest items; DB vs. application

I have a Qt application, which sends and receives messages. Messages are stored in a local MongoDB. The application has a message list window, which shows sent, received and all messages (depending on the view). For performance reasons the application has a QList, which holds QPairs of Mongo ID and the message itself, so more or less all messages are available in the application. We want to limit the no. of shown messages, because the view gets slower for 1000 and more messages. The simple approach was just to limit the no. of pairs stored in the QList. However, I'm not quite sure, if this is true. Recently I've read here ( **EDIT:** found it) a question which basically said "Your application code won't be smarter/faster/better for stuff a DB is designed for (e.g. sorting, getting a subset, etc.)". In addition keeping the QList in sync with the DB is causing us headaches and we have some corner cases like an very old message can be updated and then has to be displayed again. So the question is, would a DB-only approach (e.g. querying the DB for 1000 messages whenever the view has to be updated) be faster then storing the acutally shown messages in the QList and trying to keep them in sync.


Why no developer API in C++ for Google or Yahoo mail?

I was trying to do some C++ coding that can send files from my laptop to my webmail account. It took me about 10 minutes to realize that there is no easy way to do this. Look into these links:   1. GMAIL: http://code.google.com/apis/gmail/oauth/code.html   2. YAHOO: http://developer.yahoo.com/mail/ I am trying to understand why PHP or Python or Java support exist but no C++. No flame wars, I love all programming languages and their creators equally but I am curious to understand the logic behind such implementation choices.


Why exactly can't PHP have full unicode support?

Everybody knows, that PHP has problems with Unicode. Version 6 is effectively abandoned, because of Unicode implementation difficulties. But I wonder if anyone knows what are the **exact** reasons? Architecture/design problems, performance concerns, community problems (I bet not), something other?


Should I use scaffolding or not in Ruby on Rails?

I'm learning Ruby on Rails for a new project of mine. I am referring the book 'Agile Web Development with Rails' which shows how to build a shopping cart and they use scaffolding. I'm pretty familiar with MVC architecture and have used several frameworks in PHP to build applications. I've never used scaffolding and I'm not sure if that's the best way to start building an application. Experienced users, please suggest if I should be using scaffolding or should I code manually.


MPL 1.1 and APL 2.0 License compatibility

I am working a project that is licensed under the MPL 1.1 and would like to incorporate some code that is licensed under the APL 2.0. I know in 2010 Mozilla announced they were updating the MPL to make it more "Apache compatible" among other things. I'm no lawyer. Exactly what part(s) of the MPL 1.1 don't jive with the APL 2.0 and vice versa? The project has very few of its original contributers still actively involved so I doubt I'd be able to contact all of them to get permission to change the license.