Organizing Git repositories with common nested sub-modules

I'm a big fan of Git sub-modules. I like to be able to track a dependency along with its version, so that you can roll-back to a previous version of your project and have the corresponding version of the dependency to build safely and cleanly. Moreover, it's easier to release our libraries as open source projects as the history for libraries is separate from that of the applications that depend on them (and which are not going to be open sourced). I'm setting up workflow for multiple projects at work, and I was wondering how it would be if we took this approach a bit of an extreme instead of having a single monolithic project. I quickly realized there is a potential can of worms in _really_ using sub-modules. Supposing a pair of applications: `studio` and `player`, and dependent libraries `core`, `graph` and `network`, where dependencies are as follows:   * `core` is standalone   * `graph` depends on `core` (sub-module at `./libs/core`)    * `network` depdends on `core` (sub-module at `./libs/core`)    * `studio` depends on `graph` and `network` (sub-modules at `./libs/graph` and `./libs/network`)    * `player` depends on `graph` and `network` (sub-modules at `./libs/graph` and `./libs/network`)  Suppose that we're using CMake and that each of these projects has unit tests and all the works. Each project (including `studio` and `player`) must be able to be compiled standalone to perform code metrics, unit testing, etc. The thing is, a recursive `git submodule fetch`, then you get the following directory structure:               studio/     studio/libs/                    (sub-module depth: 1)     studio/libs/graph/     studio/libs/graph/libs/         (sub-module depth: 2)     studio/libs/graph/libs/core/     studio/libs/network/     studio/libs/network/libs/       (sub-module depth: 2)     studio/libs/network/libs/core/      Notice that `core` is cloned twice in the `studio` project. Aside from this wasting disk space, I have a build system problem because I'm building `core` twice and I potentially get two different versions of `core`. ### Question How do I organize sub-modules so that I get the versioned dependency and standalone build without getting multiple copies of common nested sub-modules? ### Possible solution If the the library dependency is somewhat of a suggestion (i.e. in a "known to work with version X" or "only version X is officially supported" fashion) and potential dependent applications or libraries are responsible for building with whatever version they like, then I could imagine the following scenario:   * Have the build system for `graph` and `network` tell them where to find `core` (e.g. via a compiler include path). Define two build targets, "standalone" and "dependency", where "standalone" is based on "dependency" and adds the include path to point to the local `core` sub-module.   * Introduce an extra dependency: `studio` on `core`. Then, `studio` builds `core`, sets the include path to its own copy of the `core` sub-module, then builds `graph` and `network` in "dependency" mode. The resulting folder structure looks like:               studio/     studio/libs/                    (sub-module depth: 1)     studio/libs/core/     studio/libs/graph/     studio/libs/graph/libs/         (empty folder, sub-modules not fetched)     studio/libs/network/     studio/libs/network/libs/       (empty folder, sub-modules not fetched)      However, this requires some build system magic (I'm pretty confident this can be done with CMake) and a bit of manual work on the part of version updates (updating `graph` might also require updating `core` and `network` to get a compatible version of `core` in all projects). Any thoughts on this?


Developing cross-DB applications

So far I've always coded using raw/embedded, dialectic SQL. This seems obviously wrong to me because it ties you to concrete technologies so your software can't be deployed to any machine - especially servers. In general (independently of the programming language and RDBMS), what options does one have in this case? How good are each one of them? What would you say is the standard approach?


Designing authentication for REST API

I'm working up an API for a REST service that I'm going to both be producing and consuming. I've spent the past few days trying to figure out how to handle authentication nicely, and think I've finally come up with something. I'm coming up with this based on the following facts about the application stack:   1. Client & Server are in .NET4 (Client part in Client Profile)   2. Server exposes using WCF REST   3. I really don't want to keep the user name and password in memory in the app From 3, I wanted to use a form of token authentication, so that after the credentials are verified by the server, the client gets a token back to use throughout the rest of the app (this will allow me to do other things, such as timing out users, being able to move users seamlessly between the web and desktop versions, etc). After figuring out how to make the calls replay and tamper resistant, I've come up with the following:   1. Before the client attempts to authenticate, it generates a Diffie-Hellman key pair using the `ECDiffieHellmanCng` class.   2. It sends the public part of the key pair over the wire along with the user name and password (Over HTTPS of course).   3. Server authenticates the username/password combination, if successful, it then does the following:      1. Creates a unique session token     2. Generates its own DH key pair, and calculate the shared secret from the public key provided by the client     3. Makes note of the session token, the shared secret, the user, and the "last action" time (used for a rolling expiration window) in its database     4. Returns the session token, its public DH key, and an authentication success message   4. Client takes the DH key from the response, calculates the shared secret, and store both token and secret in memory. From this point on, the session token/secret combination works like most other REST APIs, with the request being fingerprinted and timestamped, and then have some sort of HMAC generated. Whenever a client performs an action against the server, it checks the token/secret pair, and allows the action if it is valid and not expired, and updates the last action record in the session. I don't see any obvious flaws, and is probably over-engineered for this, but I need to learn how to do this at some point. The HMAC prevents replay attacks, the DH negotiation helps prevent MITM attacks (I can't think of a workable attack off the top of my head between HMAC/DH). Any holes anyone can poke in this?


Good practice for unit testing with large or complex fixtures?

I am trying to use JUnit to test a class (`FooWriter`) that is responsible for writing my application's data to disk using a custom file format. The data set being written is potentially very large, and I want to at least be able to test simple things, such as whether or not the expected number of lines were written out. My problem is that I'm not sure what the best way is to set the test up with realistic test data. It seems like my options are:   1. Read the test data in from disk and then use that data for the `FooWriter` test case   2. Write a hard-coded text fixture for the `FooWriter` test case to use (1) seems like a bad idea because then the `FooWriter` test case would no longer be isolated from other complex, breakable operations. (2) seems like a bad idea because it would result in about a thousand lines of code to compose the data structure, along the lines of:               foo.addBar(new Bar("bof", "bam"));     foo.addBar(new Bar("baz", "boom"));      Not only is that tedious and error prone, if I were to later make a change in the way the data is constructed, the test could then fail whether or not the application itself is actually broken. In cases like this where I see no good options, I've found it's usually because I'm being stupid. Where's the stupid?


Is it normal for a school to focus on specific programming languages and frameworks?

Next year I'm going to school to study IT. I went to some schools' open door days already and I was given much information. However, at one school I was told they primarily focus on the .NET Framework and Java. I'm concerned about this because I think the programming language and frameworks used isn't as important as the design of a software program. I'm also concerned about the fact that you can get used to the flaws in those languages and frameworks and you may lack knowledge of other paradigms (such as functional programming). Am I getting this right? Is it normal for a school to focus on a specific language or framework?


How to handle product rebranding in code in a short time frame

We've all been there - a product feature is called "gold", and then a week before launch they decide it is to be called "platinum". Luckily, you had some nous about you so the UI code is easy to change. But...what about all the variables and methods? Sure, you could change all these but what about the testing time? Obviously Resharper or some other enterprise level refactoring tool may help but how do you sell a zero-value proposition to the business? After all, that text change on the front screen is just a 2 minute job - right?


What is likely to be the bottleneck between the SQL Server, IIS and .net when receiving json as text from the DB?

I have spent the best part of a month working on the jQuery Calendar plugin. The setup is such that all the calendar entries are stored in a table inside SQL Server and im using a single "Select As" statement to construct the json data within the SQL query itself. This has an execution time of less than one second. However, calling the actual final aspx page in the browser requires a wait of over 240 seconds while the data is passed as json to the browser. I've tried various methods to get around this. For example, i tried writing the query results to a json file first, and then calling the file in on the final page. This reduces the page load time to around 90 seconds but still not fast enough. I've also implemented a function whereby if the data hasnt changed the same json file is returned and is not re-generated. When there is no data that has changed on the calendar this reduced the page load time to around 1 second. Im convinced that writing the json data into the file is the bottleneck here.. But the real question is, is this as efficient as things are realistically going to get with IIS and .net? Or is there room for improvement? I also dont know which aspect to investigate further now. I dont know whether to consider if IIS is causing the hold up, or the way i have put the project together. Is there a more efficient solution that the one i have put together above?


How can I progress from a software developer to a software manager or team leader?

I've been a software developer (whether part time or full time) for almost 3 years. I've always been the type of person to have that knack for taking a lead on things, and providing the organization around getting things done. Ever since I was the lead on my senior design project back in college, I felt that this was my true calling, not sitting behind a desk coding. Now, I know I need to understand how to code for other developers to truly respect me. Also, I really do love coding. I work on plenty of side projects at home outside of work, keep up with best coding practices, and try and continuously further my knowledge of the domain. My main question is, what type of things or opportunities should I be looking out for that will help me progress my career to a more managerial role, rather than a coding role. Like I said, I LOVE to code, however I'd love even more to be able to design things at a high level, and organize the team in such a way to get things done, and monitor their progress, while helping out with technical decisions here and there. These types of things truly make me happy, as opposed to just sitting behind a desk coding all day long. Obviously one of my main dreams is producing some sort of software on my own that would eventually blow up and make it big, and then beginning to hire a team and do it all myself, but I feel like the chances of that happening are far worse than just altering my career path a little to get where I want to go. I feel like I can garner that same satisfaction doing it for an employer rather than myself. Even though I haven't felt that way before, I feel like it has been mainly because I'm not doing what I TRULY want to do. Any tips, pointers, or things to keep in mind? Anyone that has done just this, and if so, how did you do it?


Game development design patterns and architectures?

Some friends and me wish to develop a 2D game just for the experience of learning this paradigm. We are all software engineers with experience in business apps, but we are unsure if the typical design patterns and architectures (MVC, 3-layer, etc) apply as well, and we are totally unknown about the techniques that are typically used in Game development (Scenegraphs, key bindings implementation, event management, sound/texture banks...) We plan on developing with C# and XNA/Monogame, and I would be grateful if someone could point out any useful bibliography that could be helpful for us to plan an architecture and deal with any day-by-day game development issues. Thank you


Multi regex matching -- what to do to optimize it?

I have multiple regexes matching an input in greedy-first mode. All regexes are already compiled and I don't see what I can do more to speed-up things. I mean using tools coming with .Net framework. Since I don't do any replace, or capturing, I wonder if it makes sense to built my own regex matching -- in result I would execute matching only once (per multi-regex) instead of multi matching (per each single regex). Am I thinking too far? Is there other way to speed it up?


HMVC and Database Connections

Whilst I have good experience with OOP, I'm fairly new to the concept of (H)MVC. I understand the basic concept of modular design that comes with HMVC, it's the great attraction of it. But one thing that has been bugging me, and will hopefully help me understand HMVC better is how do you handle the database connection? I would assume that you would have a module, lets call it Database, that would initiate the connection. Now at the start of my script I would have something along the lines of:               $dbConn = new Database();      That would initiate the connection to the database. However, when I want to run a query I need to run something along the lines of:               $query = "my query string";     $result = $dbConn->query($query);      So I need to access the query function of the database object. Now as far as I can tell in HMVC I shouldn't directly access `$dbConn` from within a model of another module. But almost every module will need to access `$dbConn`. From my understanding this means that in the controller of all other modules, any time I need to run a query I would have to create a new instance of the Database module, passing in an array of arguments, telling Database which method to run and what arguments that method needs. But then what if I need to make a call to the database half way through a method in a module's model? Quite often I will need to update a table, or select some data based on an if statement. Surely I shouldn't be moving that logic to the controller? So that means I need to be able to access another module from within a model, which seems to break the rules of HMVC. **So how do I implement a database module as this is confusing me?**


Inject dependency as method parameter instead of constructor parameter

I'm using an ORM which doesn't allow me to inject dependencies in the constructor. Let's say I'm using DDD for the business logic, and the MVC pattern for the UI. Now one of my domain objects needs to access an external service. I'm very opposed to the service locator anti-pattern (wouldn't touch it with a ten foot pole), but as I see it, that leaves me with the following:               class Controller     {         private readonly IExternalService _externalService;              public Controller(IExternalService externalService)         {             _externalService = externalService;         }              public ViewResult Action(Guid Id)         {             // Omitted repository access for brevity.             domainObject.DoSomethingWichNeedsAnExternalService(_externalService);         }     }      Somehow I get the feeling this isn't very clean, what if the "domainObject" is buried deep into the model/graph, should the "_externalService" be passed all the way down? Are there any best-practice alternatives?


Standards to constraint HTML renderer in only US-EN

Does W3C or any other organisation has standard or protocol to constraint all developers to make sure they must use american english while they develop any sort of interpreter? To avoid something like, > I was writing code and tried to align image in centre(spelled in british > english) > > align='centre' > > above didn't work!! > > There is no spelling mistake, above spelled word meaning is "middle" > > when I wrote > > align='center' it worked, > > Does this mean HTML is written in "American English"? What if a developer from British background writes a renderer for web browsers such as gecko? **EDIT** Sorry I am not ranting but, I was wondering if W3C has any standards written somewhere which states that any future code or html tag written for HTML language must be in US-EN. Does anyone have idea whether W3C have some constraint on this?


What should I learn more about debugging?

To debug my programs I mainly use the following methods:   1. Use printf (or equivalent in other languages) to check the value of a variable after a particular statement or to check whether the program enters a conditional statement or a loop.   2. Use watch/breakpoints when using IDEs. I am able to solve the problems using the above methods. But I have noticed that there are two kinds of builds - debug and release. From the name I can understand that debug build would be helpful in debugging. Also I have read that debug build stores something called symbol table information and stuff. How can I use the debug build for debugging? Are there any other debugging techniques which I should learn?


Which popular object-oriented languages support readonly methods?

I thought that many object-oriented languages have a reserved keyword for methods which do not modify the state of an object. These methods often have names that start with `get`. AFAIK a "getter" is always related to a single object attribute and "accessor" is too general, so "readonly" may the right term for this kind of methods (?). To give an example:               object Timespan {         attribute start         attribute end              // getter, not changing the state         readonly method getStart    { return start }          readonly method getEnd      { return end }              // also not changing the state         readonly method getDuration { return ( end - start ) }     }      The compiler/interpreter should check that readonly methods have no side- effect by modifying object attributes. I wonder why this language feature is not more common - just naming a method `getFoo` does not ensure that it won't modify the object.


What does it mean to be agile?

We have a project that everyone says we will be doing in a agile way but I doubt we have clearly understood what agile is. In previous projects we had planning meetings, then defined the product back log and allocated the work to developers in 2 to 3 week sprints. Every morning we had scrum meetings (which seemed to go on for 1/2 an hour each time) and each developer got on with it after that. Hardly anyone wrote any tests until at the end of sprint and work that was not completed was added on to the next sprint. Developers hardly spoke to each other and there was no TDD involved in development. In fact most developers had a spec at the start and just got on with it for the 2 or 3 weeks the sprint was arranged for. There was hardly any communication with the client/stake holder. QA got involved usually a few months later and by then we found missing requirements which further increased the amount of work we had to do. Clearly there was no feedback loop. So my question is, where did we go wrong and how can I prevent the team from making the same mistakes.


Is C# more superior than Java as a programming language, objectively speaking?

A colleague (a .NET fan) argued that (in context to Java vs .NET comparison), while there are different arguments for Java and for .NET, and to determine which one is the better choice is a business or personal decision depending on many factors, but from programming language point of view, .NET's C# is clearly a more powerful programming language than Java To summarize, everything that can be written in Java can be written in C# just as easily or easier, but the reverse is not true. Many features such as lambda expression, and linq is impossible (or very hard in Java), and C# also has syntactic sugar that makes things a lot easier, such as extension method, automatic properties, etc. But there is almost no feature that can be done in Java but impossible or very difficult in C#? So, in any possible situation C# is equal or more powerful than Java. Is my colleague's assertion correct? If not, what are some examples of coding that is clean and easy in Java but messy, difficult or impossible in C#? Note: I don't think this is a subjective/argumentative question. I am not looking for arguments that Java is a better choice, or .NET is. I am just asking for evaluation based on facts and concrete examples. For example (made- up example): in .NET iterating on a list will need a dirty workaround and takes dozens of lines, while in java it's just a few clean line


Run RSpec from within a ruby script while refreshing all ruby configs etc

I'm working with a very large project with tons of established tests that include some reasonably complicated environment setups and what not. I've recently run into a situation testing some eventually true conditions and stuff like that where I want the ability to run a specific test many many many times and figure out the approximate run time to help me figure out how I should be configuring the waiting times on those tests before I assume failure. I wanted to do this via ruby so I could easily dump the rspec results into json blocks for ease of interpretation and modifcation, as many of the tests dump TONS of text into the sysout stream, and I don't really want to parse it all just to get the bit at the end that reports results. Eventually I also want the ability to inject flags into the middles of tests to give me finer grain timing information about how long, for example, a specific part of a specific test runs on average. So far my attempt looks like this.               #some setup code to get $runnerargs configs etc     until $i >= $repetitions do       $config = RSpec.configuration       $json_formatter = RSpec::Core::Formatters::JsonFormatter.new($config.output)       $reporter = RSpec::Core::Reporter.new($json_formatter)       $config.instance_variable_set(:@reporter, $reporter)       #some other stuff       RSpec::Core::Runner.run($runnerargs)       #get results in a json file and do cool things with them     end       The problem I'm having is that it looks like ruby doesn't seem to refresh the environment from within a script by default when running rspecs. For example if I do a similar thing to this test in a shell script it works fine, but gives me really ugly output that I don't want to work with. but running things this way, the first test runs fine, but the next test crashes because environment variables used within the test spec have changed during the execution of the first test and they are not properly restarted. I'm not sure if the fault is ruby or rspec. Anyways, anyone else encounter something similar? Is there a way to force ruby or rspec to completely close down the old environment and spin up a new one the way running from shell script does?


Why build data models in a dynamic language?

**Background** This question stems out of an architectural discussion we had at work. For the current project we are using Python and an object oriented database. There are input services that we consume, and certain interfaces that we are expected to provide output through. Someone on our team started designing a data model, and my question was: why? A data-only object in Python can just as well be be represented by a dict (there is a fair amount of questions about that on this site). We don't have a relational database that has columns that we need to map objects to either. At the same time, there is a cost to a data model in that it will always need to be maintained. When interfaces change it (IMHO) simply becomes another dependency that needs to be satisfied, but unlike in static-typed languages it does not actually enforce anything. **Question:** The way it seems to me is that when you are in an environment where everything is dynamic, it makes sense for the interfaces to define your data model implicitly rather than maintain some sort of classes that define a model. Are there ever any good reasons to the contrary? **EDIT** In the comments and answers people seem to be focusing on two areas, they are: database mapping and representation as well as validation of the data model. I apologize for not being more explicit about the DB, but in this environment that we face we have an object-oriented DB that stores blobs in a file system- like representation. There is no mapping to SQL and no ORM of any sort to speak of. I do understand the argument though. For example, Django's models require subclassing for ORM to work. In thise case, making model classes makes perfect sense because the DB is effectively a static-typed data store and not 'dynamic'. But this is not the scenario of the question, because it's not a pure dynamically typed environment. Regarding validators: yes. One will need to create validators that check fields being present, and them being of the right type. In static-typed languages the model implicitly does this (when you're coding C++/Java you can't stick user 'std::string' to where a User class should be). But in Python, a model class does not enforce anything. If I am building validators that check presence of attributes anyway, does this not make classes, dicts, generators etc functionally interchangable? And if so, should the solution not be one with least code? Validators in general seem to me to be an argument in favour of _not_ building data model classes rather than the contrary. Am I wrong in this?


What are C's advantages over OOP languages, other than performance?

> **Possible Duplicate:**   >  When to use C over C++, and C++ over C? C still has its own importance in the programming world! And one reason for it is its performance. But, I have some questions.   * Is there anything that is special to C that other languages missing?    * What are its importance today, other than performance issues?    * What are the advantages of C over OOP languages like C++, Java, Python, etc.,?   * Is there anything other that gives a plus point to C?


Is there a stricter strtoull() in any ubiquitous C library?

I want a function that will interpret a string as a strictly unsigned integer, failing when the string overflows, represents a negative number, or does not represent a number. `strtoull()` does set errno to ERANGE on overflow or EINVAL for a string that does not begin with a number, but accepts negative numbers as valid. `strtoumax()` is the same as `strtoull()` `atoll()` and `strtonum()` are ruled out because they are strictly for signed integers. `sscanf()` sets errno to ERANGE on overflow and stops processing the string if it does not begin with a number (reflected in sscanf's return value), but also accepts negative numbers as valid. Is there another option that I'm missing?


Declaring functions in order to avoid explicit nested loops

My programming professor has told me that it is a good programming practice (at least in C/C++) to declare a function with the inner loop when nesting loops (not _for_ loops, since when, i.e. looping through a multidimensional array this is very intuitive). For example, if I write               int main()     {         while (cond1)         {             // ...(1)...             while (cond2)             {                 // ...(2)...             }         }     }      then it is better:               type inner_loop(param)     {         // ...(1)...              while (cond2)         {             // ...(2)...         }     }          int main()     {         while (cond1)         {             inner_loop(param);         }     }      What improvements do imply this method? Is there any case in which this way of programming nested loops can be counterproductive? Thanks in advance.


Language that can statically ensure a map's fields are present

If data is simple and objects are complex, I'm curious if there are any existing statically typed languages that would be able to augment(?) a map type into a type with guaranteed fields. I realize that at runtime, in any language this type of check is pretty doable. But in theory I also believe this should be possible to check with a compiler. To do everything below in Java, would be an explosion of interfaces (HasComplete, HasTitle, HasTitleAndComplete) So has anyone done it? If not, how come? If so, how was it implemented? This would allow you to read in data but then manipulate it with at least some type safety:               // User input is often simply converted to a Map     function parse(json) -> Map {...}           // result still has all user input fields,      // but this would be a runtime exception      // if specified fields are missing     function cast(Map, Map<fields...>) -> Map<fields...> { ... }          input = "{title:'do it', complete: false, rank: 5, subtitle: 'now'}"          // Would throw class cast exception if complete or title were missing     todo = cast(parse(input), Map<title:str, complete:bool>)               // Runtime introspection     todo instanceOf Map -> true     todo instanceOf Map<title:str, complete:bool> -> true     todo instanceOf Map<title:str> -> true     todo instanceOf Map<complete:bool> -> true     todo instanceOf Map<complete:date> -> false     todo instanceOf Map<rank:int> -> false because cast() did not specify rank     todo instanceOf Map<title:str, complete:bool, author:str> -> false           // Typed methods based on map with certain fields     function capitalize_title(Map<title:str>) {...}     function finish_task(Map<complete:bool>) {...}     function finish_and_rename(Map<title:str, complete:bool>, newTitle) {...}     function increase_rank(Map<rank:int>) {...}          // Static Check compile pass     todo = capitalize_title(todo)     todo = finish_task(todo)     todo = finish_and_rename(todo, "[complete]")          // Static Check Compile Fail because cast() did not specify rank     increase_rank(todo)          // Methods could return a type with added (or removed) fields     function add_uuid(Map) -> Map<+id:int> {...}     todo_with_id = add_uuid(todo)     todo_with_id instanceOf Map<title:str, complete:bool, id:int> // true


Efficient methods for storing tens of millions of objects for querying, with a high number of inserts per second?

This is basically a logging/counting application that is counting the number of packets and counting the type of packet, etc. on a p2p chat network. This equates to about 4-6 million packets in a 5 minute period. And because I only take a "snapshot" of this information, I am only removing packets older than 5 minutes every five minutes. So the maximum about of items that will be in this collection is 10 to 12 million. Because I need to make 300 connections to different superpeers, it is a possibility that each packet is trying to be inserted at least 300 times (which is probably why holding this data in memory is the only reasonable option). Currently, I have been using a Dictionary for storing this information. But because of the large amount of items I'm trying to store, I run into issues with the large object heap and the amount of memory usage continuously grows over time.               Dictionary<ulong, Packet>          public class Packet     {         public ushort RequesterPort;         public bool IsSearch;         public string SearchText;         public bool Flagged;         public byte PacketType;         public DateTime TimeStamp;     }      I have tried using mysql, but it was not able to keep up with the amount of data that I need to insert (while checking to make sure it was not a duplicate), and that was while using transactions. I tried mongodb, but the cpu usage for that was insane and did not keep either. My main issue arises every 5 minutes, because I remove all packets that are older than 5 minutes, and take a "snapshot" of this data. As i'm using LINQ queries to count the number of packets containing a certain packet type. I also am calling a distinct() query on the data, where I strip 4 bytes (ip address) out of the keyvaluepair's key, and combine it with the requestingport value in the Value of the keyvalupair and use that to get a distinct number of peers from all the packets. The application currently hovers around 1.1GB of memory usage, and when a snapshot is called it can go so far as to double the usage. Now this wouldn't be an issue if I have an insane amount of ram, but the vm I have this running on is limited to 2GB of ram at the moment. Is there any easy solution?


Whats the real overhead of TDD once the entire team is used to it?

What percentage of time is saved and costed doing TDD. I assume this percentage of cost and reward changes during a projects life- cycle. I'd imagine the **initial phase** has a lot more cost but little rewards attached. Further on (during **re-factoring** ) you get the benefit of your tests. I've heard anywhere from **30-50% of your time** is writing unit tests. However that doesn't take into account the **time saved** from writing those tests. What's everyones' experience with this? Wes **EDIT** Whats the time saved as well as the time cost? In bug fixing and refactorablity?


A specific problem with architecturing a part of our application

Firstly, I'll try to describe the real world model of what we are trying to express in C# code. We have a device called M100. It's purpose is to read\write data from\into cards (plastic or ULTRALIGHT cards such as MIFARE). It can be with one up to 3 antennas (the device read\write data through antenna). One of antennas is internal (so card can be put on the device surface and the device will be able to perform read\write operations), the other are external. Let's consider the usual situation. We have a point of service terminal. M100 reside inside the terminal and it has two external antennas wich are placed over a tract of cards dispenser. Cards dispenser is another device which is responsible for accepting and dispensing cards for performing read\write operations by M100. So, card dispenser takes the card from the user, move it to the read\write position and after that M100 can perform read\write operations. M100 can be equipped with only one (internal) antenna. So we have to main cases: with and without card dispensers. We have one application that interacts with dispensers and the other uses M100 without card dispensers. We developed M100Provider with it's interface IM100Provider. This is the low- level class which interacts with M100 directly, passes commands through COM- port. We have a higher level-operations such as AuthorizeOperator, WriteTicket, ReadCard (all this operations require M100) so we developed M100Communicator class (maybe the name does not reflect it's intention at the time, but we will think about the name a bit later). M100Communicator is a singleton. Because we need to manipulate card dispensers to accept and dispense users cards M100Communicator interacts with CardDispensersManager class. We haven't decide yet wil it be composed into M100Communicator or will it be a singleton (it seems like it's a singleton). All these operations are have to perform in a kind of a unified way:   1. Block the current object.   2. Check if there are some dispensers configured   3. If they are - pass to them a command to open the tract for card acception.   4. Pass to M100 a command to search a card through specified antennas.   5. When the card was found, perform read\write operations.   6. Dispense card back to the user. Here are the problems we are faced:   1. Considering that M100Communicator sometimes doesn't require CardDispensersManager we are forced to check it's state to null reference everywhere (and it will be quite strange to have a special case CardDispensersManager which will return meaningfull responses while there are no dispensers!).   2. M100Communicator and CardDispensersManager have to be initialized from the start of the system so it's unclear how to update the configuration of CardDispensersManager and M100Communicator and how to communicate with CardDispensersManager directly when we want to close ports and stop communication with dispensers explicitly, because it will be very strange to expose dispensers API through M100Communicator. (yes we have the requirement to be able to access dispensers API from everywhere, so we think that CardsDispenserManager has to be a singleton).


In what programming language did "let" first appear?

I was wondering about the origins of the "let" used in Lisp, Clojure, and Haskell. Does anyone know which language it appeared in first?


Do I have to release my code as open source if I use Git?

This is a question **focused on the legal aspects of software licensing**. I am starting to develop a proeject want the option to claim the source code as properitary and retain full copy rights. I like 'git' (license under GNU v2), but want to make sure of a couple legal things.   1. What is the legal status of source code under version control of 'git' (which is distributed under the GNU v2 license)? Does it qualify as a 'derivative work'?   2. What are the legal ramifications of the source code's legal status? Specifically in regards to being legally obligated to realeasing source code.   3. What besides git (GNU v2 license), what are my other version control options (legally speaking)?


Dijkstra quote on object-orientation?

I came across the following supposed Dijkstra quote on object-orientation > Object-oriented programming is an exceptionally bad idea which could only > have originated in California However even my source isn't convinced the quote is genuine. Does anyone know whether it's genuine, and if so what the context he was speaking in was? I'm aware of the shortcomings of OOP, just wondered which one was in his mind at the time.


How to be robust against webservice downtime caused by third parties

I'm using iPage as my cloud based server provider. I haven't had any problems with them yet. They hold the scripts for my RESTful services for the mobile app I'm developing. My problem however is that tonight the service went down. I got a "This is a 500" error. I'm wondering how do I build redundancy into my RESTful services to prevent this stuff from happening. They say it'll be 2 hours at least until they can solve this problem. If my app is live I can't wait 2 hours. My users will get annoyed. I know this happens anyway but how can I build redundancies to prevent it.


Ideas about how to prevent malicious code to go into production especially in case of SAAS environments

As nowadays SAAS is becoming popular way of developing and deploying the applications, and I have just started working at a company providing SaaS solution for payment authorization services. Since past few days, I have been thinking what would happen if some "unsatisfied / angry" developer write a malicious code (lets say deleting transaction table !)which would activate on some particular time (so that it would not be caught during testing process) and can create havoc for any time critical SAAS application. Any good SAAS offering comes with proper backup strategy and hence data restoration could be possible upto certain extent but it would seriously hamper the availibility of system and in turn the image with clients. Sometimes I think this could be controlled through code reviews but I have seen that most of the times the code reviews are not done properly and such malicious logic can be camouflaged behind some complicated string manipulations. So I am just boucing my thoughts to community for some good ideas, which could be implemented in development process to catch such malicious activities early on. P.S. : Sometimes though I am unsatisfied / angry developer but would never do such unethical things being a coding lover.


What's the best way to create a static utility class in python? Is using metaclasses code smell?

Ok so I need to create a bunch of utility classes in python. Normally I would just use a simple module for this but I need to be able to inherit in order to share common code between them. The common code needs to reference the state of the module using it so simple imports wouldn't work well. I don't like singletons, and classes that use the classmethod decorator do not have proper support for python properties. One pattern I see used a lot is creating an internal python class prefixed with an underscore and creating a single instance which is then explicitly imported or set as the module itself. This is also used by fabric to create a common environment object (fabric.api.env). I've realized another way to accomplish this would be with metaclasses. For example:               #util.py     class MetaFooBase(type):         @property         def file_path(cls):             raise NotImplementedError              def inherited_method(cls):             print cls.file_path               #foo.py     from util import *     import env          class MetaFoo(MetaFooBase):         @property         def file_path(cls):             return env.base_path + "relative/path"              def another_class_method(cls):             pass          class Foo(object): __metaclass__ = MetaFoo               #client.py     from foo import Foo          file_path = Foo.file_path      I like this approach better than the first pattern for a few reasons: First, instantiating Foo would be meaningless as it has no attributes or methods, which insures this class acts like a true single interface utility, unlike the first pattern which relies on the underscore convention to dissuade client code from creating more instances of the internal class. Second, sub-classing MetaFoo in a different module wouldn't be as awkward because I wouldn't be importing a class with an underscore which is inherently going against its private naming convention. Third, this seems to be the closest approximation to a static class that exists in python, as all the meta code applies only to the class and not to its instances. This is shown by the common convention of using cls instead of self in the class methods. As well, the base class inherits from type instead of object which would prevent users from trying to use it as a base for other non-static classes. It's implementation as a static class is also apparent when using it by the naming convention Foo, as opposed to foo, which denotes a static class method is being used. As much as I think this is a good fit, I feel that others might feel its not _pythonic_ because its not a _sanctioned_ use for metaclasses which should be avoided _99%_ of the time. I also find most python devs tend to shy away from metaclasses which might affect code reuse/maintainability. Is this code considered code smell in the python community? I ask because I'm creating a pypi package, and would like to do everything I can to increase adoption.


Ensuring that headers are explicitly included in CPP file

I think it's generally good practice to `#include` the header for any types used in a CPP file, regardless of what is already included via the HPP file. So I might `#include <string>` in both my HPP and CPP, for example, even though I could still compile if I skipped it in the CPP. This way I don't have to worry about whether my HPP used a forward declaration or not. Are there any tools that can enforce this `#include` coding style? _Should_ I enforce this coding style? Since the preprocessor/compiler doesn't care whether the `#include` is coming from the HPP or CPP, I get no feedback if I forget to follow this style.


Updating copyright headers each new year just because Jan 1st has passed?

I've seen some projects that - with each new year - start to change all files in their source-tree to update the copyright year. Isn't this just pushing hot air on a level of magnitude? AFAIK:   * Copyright year is based on relevant changes of a work (also) - not only because of a trivial change of the copyright year in a file-header that is the only change.   * Changing nearly all files without an actual need brings the code out of order in version control. I can't help myself but have problems to see why someone wants to do such superfluous stuff, albeit I know some projects are doing this (for example Zend Framework 1 in 2012). Is there any use in changing the copyright year in each file only because Jan 1st has passed?


Why do we need years in a software license?

I start every `.java` file in my project with a license (BSD, in my case). And its first line says:               /**      * Copyright (c) 2011-2014, Firstname Lastname      *      * Redistribution and use in source and binary forms, with or without      * modification, are permitted provided that the following conditions      etc.      The question is, why do I need to show years there? I see many other projects are doing the same. What will I lose by just saying `Copyright (c) Firstname Lastname`, without that time interval.


Quickest way to split a delimited String in Java

I am building a Comparator that provides multi-column sort capability on a delimited String. I am currently using the split method from String class as my preferred choice for splitting the raw String into tokens. Is this the best performing way to convert the raw String into a String array? I will be sorting millions of rows so I think approach matters. It seems to run fine and is very easy, but unsure if there's a faster way in java. Here is how the sort works in my Comparator:               public int compare(String a, String b) {              String[] aValues = a.split(_delimiter, _columnComparators.length);         String[] bValues = b.split(_delimiter, _columnComparators.length);         int result = 0;              for( int index : _sortColumnIndices ) {             result = _columnComparators[index].compare(aValues[index], bValues[index]);             if(result != 0){                 break;             }         }         return result;     }      After benchmarking the various approaches, believe it or not, the split method was the quickest using the latest version of java. You can download my completed comparator here: https://sourceforge.net/projects/multicolumnrowcomparator/


Why would an employee not be allowed to share techniques?

Few days back, I faced two interviews. It's obvious that they are going to ask about the different techniques I have learned. So, I gave them link of my tutorials while giving telephonic interview (Skype). In short, I explained the things using my blogs which they wanted to know. Say for example, Q: What challenge did you face earlier and how did you solve it ?   A: I got stuck when client insist me to have customized moviePlayer in iPhone, I came out to an solution. I have given complete brief of that technique here. After this conversation, this was their response: > We are happy to see you active in such manner. But our company has some > rules and regulations. You are not allowed to post anything regarding our > project. If you are willing to obey our rules, we are happy with that and we > will hire you. I just couldn't understand why knowledge sharing is strictly prohibited? I am fully agree that if company is developing new APIs, or new technologies I should not publicly discuss it. But my blogs are about some techniques sharing. Why am I forced to shut down my open-source sharing if I want to join that company? I also explained them, If no one is going to share their knowledge, how are you going to learn such things? I gave examples like these:   * If Ray Wenderlich doesn't post about game development, how am I gonna learn game development basics for iPhone / iOS?   * If Jon Skeet is not allowed to give answer on Stack Overflow, how am I gonna learn superstitious things? **Summary** :   1. Why do company think like that "Our developer share our company's details?"   2. Why do company think like that "It's their own property, If we do some research regarding development on office? " (need brief, I can elaborate more, just comment for that, I will edit question). **Edit** : Well! I am sharing techniques in small pieces & functionalities. I am not sharing whole project. Similarly, I am also doing some research work at my home & share about my technical experience. What is the reason behind interrupting someone's life. Its all about sharing the stuff that you have learned & it's strongly not about sharing companies client details or company projects.


As a teen, how can I find "friends" for programming

I'm a teen who has been programming for about 3 years, I can do some basic Software and so, but I feel I can't do all by myself. What can I do to find people interested in Programming ? None of my friends does, I only have a Cousin which is studying Software Engineering, but he is in another country. I live in Spain, so It's more difficult that in USA.


Should you put personal beliefs in your program?

Recently I've found two examples of programmer's personal beliefs in programs that have removed or crippled useful functionality   * uTorrent using KB (rarely used) vs Kb (what most ISPs and other programs use as their metric) in their current connection speed. Various attempts by others and me to give options to at least give an option to show in Kb have ended with "ISPs should use KB"   * Kleopatra (gpg4Win key manager) not having PGP Key Pictures since they "give a false sense of security" and "increase the size of certificates". While the latter is true, the former is debatable. Both of these hurt the program and its usefulness to me. uTorrent's forums used to be filled with people saying they have 10 Mb download pipe but uTorrent only goes up to 2 MB (not knowing that Mb `!=` MB), and with feature requests to show in Mb. Kleopatra has lost usefulness to me since I don't have the functionality to add pictures to PGP keys. These all are political statements; developers attempting to make change in, in their minds important, issues. But should this come at a cost to end user functionality? If a programmer heavily believes X but everyone else believes Y, should the programmer refuse to add support for Y because in their mind X is horrible? In short, should a programmer make political statements in their program?


What to do if boss always postpones major decisions about requirements and overall design?

When starting a new project, my boss always avoids to make fixed decisions. He is usually saying: ok, just start to write something and be as generic as possible. When you're finished we look how we continue. His argument is basically that you never know and "agile development". To keep the question as generic as possible: what do you do if your boss doesn't like to make decisions? Just stick to it and write code that might undergo heavy refactoring and partial rewriting a few weeks later? Or keep on discussing until the boss does at least a few decisions? This is more or less my current strategy. Because it's like a law of physics, at some point something needs to be delivered. Either because the boss' boss wants to see results or because stuff is becoming ridiculous at some point. I also observe that my boss is criticizing nearly everything. Even suggestions that are based on his own...


Reasoning to wait until third time in the Rule of Three?

I just came across the article "Rule of Three" in wikipedia > Rule of three is a code refactoring rule of thumb to decide when a > replicated piece of code should be replaced by a new procedure. It states > that the code can be copied once, but that when the same code is used three > times, it should be extracted into a new procedure. The rule was introduced > by Martin Fowler in Refactoring and attributed to Don Roberts. I know that this is just a rule of thumb, but why is it recommended to refactor only after the second duplication? Is there any downside to refactoring when we write the first duplication?


What do you do when your naming convention clashes with your language?

Okay, this is one of those little things that always bugged me. I typically don't abbreviate identifiers, and the only time I use a short identifier (e.g., `i`) is for a tight loop. So it irritates me when I'm working in C++ and I have a variable that needs to be named `operator` or `class` and I have to work around it or use an abbreviation, because it ends up sticking out. Caveat: this may happen to me disproportionately often because I work a lot in programming language design, where domain objects may mirror concepts in the host language and inadvertently cause clashes. How would you deal with this? Abbreviate? (`op`) Misspell? (`klass`) Something else? (`operator_`)


Do I need to understand algorithms and data structures to be called a programmer?

It has been six years since I have been coding. Coding into all kinds of things like ActionScript, JavaScript, Java, PHP, Ajax, XML HTML, ASP, etc. I have used arrays, maps, linked lists, sets, etc and wherever I worked people like me. But whenever I am interviewed it is very likely that people ask me question on hashes, trees, stacks, and queues. Some questions are on juggling some sorting algorithms. I don't know if I should really know them or should I stop calling myself a programmer. There is something in me which also tells me even if people who are asking all these questions select me, they will never be making me work of these things. Am I really required to know all this?


Documenting/defining data structures in Python

What is the preferred way to document the contents of and logic behind dynamically generated data structures in Python? E.g. a dict which contains the mapping of a string to a list of lists of strings? I find it hard to transport the meaning and algorithmic workings of the data elements through Python code alone. It is unsatisfying and sometimes counterproductive to try to shape the code which erects such a dict into a form which tells another programmer easily about the structure of a dict entry. Similarly, placing a comment with an example entry is anything but optimal in my eyes.


Have any of you tried "Basic for Android"?

I have developed for Android for half a year or so and it is going quite well. I found the learning curve steep in the beginning, but then I somehow got the idea of it all and now I don't have to fight so much anymore. Rather I spend the time on specific problems like "How to do X in Android" but that is usually simple enough to google - or to ask here :) Anyhow, I just discovered Basic for Android and I must admit it looks attractive. It has the kind of IDE I am used to (Delphi) and it seems to be very capable. But on the other hand I am still new in the Android universe so I don't find myself competent enough to really judge the pros and cons of the tool. Have any of you tried it, and if so, what are your thoughts about it?


Where to load and store settings from a file?

I think this question should apply to most programs that load settings from a file. My question is from a programming point of view, and it is really how to deal with the loading of settings from a file in terms of different classes and accessibility. For instance:   * If a program had a simple `settings.ini` file, should its contents be loaded in a `load()` method of a class, or perhaps the constructor?   * Should the values be stored in `public static` variables, or should there be `static` methods to get and set properties?   * What should happen in the event of the file not existing or not being readable? How would you let the rest of the program know it can't get those properties?   * etc. I'm hoping I'm asking this in the right place here. I wanted to make the question as language agnostic as possible, but I'm mainly focusing on languages that have things like inheritance - especially Java and C#.NET.


What do you do if you've had a series of bad employers?

So I've had a series of really bad experiences and am wondering what I'm doing wrong. I started out as a part time programmer at a major university. I developed a problem with my wrist and asked (nicely) for some help with my ergonomic accomodations. My boss started screaming at me, then later claimed I screamed at her. When questioned about it, she just started sobbing. Luckily, there were others around who heard the screaming and knew I was telling the truth. She was eventually let go. My contract went up and I switched jobs, this time to a startup. Well, we went several months without my getting a development machine. When the economy tanked, they started asking for insane amounts of overtime. I complied because I was afraid of having to look for work. The final straw was they contacted me right before my father's funeral to fix a problem. I was laid off, didn't receive my final check on time and the company screwed my COBRA up to the point where I couldn't get prescriptions for months. They recently were fined by the State of X for what they did. Now, even though I worked my heart out for them and they were willing before being fined, they are refusing to provide a reference. I took a new job quickly, mainly because I really needed my health insurance set up. They wanted me to do several months of work in a couple of weeks. They had no project plan. Their customers were seriously not doing well, as whole sections of the application would stop working if someone ran a spell check. Even though they had completely unreasaonble expectations about my work, they were happy to say it would take several months to repair the spell check bug. There was virtually no training. They had me interviewing candidates and I selected one. Apparently, that person was my replacement because I was let go after a few months. Recently, my former boss called my current employer and made up allegations that I am discouraging people from applying to open positions at his firm, which is insane because I didn't even know they were hiring. I feel like I have a T-shirt that says, "If you're insane or would like someone to kick around and treat badly, hire me!". Then again, when I look at some programmers' resumes, I do see horror stories, too. So are there things I can do differently to avoid these problems? Is it part of our profession that people do not have standards? Perhaps it is a personality issue, that resides purely with me? Has anyone else had a series of bad experiences and turned things around?


Advantages and possible drawbacks of using Java for cross-platform development vs. .NET?

If I were to begin writing an application using Java with the intention of porting it to other platforms with little or no modification, would it be wise to consider using the .Net framework instead? I have no specific targets in mind with respect to platform. At a minimum, Windows/Mac/Linux support would be nice. Also ease-of-use for the end-user is a consideration.


How do you feel about using online Version Control Systems?

I have been running my own home-based server for ages for my own personal code, and have tried one system or another (SVN, VSS, etc). But recently, I've enjoyed having some more precious (no source code) data off-site, without having to constantly worry about backups in case of hardware failure, using services like Dropbox, Skydrive, Google apps, etc. This has made me want to do the same with my source code for various projects, however, I have a few worries about them. Namely, how secure is my code from curious/prying eyes, and do I need to possibly have a fail-safe service, in case one goes belly up overnight, or simply has massive data issues? This wasn't actually a concern until I read someone's experiences with Mozy.com, which while not a code repository service, data storage is data storage. If you do use/recommend such a service, which would you recommend? I'm open to using any system, be it Mercurial, SVN, GIT, TFS, etc, so long as it has a Windows and a Mac client option (web-based would be a very nice "bonus"). And most importantly, why?


Functional programming is one of the oldest programming paradigms. However it isn't used much in the industry compared to more popular paradigms. But it have largely been emphasized in academia. What's your strongest opinion against functional programming?


Violation of the DRY Principle

I am sure there's a name for this anti-pattern somewhere; however I am not familiar enough with the anti-pattern literature to know it. Consider the following scenario: `or0` is a member function in a class. For better or worse, it's heavily dependent on class member variables. Programmer A comes along and needs functionality like `or0` but rather than calling `or0`, Programmer A copies and renames the entire class. I'm guessing that she doesn't call `or0` because, as I say, it's heavily dependent on member variables for its functionality. Or maybe she's a junior programmer and doesn't know how to call it from other code. So now we've got `or0` and `c0` (c for copy). I can't completely fault Programmer A for this approach--we all get under tight deadlines and we hack code to get work done. Several programmers maintain `or0` so it's now version `orN`. `c0` is now version `cN`. Unfortunately most of the programmers that maintained the class containing `or0` seemed to be completely unaware of `c0`\--which is one of the strongest arguments I can think of for the wisdom of the DRY principle. And there may also have been independent maintainance of the code in `c`. Either way it appears that `or0` and `c0` were maintained independent of each other. And, joy and happiness, an error is occurring in `cN` that does not occur in `orN`. So I have a few questions: 1.) Is there a name for this anti-pattern? I've seen this happen so often I'd find it hard to believe this is not a named anti-pattern. 2.) I can see a few alternatives: a.) Fix `orN` to take a parameter that specifies the values of all the member variables it needs. Then modify `cN` to call `orN` with all of the needed parameters passed in. b.) Try to manually port fixes from `orN` to `cN`. (Mind you I don't want to do this but it is a realistic possibility.) c.) Recopy `orN` to `cN`\--again, yuck but I list it for sake of completeness. d.) Try to figure out where `cN` is broken and then repair it independently of `orN`. Alternative _a_ seems like the best fix in the long term but I doubt the customer will let me implement it. Never time or money to fix things right but always time and money to repair the same problem 40 or 50 times, right? Can anyone suggest other approaches I may not have considered? If you were in my place, which approach would you take? If there are other questions and answers here along these lines, please post links to them. I don't mind removing this question if it's a dupe but my searching hasn't turned up anything that addresses this question yet. * * * EDIT: Thanks everyone for all the thoughtful responses. I asked about a name for the anti-pattern so I could research it further on my own. I'm surprised this particular bad coding practice doesn't seem to have a "canonical" name for it.


How important is XML for a developer?

Is it must that every developer should know XML? How important is XML for a developer? Any suggestion...


Using a GPL licensed library in a commercial app

I develop an android application and in my app I use a libary (jar) that I download from the internet. This jar is open-source under the "GNU General Public License v2". I tried to read the text of the license but had difficulty understanding it. My question is: can I use this libary without changing nothing in the jar in a commercial application? I will be making profit from selling my app which uses this GPL-ed .jar file. If possible, I would like to avoid converting my application to open-source.


Naming convention of getters and setters

Given a string variable `variable`, for example, the convention to expose it is: > public class SomeClass { >   >   >     public String variable = ""; >     public String getVariable() {return variable;} >     public void setVariable(String variable) {this.variable = variable;} >   > > } Which looks like: > class.getVariable(); // Gets "variable" > > class.setVariable("Hello"); // Sets "variable" * * * **Is the following convention considered bad style?** : > public class SomeClass { >   >   >     public String variable = ""; >     public String variable() {return variable;} >     public void variable(String variable) {this.variable = variable;} >   > > } Which looks like: > class.variable(); // Gets "variable" > > class.variable("Hello"); // Sets "variable" * * * Keep in mind that the established design pattern of fluent interface seems to suggest that one create objects using something like: > public class SomeClass { >   >   >     public String variable = ""; >   >     public SomeClass(String variable) {this.variable = variable;} >   >     public String variable() {return variable;} >     public SomeClass variable(String variable) {return SomeClass(variable);} >   > > } Which looks like: > SomeClass sc = new SomeClass().variable("Hello"); // Instantiates a new > SomeClass object with variable equal to "Hello". Evidently, the word "set" is implied in the _fluent interface_ pattern. (Yes, technically, the fluent interface returns the class instead of void when setting. This is not important.)


How to structure many projects that can be versioned and deployed separately

My team is in a situation where we need to create about 30 different processors. By processors I mean code that takes data from a DB and sends it to a remote service somewhere else in the world. They each do fundamentally the same thing, only with different data. Only some of these processors will be deployed to server A, some to server B, and so on. And they won't all version at the same time. If we make a change to processor X, we would version and ship X while leaving the rest of the processors alone. We've come up with three possible options, each of which have their own issues:   1. Have 30 different solutions   2. Have one solution with 30 different projects   3. Have one solution, with one project, with each processor functionality separated by namespace The main con of #1 is having to create and maintain 30 different solutions. And if we have to make a change to many processors at once, we'll need to open n solutions to do so. The main con with #2 is versioning. If we branch the code, we branch the whole thing, even if only one project changed. The main con with #3 is the same as #2. And then we also need to find a way to exclude certain processors from certain servers for deployment. #3 is the easiest to manage during development, but the most difficult during deployment. Is one of these the best option, or is there something else I haven't considered?


Writing a client contract for Web development?

I am a small time web dev freelancer during my time off at university and I have some horror stories when it comes to designing sites for people (not that the sites are bad - just the clients DO NOT KNOW WHAT THEY WANT) this _really_ grinds my gears. To set the context this is what I want to avoid: > I had a client last year that I built a site for _ANON_. We agreed upon a > price (£200 - I am a student so their mentality is "Oh you are a student > that makes you cheap right?") I had the site done to the original > specification within about 3 days (nothing was ever written down be it > original specification costs etc it was all done over phone/Skype) The > client _then_ decided that his original idea wasn't that good looking in > practise so I was told to scrap it and start again, fine, Im'm a > professional I can take that. > > I then redid the site to the new spec that he gave me, took another 3-4 days > and the same thing again, don't like it, start again. By this time I'm > getting rather annoyed with the lack of constructive criticism, So I redo > the site to basically how it is now (see URL above) he says "yeah looks okay > ship it" so it gets put on the web THEN he decides "Oh by the way I want and > e-commerce solution AND a members only section or you aren't getting paid > anything." being in the position I was in I couldn't very well just say no > due to the 12 or so days of my life he had waisted so I proceeded to add the > e-commerce and members only sections, this then led to a **plethora** of > other changes. > > For example there is a page with a variety of "packages" the user can choose > from, I had these done in _glorious_ CSS3 I mean it looked amazing, really > chuffed with my work I put it online and linked him to it... "It's crap get > rid of it do it in photoshop and put .jpg's up instead". Baffled as to how > it could look "crap" I asked what browser he was using... "IE6", I could > have killed him, but restrained myself and told him to upgrade to Chrome or > FF3.6, So he upgrades to FF, "Wow that looks great!... But still redo it in > photoshop so people with IE6 will see it fine" I tried to tell him that the > site demographics showed he was the ONLY one using IE6 but he wasn't having > any of it, so I spend a while doing it in PS put them up, all was fine. > > _Then_ , he says "oh by the way I want to change the package prices" I say > "well if you had left them in CSS3 and HTML you could have done it > yourself", He didn't want to hear it and made me redo the jpg's - This > occurs **every time** he has a new package that needs put up as you would > imagine this gets very annoying after a while and I was beginning to get fed > up, but he decided that with how it was done now looked great and kept him > happy, I then asked about payment "Oh I only have £50 that I can give you > but I can give you 2x 12 week training packages". I think okay, I'll make > the best of a bad situation and take it, so I agree, I get £50 for 2-3weeks > work and 1x12 week training package, I finish that then ask about the other > one "Oh that was only if I could afford to give it to you, right now I can't > so you'll have to pay £120 for that.". Not only that but he keeps pestering > me to do little remedial changes on the site that I taught him how to use, > but he doesn't want to know, so not only am I not getting paid for any > changes I make for him he threatens me that if I don't change them he's > going to spread bad rep about me to any of his clients and everyone he > knows. As you can imagine this got me very edgy about clients and I would now like to develop a contract that:   * No compromises are made for IE6.   * 25% up front 25% half-way and 50% upon completion.   * I have a _minimum_ standard that I will work to so jobs under £500 are not viable.   * Remedial and quarterly changes are payable on a per-hour rate.   * I can reserve the right to take down any site if the 50% upon completion is not paid within 30 days.   * There are no "cash-substitutes" - no cash - no site. If anyone could suggest what to add above as clauses in my contract and if the above are suitable, as in would they scare clients off? Any suggestions on any part of the contract would be appreciated as well as where to get them written up. Thanks all!


Where does the the term "feature creep" come from?

There is a decent Wikipedia article on the "Feature Creep", but it doesn't state an origin. A Google search only leads to some vague article claiming "Earl Rich" coined the term, but there isn't much backup for that claim. There is a Dilbert comic from 2001 on the subject, but the tone seems to imply that the term pre-existed; more or less confirmed by the fact that Google has results pre-2000. However, finding the exact origin proofs difficult. So, who, if anyone at all, coined the term "Feature Creep"? Where does it come from?


Copyrighting simple JavaScript code

Googling around I found a particular page: PCB Via Calculator Looking the page code I found in the JavaScript code: > //copyright circuitcalculator.com > > //please do not copy without permission Taking in account the simplicity of this code, can I write my own JavaScript function for this? I think some related links can be useful. * * * **UPD** : So, talking more specifically this code cannot be accused in any sense?


Fastest native C++ multi-platform compiler & IDE & debugger

If I'll begin developing cross platform applications, The complied file speed is very important for me . I have research before than and find same result about IDE : (I ignored eclipse because very java base, but not complete) for IDE : >   1. NetBeans C/C++ IDE . >   2. CodeBlocks . >   3. CodeLite . >   4. or others . > And for complier || framework || toolkit : >   1. QT toolkit or UnitTest++ . >   2. gnu g++ . >   3. gnu gcc . >   4. wxWidgets . >   5. cygwin . >   6. VC++ . >   7. or others. > But I watch to some QT apps are very dependent to QT's libs :( , It's not good and decrease speed. Now my real question if I want start project what is the best IDE with debugger ,what is the best compiler that give fast speed native code to me, or I force use multi-compiler for any OS ? & please say your reason why that IDE & why that complier.


CPU Architecture and floating-point math

I'm trying to wrap my head around some details about how floating point math is performed on the CPU, trying to better understand what data types to use etc. I think I have a fairly good understanding of how integer math is performed. If I've understood correctly, and disregarding SIMD, a 32-bit CPU will generally perform integer math at at least 32-bit precision etc. Is it correct that floating-point math is dependent on the presence of a FPU? And that the FPU on the x86 is 80-bit, so floating point math is performed at this precision unless using SIMD? What about ARM?


What is the business cost of anemic domain model

I am looking to quantify the cost or problems of bad software development practices. Specifically can software that has been developed resulting in an anemic domain model be quantifiable in terms of business cost or risk? My initial thoughts (which are all nearly impossible to generically quantify) are: -   * Reduced flexibility.   * Potential for increased support costs. Any assistance you can offer would be greatly appreciated.


Simulating simultaneous entities

Consider the need to simulate a set of entitities in an accurate way. All entities exist in an artificial timeline. Within 'steps' of this timeline, all entities can do certain operations. It is imperative that timed events, are handled accurately, and not in processing order. So simple threading isn't a proper simulation, nor is procedurally walking across all entities. Processing may be slow, accuracy is key here. I have some ideas how to implement this myself, but most likely something like this has been done before. Are there any frameworks available for these purposes? Is there any particular paradigm more suitable? UPDATE: **example** for clarification Example: A and B send C a message at the exact same time. Assume sending the message takes time based on distance, and they both are at the exact same distance from C. C should be able to handle this action as a simultaneous 'event', not based on processing order if A would be traversed before B.


Advice on learning programming languages and math

I feel like I'm getting stuck lately when it comes to learning about programming-related things; I thought I'd ask a question here and write it all down in the hope to get some pointers/advice from people. Perhaps writing it down helps me put things in perspective for myself aswell. I study Interactive Multimedia Design. This course is based on two things: graphic design on one hand, and web development on the other hand. I have quite a decent knowledge of web-related languages (the usual HTML/JS/PHP) and I'll be getting a course on ASP.NET next year. In my free time, I have learnt how to work with CodeIgniter, aswell as some diving into Ruby (and Rails) and basic iOS programming. In my first year of college I also did a class on Java (19/20 on the end result). This grade doesn't really mean anything though; I have the basics of OOP down but Java-wise, we learnt next to nothing. Considering the time I have been programming in, for example, PHP.. I can't say I'm bad at it. I'm definitely not _good_ or _great_ at it, but I'm decent. My teachers tell me I have the programming thing down. They just tell me I should keep on learning. So that's what I do, and I try to take in as much as possible; however, sometimes I'm unsure where to start and I have this tendency to always doubt myself. Now, for the 'question'. I want to get into iOS programming. I know iOS programming boils down to programming in Cocoa Touch and Objective-C. I also know Obj-C is a superset of C. I have done a class on C a couple of years ago, but I failed miserably. I got stuck at pointers and never really understood them.. Until like a month ago. I suddenly 'got' it. I have been working through a book on Objective-C for a week or so now, and I understand the basics (I'm at like.. chapter 6 or so). However, I keep running into similar problems as the ones I had when I did the C class: I suck at math. No, really. I come from a Latin-Modern Languages background in high school and I had nearly no math classes back then. I wanted to study Computer Science, but I failed there because of the miserable state of my mathematics knowledge. I can't explain why I'm suddenly talking about math here though, because it isn't directly related to programming.. yet it is. For example, the examples in the book I'm reading now are about programming a fraction-calculator. All good, I can do the programming when I get the formulas down.. but it takes me a full day or more to actually get to that point. I also find it hard to come up with ideas for myself. I made one small iOS app the other day and it's just a button / label kind of thing. When I press the button, it generates a random number. That's really **all** I could come up with. Can you 'learn' that? It probably comes down to creativity, but evidently, I'm not too great at being creative. Are there any sites or resources out there that provide something like a basic list of things you can program when you're just starting out? Maybe I'm focusing on too many things at once. I want to keep my HTML/CSS at a decent level, while learning PHP and CodeIgniter, while diving into Ruby on Rails and learning Objective-C and the iOS SDK at the same time. I just want to be good at something, I guess. The problem is that I can't seem to be happy with my PHP stuff. I want more, something 'harder'; that's why I decided to pick up the iOS thing. Like I said, I have the basics down of a lot of different languages. I can program something simple in Java, in C, in Objective-C as of this week.. but it ends there. Mostly because I can't come up with ideas for more complex applications, and also because I just doubt myself: 'Oh, that's too complex, I can never do that'. And then it ends there. To conclude my rant, let me basically rephrase my questions into a 'tl;dr' part. A. I want to get into iOS programming and I have basic knowledge of C/Objective-C. However, I struggle to come up with ideas of my own and implement them and I also suck at math which is something that isn't directly related to, yet often needed while programming. What can I do? B. I have an interest in a lot of different programming languages and I can't stop reading/learning. However, I don't feel like I'm _good_ in anything. Should I perhaps focus on just one language for a year or longer, or keep taking it all in at the same time and hope I'll finally get them all down? C. Are there any resources out there that provide basic ideas of things I can program? I'm thinking about 'simple' command-line applications here to help me while studying C/Obj-C away from the whole iPhone SDK. Like I said, the examples in my book are mainly math-based (fraction calculator) and it's kinda hard. :( Thanks a lot for reading my post. I didn't plan it to be this long but oh well. Thanks in advance for any answers.


why are both index[array] and array[index] valid in C?

For example consider:               int index = 3;     int array[4] = {0, 1, 2, 3};      then both `index[array]` and `array[index]` are valid expressions, much like `*(index + array)` and `*(array + index)`. In C arrays why is this true? array[5] == 5[array] explains how it works. My question is: Why did the language designers choose to allow this? Why not just enforce that `index[array]` is invalid, for clarity's sake?


Terminology: queue versus fifo

When referring to or documenting a typical lock-free circular data structure (or class or object) used to communicate between arbitrarily long asynchronous threads or processors: "queue", "fifo" or "FIFO" are commonly used. Is there a technical reason why one term might be the more accurate or better communicative usage in some situation over the other term.


How do I convert 64 bit frames to 32 bit?

The problem: We have a camera that is grabbing frames in 64 bit format. We use 32 bit software, and this worked fine on older 32 bit systems. Then the systems changed to 64 bit, and so did the frames, and my application can't access the image frames anymore. We have been able to save the frame to an image file (tiff), then open this file with our application, but it is very slow, and it feels like there has to be a better way to do this. I'm thinking I could call a script from my application that would access the 64 bit frame through the existing library, convert the frame to 32 bit, and return that frame to my application. The problem is, I'm not even sure where to start: how are frames stored before they are saved to files? Once I access the frame, is it even possible to convert it to a 32 bit format for my main application to access?


better way to define an exception thrown by a method in Java?

I know how to define exceptions and all, but I'm not sure if the way I'm doing it is the most intuitive and readable by another users. I have a very simple method I've written that I want to throw an exception, because it's easier then manually checking return values; the method is private and there is no way need to define a public Exception type. None of the existing Java exceptions fit the error exactly, so I'm trying to figure out what type of exception I want to throw here? I don't want to just throw a RuntimeException, I only want to catch my specific exception I throw, all other Exceptions should propagate up. I figured I would define a little inner class for my exception. However, i don't really need to overwrite anything in the RuntimeException class, I just want to catch and and print it's message. So now I have a line that says something like               private class MissingPropertyException extends RuntimeException{};      This does nothing but allow me to catch _only_ the exception I'm intentionally throwing while ignoring the rest. Is this good syntax? it feels odd to define a inner class without implementing anything within it. Is there a way to do this elegantly without creating an empty inner class?


Read K&R before learning low latency C++?

I have never really done a large amount of C programming but am in the middle of teaching myself low latency C++. Would it do more harm than good to read the K&R C programming book? I am a bit worried I will be reading about C conventions which may no longer hold in C++ (especially with C's fondness of global variables).


Testing a REST client against a REST Server. How to do fixtures?

When writing unit tests, it's common to use fixtures: little testable data, so we can say: 1\. Get all clients should include Willy Wonka. 2\. Delete client 3, and now get clients should not include Willy Wonka anymore. That's fine for unit tests. Use setup/teardown to re-load the fixtures or rollback the transaction. So testing **creates, updates, and deletes are done inside a transaction**. The new temporary data lasts just for the length of that test, then is reset. **But what about when we've separated the REST server from the REST client?** We want to make sure our REST client is not just reading correctly, but creating, updating, and deleting correctly. I haven't been able to find any examples or suggestions for **how to do this against a remote test REST server.** Assuming I've got a test REST server serving only fixtures. The whole stateless nature of HTTP means it'd be hard to send a "BEGIN TRANSACTION" and "ROLLBACK TRANSACTION" or "RELOAD FIXTURES" type of message, right? I can't be the first to want to do this, so I have a feeling I need a different way of thinking about this. Any suggestions?


Would licensing software engineers increase skill and salary levels?

When I apply for jobs I have to compete with too many other software engineers who have little or no skill and dilute the candidate pool. I feel it devalues our profession and ultimately pushes down salary levels for all practicing software engineers. I feel my career, and that of other skilled software engineers, would benefit if less unskilled software engineers were prevented from entering the field until they passed a standard set of tests to become "licensed", like other professions such as medicine and law -- they have made it very hard for others to join them, creating an artificial shortage via strict license and boards. They are paid a lot more than most engineers. And even other engineers have PE exams before they are allowed to "practice". Would requiring licensure of software engineers or having a Software Engineer Board increase skill and salary levels in the field?


Is it a good idea to create multiple heads with Mercurial?

I just made a commit that I want to reverse, but I want to keep the bad commit in history. So, I `hg update` to the previous (good) commit. Then I keep working. This leaves me with a new head: the abandoned bad commit. Is this bad practice? What's the best way to keep bad commits in history while not using them?


Choosing DOCTYPE for an online eBook

I'm about to begin working on a project which involves creating an eBook-like website which will contain lots of large documents with text and images.   The site should have a rather minimalistic design, but it will include a UI with some scripting and animations to make browsing the large documents easier. I've been thinking on this matter for a while now and I can't decide what markup to use for such a project.   Should it be `HTML 4.0 strict`? `XHTML 1.0 strict`? Perhaps `HTML5`? It is a likely that people who are not especially internet-savvy will visit the site due to its content, and as such I think it's very plausible for some of the visitors to have relatively old browsers. Can `XHTML` or `HTML5` hurt me in this regard? Reading about various eBook formats (specifically `EPUB`), I learned that many of them use `XHTML` internally; does this mean that if I use `XHTML` (correctly) the site might also be packaged and delivered as an `EPUB` in the future? The strictness and cleanliness of `XHTML`/`XML` also appeals to me greatly. Overall `XHTML` appeals to me the most, but I'm scared about the implication of its use. It has supposedly been discontinued by W3C in favor of `HTML 5`. However, I don't really see any advantages to using `HTML5` over `HTML 4 strict`, as I won't be using any of it's features. I'm also worried about browser compatiablity of `HTML5`. Should I just stick with good ol' `HTML 4 strict`?


Subversion/source control only for production code?

I graduated from college in Computer Science a year ago, and am now working at a small web development company (me and one other developer, plus managers, customer service and tester). Until just before I started, there was no source control system. We're now slowly starting to implement SVN, but the other (senior) developer (henceforth referred to as Joe) insists that the only code that should be committed to our SVN repository is that which has been tested and approved as production-ready. That means that, on larger projects, there might be no commits for weeks at a time or more. Is this a normal practice? It seems to me like we lose a lot of the benefits of source control, including:   * Fine-grained tracking of project progress   * Tracking of issues as they appear and are resolved   * Easily rolling back mistakes   * Easy backup of code, so we don't lose much if a workstation goes down   * Easier to identify exactly what code is running in which production sites, assuming we stamp revisions into executables as described here   * Easy collaboration (though we don't do any teamwork; it's all solo projects)   * Etc. EDIT: I should emphasize that historically, there hasn't been any true teamwork in this company; just two developers working on separate projects. Also, a lot of the projects are small, so they can be completed in a couple of weeks. And the company has been in business for more than a decade and has gotten along fine without source control. Projects are usually completed within their estimated timeframe.


What are the best FizzBuzz questions for interviewing a candidate for a Software Developer role?

I'm looking for some advice on interviewing technical candidates. I touched on this briefly in a question I previously asked: template questions in a technical interview and was informed that FizzBuzz questions are designed to weed out candidates you definitely don't want coming near your code. Moving on from that, I'd like to know what FizzBuzz questions work best? In my own experience, the common one I've seen is "Can you write a method to determine if a number is prime or not?". Personally, I find this a little too easy (writing the most efficient one is another story). Are there better FizzBuzz questions that can be used? What ones would you put to a candidate?


In AngularJS, why do we use scope instead of $scope in the directive link?

Just curious why whenever I see an example of a directive using a link, the parameter for scope is scope and not $scope? This is always biting me because I'm so used to typing $scope, my brain auto- types it and I have to go back and correct it.


Does studying logic puzzles help to pass interviews or limit you?

It is still under question—a Programmers.SE question—if competence in solving logic puzzles is a good assessment of programming skills. Nevertheless, they're still used, and chances are high that you will bump into such a question when you decide to change your employer next time. Mr. Job recommends in a comment to the answer that you should just "study the puzzles, and pass interview". Indeed, there is a plenty of them, and you may have a lot of fun and practice solving them, and you will probably demonstrate (to yourself only, unfortunately) your ability to crack them without any help. However, I'm not sure how it would help you at an interview. Assume you've studied a lot of these puzzles, and come to a job interview. The interviewer asks you to solve X, and...you already know how, because you've solved it before. You tell that you've solved this puzzle before, but it does not matter that you've **solved** it: what counts is that you've **seen** it, and thus the interviewer can't tell if you're capable to solve it, or just read the solution coined by someone else. He picks another puzzle—and you've seen it before too. And again, and again. Finally, the interviewer finds a problem you haven't seen: a badly formulated one with quite a stupid and illogical solution (that's why you haven't encountered it during your practice). No wonder you fail to solve it. But the assessment's been already made: you failed to solve a puzzle you were eligible for. The question is, how should you behave if you like logic puzzles, solve a lot of them (on your own), and encounter them at an interview?


Why does XMLHttpRequest not seem to follow a naming convention?

I've been working with the XMLHttpRequest object in JavaScript recently, and I couldn't help but notice that the casing of this name makes no sense. Why is 'XML' all in caps while 'Http' is not? They're both acronyms! Surely it'd make more sense for the name to be one of the following:   * XmlHttpRequest _(PascalCase, best practice for class names in JavaScript)_   * xmlHttpRequest _(camelCase, also common though not for classes)_   * XMLHTTPRequest _(caps-for-acronyms, rarely used in programming?)_ I'm sure there must be some reason and I'd hate to think it's now set in stone just because no one questioned this at the time. Is there another naming convention that I'm unaware of? Thanks! XMLHttpRequest specification: http://www.w3.org/TR/XMLHttpRequest/


Python mutable default argument: Why?

I know that default arguments are created at the function initialisation time and not every time the function is called. See the following code:               def ook (item, lst=[]):         lst.append(item)         print 'ook', lst          def eek (item, lst=None):         if lst is None: lst = []         lst.append(item)         print 'eek', lst          max = 3     for x in xrange(max):         ook(x)          for x in xrange(max):         eek(x)      What I do not get is why this was implemented this way. What benefits does this behaviour offers over an initialisation at each call time?


Is the Entity Component System architecture object oriented by definition?

Is the Entity Component System architecture object oriented, by definition? It seems more procedural or functional to me. My opinion is that it doesn't prevent you from implementing it in an OO language, but it would not be idiomatic to do so in a staunchly OO way. It seems like ECS separates data (E & C) from behavior (S). As evidence: > The idea is to have no game methods embedded in the entity. And: > The component consists of a minimal set of data needed for a specific > purpose > > Systems are single purpose functions that take a set of entities which have > a specific component * * * I think this is not object oriented because a big part of being object oriented is combining your data and behavior together. As evidence: > In contrast, the object-oriented approach encourages the programmer to place > data where it is not directly accessible by the rest of the program. > Instead, the data is accessed by calling specially written functions, > commonly called methods, which are bundled in with the data. ECS, on the other hand, seems to be all about separating your data from your behavior.


suggestions for staff id authentication

I'm developing an ipad app for managing HR attendance, so the idea is that the staff come to the center, choose their name from a table, and write down their personal id, for the time they come and the time they leave, still evaluating for the requirements if they want the time automatically saved or the staff write the time down (with a roller disk), or both, so what other way of authentication with an ipad comes to mind? (other than typing a code), (no ipad 2 wanted), so they don't want pictures. also how to avoid one person writing the code for a friend??, the data will be stored in coredata, and sync with server, thank you!


What should I do with production error logs?

We have a PHP intranet site that we run with warning/error logging on (as it's not under heavy load and there's a number of bugs/bad code left to find). Because the site is relatively unstable and in active development, I've been clearing the production error logs when each new version releases so I get a clean look at what problems we're having. We _usually_ don't release until all logged problems identified in the last production build are fixed. I still keep Apache's error logs because our code shouldn't mess up Apache (and if it does it's a huge deal), so if something's wrong there I want to know. I'm wondering what a good practice is here; our previous code base logged _hysterically_ verbosely so I've been trying to limit the logs so it's actually usable information, but just clearing the logs seems suspect as well. For reference, most of the logs are undefined variables because a past programmer liked to use `if (!$var)` instead of `if (empty($var))`. I've been eager to remove _those_ entries since the application doesn't perform any unexpected actions but I would get dozens of the same warning daily until we fixed it. Those are also why I left warning logging on in production. **Should I keep all my error logs for future reference?** Should I segregate old logs somehow and tag them to build numbers?


Is there a canonical book on Android Development?

I am getting into Android Development and want a book to help fill in some of the gaps. Is there a book out there that's the de-facto standard for describing best practices, design methodologies, and other helpful information on Android Development? What about that book makes it special?


In agile (scrum), how do you go about breaking down a user story?

In agile (scrum), how should one ideally break down things into a user story. The team size is about 6 developers if that makes a difference, and iterations are 3 weeks. Is breaking a user story with points and hours considered agile, or is it ONLY user points for a given user story? Should we break a user story into tasks also? In the actual workflow for a user story, you have things like:   1. requirement gathering   2. review of the user story by managers etc.   3. qa related tasks in the user workflow  How are these things handled in a agile environment?