Is not being paid for training normal?

I'm a recent college graduate, and I recently had a interview with a company for an entry-level programming job. The company told me that they require two months of unpaid training for all entry level programmers. The reason given was that since they are providing free training, there wouldn't be any compensation. Is this normal? **Update** For other junior developers looking at this: Don't go for these type of scams. This was my first interview. I interviewed with 10 other companies around the area and got about 9 job offers from them. I worked for a fortune 50 company for 9 months with good pay and recently found a better opportunity for even better pay and better work. I guess moral is to be patient and have confidence in yourself.


Domain security involving domain logic

Together with my application's domain logic I am trying to outline the security model. I am stuck with a requirement that prevents me from considering security just a cross-cutting concern over my domain logic. Here follows my situation. A user in my system can potentially be allowed to create a certain kind of objects, say, 'filters'. I introduce a permission called 'CREATE_FILTER', and a user is either allowed to create filters or not, depending on whether the admin assigned such a permission to this user, or not. Ok. Now consider a more complex requirement when the number of filters a user can create is limited. So, e.g. the admin should be able to set max number of filters any user is allowed to create, or even more complex, to assign max numbers individually to users, say value of 3 to User1, 5 to User2 and so on. So, the security system, in order to authorize filter creation to a user, is not sufficient to check whether a user has such a permission assigned, but has to analyze the domain model in a complex way in order to look how many filters there are already created by the user to make the decision. To make things more complex, we can imagine that the max limit will depend on the amount of money user has on their account, or something. I want to conceptually separate (at least in my mind), whether such a complicated security logic purely pertains to security (which will of course depend on the domain model) or is this already a full-fledged part of the domain logic itself? Does it make sense to keep a 'permission' concept, when assigning/removing permissions does not help much (since it's domain state on which depends authorization decision rather than assigned permissions)? Would it be a way to go, say, to have a complicated permission concept which not simply allows an action by a mere fact of its existence but would rather involve some complex decision making logic?


Debugging memory corruption

First off, I do realize this is not a perfect q&a style question with an absolute answer, but I can't think of any wording to make it work better. I don't think there is an absolute solution to this and this is one of the reasons why I'm posting it here instead of stackoverflow . Over the last month I have been rewriting a fairly old piece of server code (mmorpg) to be more modern and easier to extend/mod. I started with the network portion and implemented a 3rd party library (libevent) to handle stuff for me. With all the refactoring and code changes I introduced memory corruption somewhere and I have been struggling to find out where it happens. I can't seem to reliably reproduce it on my dev/test environment, even when implementing primitive bots to simulate some load I dont get crashes anymore (I fixed a libevent issue which caused some stuff) I have tried so far: Valgrinding the hell out of it - No invalid writes until the thing crashes (which may take 1+ day in production.. or just an hour) which is really baffling me, surely at some point it would access invalid memory and not overwrite stuff by chance? (Is there a way to "spread out" the address range?) Code-Analysis tools, namely coverity and cppcheck. While they did point out some.. nastiness and edge cases in the code there was nothing serious. Recording the process until it crashes with gdb (via undodb) and then working my way backwards. This /sounds/ like it should be doable, but I either end up crashing gdb by using the auto-complete feature or I end up in some internal libevent structure where I get lost since there's too many possible branches (one corruption causing another and so on). I guess it would be nice if I could see what a pointer originally belongs to/where it was allocated, that would eliminate most of the branching-issues. I cant run valgrind with undodb though, and I the normal gdb record is unusably slow (if that even works in combination with valgrind). Code review! By myself (thoroughly) and having some friends look over my code, though I doubt it was thorough enough. I was thinking about maybe hiring a dev to do some code review/debugging with me, but I cant afford to put too much money in it and I wouldn't know where to look for someone who'd be willing to work for little-to-no money if he doesnt find the issue or anyone qualified at all. I should also note: I usually get consistent backtraces. There are a few places where the crash happens, mostly related to the socket class becoming corrupted somehow. Be it an invalid pointer pointing to something which isnt a socket or the socket class itself becoming overwritten (partially?) with gibberish. Although I suspect it's crashing there the most since that's one of the mostly used parts, so it's the first corrupted memory which gets used. All in all this issue has had me busy for nearly 2 month (on and off, more of a hobby project) and is really frustrating me to the point where I become grumpy IRL and think about just giving up. I just cant think about what else I am supposed to do to find the issue. Are there any useful techniques I missed? How do you guys deal with that? (It cant be that common since there isn't much information about this.. or I'm just really blind) Edit: Some specs in case it matters: Using c++(11) via gcc 4.7 (version supplied by debian wheezy) The codebase is around 150k lines Edit in response to david.pfx post: (sorry for the slow response) > Are you keeping careful records of crashes, to look for patterns? Yes, I still have dumps of the recent crashes lying around > Are the few places really similar? In what way? Well, in the most recent version (they seem to change whenever I add/remove code or change related structures) it would always get caught in an item timer method. Basically an item has a specific time after which it expires and it sends updated info to the client. The invalid socket pointer would be in the (still valid as far as I can tell) Player class, mostly related to that. I am also experiencing loads of crashes in the cleanup phase, after the normal shutdown where it's destroying all the static classes that havent been explicitly destroyed (__run_exit_handlers in the backtrace). Mostly involving std::map of one class, guessing that's just the first thing that comes up though. > What does the corrupt data look like? Zeros? Ascii? Patterns? I havent found any patterns yet, seems somewhat random to me. It's hard to tell since I don't know where the corruption started. > Is it heap-related? It's entirely heap-related (I enabled gcc's stack guard and that didnt catch anything) > Does the corruption happen after a free()? You're gonna have to elaborate a bit on that one. Do you mean having pointers of already free'd objects lying around? I'm setting every reference to null once the object gets destroyed, so unless I missed something somewhere, no. That should show up in valgrind though which it didnt. > Is there something distinctive about the network traffic (buffer size, > recovery cycle)? The network traffic consists of raw data. So char arrays, (u)intX_t or packed (to remove padding) structs for more complex things, each packet has a header consisting of an id and the packet size itself which is validated against the expected size. They are around 10-60bytes with the biggest (internal 'bootup' packet, fired once at startup) having a size of a few mb > Lots and lots of production asserts. Crash early and predictably before the > damage propagates. I once had a crash related to std::map corruption, each entity has a map of it's "view", each entity that can see it and vice versa is in that. I added a 200byte buffer infront and after, filled it with 0x33 and checked it before each access. The corruption just magically vanished, I must've moved something around which made it corrupt something else. > Strategic logging, so you know accurately what was happening just before. > Add to the logging as you get closer to an answer. It works.. to an extend. > In desperation, can you save state and auto-restart? I can think of a few > pieces of production software that do that. I somewhat do that. The software consists of a main "cache" process and some other worker ones which all access the cache to get and save stuff. So per crash I dont lose much progress, it still disconnects all the users and so on, it's definitely not a solution. > Concurrency: threading, race conditions, etc There's a mysql thread to do "async" queries, that's all untouched though and only shares information to the database class via functions with all lock. > Interrupts There's an interrupt timer to prevent it from locking up that just aborts if it didnt complete a cycle for 30seconds, that code should be safe though if (!tics) { abort(); } else tics = 0; tics is "volatile int tics = 0;" which is increased each time a cycle is completed. Old code too. > events/callbacks/exceptions: corrupting state or the stack unpredictably Lots of callbacks are being used (async network io, timers), but they shouldn't do anything bad. > Unusual data: unsual input data/timing/state I've had a few edge cases related to that. Disconnecting a socket while packets are still being processed resulted in accessing a nullptr and such, but those have been easy to spot so far since every reference gets cleaned up right after telling the class itself it's done. (Destruction itself is handled by a loop deleting all the destroyed objects each cycle) > Dependency on an asynchronous external process. Care to elaborate? This is somewhat the case, the cache process mentioned above. Only thing I could imagine off the top of my head would be it not finishing quick enough and using garbage data, but that's not the case since that's using network too. Same packet model.


Good abbreviations for XML ... things

I've never been very good at maintaining a coherent bunch of variable names for interfacing with XML files because I never name the variables in my interfaces the same way across my source. There are Elements, Attributes, Documents, NodeLists, Nodes, DocumentFragments and other stuff. What's a good scheme for keeping track of this stuff as variables? Is there a standard in regard to Hungarian notation? Do you even put anything signifying that the data is actually XML, is this bad practice? Also, what is the difference between the way you name your constants (signifying Namespaces, Elements and Attribute Names) and your variables (signifying Namespaces, Elements, Attributes, Nodes, Node Lists and Documents)


Groovy/Grails course content

Some Java developers have asked if I could give them a 2-day primer on Grails development. I'm assuming they're familiar with:   * Java language and libraries   * Java web development, e.g. Servlets, JSPs   * Spring   * Hibernate   * Client-side development, CSS, HTML, JavaScript I'm further assuming they have no experience with Groovy or Grails. AFAIK, the app that they'll be building is a new project, so there's no need to cover topics like using GORM with a legacy database. I'm trying to decide how I should structure the course, e.g. what topics to cover and how much time to spend on each. I reckon about 1/2 - 3/4 days on Groovy and the rest of the time on Grails would be adequate. I'll probably use the Groovy console to demonstrate the Groovy language concepts and a simple Grails app for explaining the conventions and structure of a Grails project. If anyone has a list of Groovy/Grails topics that I should cover, or even an outline of a similar course that they've given/taken, I'd be very grateful. Naturally, I will credit for any resources that I use during the course.


Why do C# developers newline opening brackets?

I've spent most of the last several years working mainly with C# and SQL. Every programmer I've worked with over that time was in the habit of placing the opening brace of a function or control flow statement on a new line. So ...               public void MyFunction(string myArgument)     {          //do stuff     }          if(myBoolean == true)     {         //do something     }     else     {         //do something else     }      I have always been struck by how ugly and space wasteful this is, especially in if/else statements. And I know alternatives exist in later versions of C#, like:               if(myBoolean == true)         //do something on one line of code      But hardly anyone used them. Everyone did the curly-brace-on-newline thing. Then I got back into doing JavaScript after a long absence. In my memory, JavaScript developers used to do the exact same curly-brace-newline thing but with all the fancy new libraries and stuff, most developers put the opening brace after the declaration:               function MyJavaScriptFunction() {         //do something     }      You can see the sense in this, because since using closures and function pointers has become popular in JavaScript, it saves a lot of space and makes things more readable. So I wondered why it wasn't seen as the done thing in C#. In fact, if you try the above construct in Visual Studio 2013, it actually reformats it for you, putting the opening brace on a new line! Now, I just saw this question on Code Review SE: http://codereview.stackexchange.com/questions/48035/questions-responses-let- me-tell-you-about-you In which I learned that in Java, a language I'm not overly familiar with, it's considered de-rigour to open your curly braces right after the declaration, in modern JavaScript fashion. I had always understood that C# was originally modelled after Java, and kept to a lot of the same basal coding standards. But in this instance, it seems not. So I presume there must be a good reason: what is the reason? Why do C# developers (and Visual Studio) enforce opening curly brackets on a new line?


Should I know more than one implementation of version control?

I'm using Windows and am comfortable with SVN (well, TortoiseSVN) because it's dead simple. It works for me. However, because it's been working so well, I haven't any reason to try anything else. Should I bother learning a different system, for example, Mercurial or Git?


Giving away sensitive information about previous employers during interview

When you are being interviewed by potential future employers, it is of course of benefit to both parties to discuss what your previous job entailed (ie, what you have been doing for the last few years). What if the technology (and the ideas behind the technology) that you have been working on is sensitive and confidential? I'm working on some really cool stuff at the moment, things that would impress an interviewer, that could demonstrate my passion and understanding, but at the same time I can't just come out and explain the nature of it without disclosing too much about my current employer. On the other hand, if I keep it vague without explaining the subtleties, it just seems as though I am working on fairly basic applications. The key is in the middle ground- the way the applications are constructed- which makes what I currently do both special and difficult. But even acknowledging this middle ground gives away vital information about how my employer competes. Hope that made some sense. What should I do in an interview? Is there like a 2-way NDA for interviews so I can just launch into an in-depth explanation of my past experience, or do I need to be deliberately vague and apologise for not being able to go into detail?


How to use Option Type Pattern in a language that doesn't support generics?

I've been interested to start using the ~~Null Object /~~ Option Type approach for replacing my old habits of null-checking multiple parts of my code. But, from the many examples I saw out there, it seems it's a pattern used in conjunction with generics. Great for C#, Java, Haxe and a bunch of others I'm sure. _NOT_ so great for **ActionScript 3.0** (which is what I was intending to use it for). So, am I under the wrong impression that this won't be possible / worthwhile in a language that doesn't support Generics? Or is there a way to pull it off without them? **NOTE:** It seems the " _Null Object_ " pattern shown in **this PatternCraft tutorial** doesn't quite resemble the way _Option Type_ was described in some of the other discussions in this stackexchange site. His way looks more like a factory class that spits out a **_Null???_** derivative of some base-class. I was hoping there could be a way to create Null-Objects without needing to write a dedicated class for every single case scenarios where a null-check would typically be used. * * * **EDIT: My apologies, I didn't realize "Null Object" and "Option Type" were two completely different beasts. For the sake of keeping the answers and feedback relevant to the question though, I only changed the title (was originally`How to use Null Object / Option Type Pattern in a language that doesn't support generics?`).**


NoSQL design - Storing project assignments

I currently have a planning tool using SQL tables that are sort of setup like this:   * Date table (Contains dates & indicates if that day is a weekend / holiday etc)   * Employee (Simple data)   * Project (Simple data)   * Assignments (Associates the three tables, key date + employee id + project id) I have one SQL query that, for a specific month/year, a joined list of employees + dates + assignment, e.g. 01/01/2014 employee_1 project_1. In case of no assignments, it returned the date anyway, as this makes it the most manageable on the front-end. I was toying around with node.js & mongodb for the first time today, and was wondering if my setup is something that could translate well to NoSQL. I really like the idea of using the JSON notation all the way, but I figure that this might be one of those cases where I'm better off with a RDBMS?


What are the drawbacks of not declaring a class-method static?

On the 'Interfaces' trail on the Oracle website, we are presented with the following scenario: > Imagine a futuristic society where computer-controlled robotic cars > transport passengers through city streets without a human operator. > Automobile manufacturers write software (Java, of course) that operates the > automobile—stop, start, accelerate, turn left, and so forth. Another > industrial group, electronic guidance instrument manufacturers, make > computer systems that receive GPS (Global Positioning System) position data > and wireless transmission of traffic conditions and use that information to > drive the car. > > The auto manufacturers must publish an industry-standard interface that > spells out in detail what methods can be invoked to make the car move (any > car, from any manufacturer). The guidance manufacturers can then write > software that invokes the methods described in the interface to command the > car. Neither industrial group needs to know how the other group's software > is implemented. In fact, each group considers its software highly > proprietary and reserves the right to modify it at any time, as long as it > continues to adhere to the published interface. > (http://docs.oracle.com/javase/tutorial/java/IandI/createinterface.html) So we create an interface like this:               public interface OperateCar {             // constant declarations, if any             // method signatures             // An enum with values RIGHT, LEFT        int turn(Direction direction,                 double radius,                 double startSpeed,                 double endSpeed);        int changeLanes(Direction direction,                        double startSpeed,                        double endSpeed);        int signalTurn(Direction direction,                       boolean signalOn);        int getRadarFront(double distanceToCar,                          double speedOfCar);        int getRadarRear(double distanceToCar,                         double speedOfCar);              ......        // more method signatures     }      and implement it as:               public class OperateBMW760i implements OperateCar {              // the OperateCar method signatures, with implementation --         // for example:         int signalTurn(Direction direction, boolean signalOn) {            // code to turn BMW's LEFT turn indicator lights on            // code to turn BMW's LEFT turn indicator lights off            // code to turn BMW's RIGHT turn indicator lights on            // code to turn BMW's RIGHT turn indicator lights off         }              // other members, as needed -- for example, helper classes not          // visible to clients of the interface     }      So far so good. Now suppose that, in addition, each car manufacturer is required to create a prototype car, and suppose that, for some reason, we wish to keep track of these prototype cars. One solution is to add a new method to the `OperateCar` interface:               public OperateCar getPrototype();      Then each implementing class could implement this method by returning its prototype car. But there's a problem with this: the prototype car has nothing to do with any instantiation of the implementing class; instead, it belongs to the class itself. In other words, if we didn't have the interface, we'd automatically declare this method as `static`. But we can't do that here, because Java interfaces don't allow static methods. What are the problems associated with not declaring a class-method static? Is it OK in this case just to leave out the `static` keyword so that the code compiles? Or are the drawbacks so great that it's better to look for another solution?


Sprint pressure causes quality issues?

The burn down chart displays a clear deadline and the progress towards the deadline. When the progress is slow and the completion of the committed work is at risk, people start to get sloppy on design and code reviews and on the depth of testing. Quality suffers. The question is whether in your organization you were successful to maintain high quality standards regardless of the time remaining to the end of the Sprint. Another question is whether perhaps it is best to drop the burn down chart to somewhat reduce the pressure or even move from Scrum or Kanban or other agile methodology that doesn't mandates iterations.


Do I own copyright of program I made in own time?

I created a software package that aids electrical engineers with common calculations used on site (substations to be specific). I created the package in my own time, without being asked and without guidance. The package is now widely used within my company and I intend to distribute it nationally. Do I own the copyright? My contract does state that all work produced is theirs, but this was outside of work and outside of my 'scope of work'. My company is mainly a civil and construction company and had no influence in the creation of the program. **From comments:** This is the paragraph "During the course of your service, you will disclose to the company all information, formulae, processes, inventions or improvements which you have learned, discovered or evolved during the course of your service or in connection with the business of the company and will sign any necessary documents to enable the company to obtain patent protection whether still in the company service or not. " They are taking it seriously and have got their lawyers. UPDATE::::::::::::::: email just received Dave, As you know we've been pursuing the request you and your patent attorney raised earlier this year, paraphrased below: ... a patent attorney, who has advised me to seek official clarification from _{redacted}_ over the IP and copyright ownerships before I launch the company. In effect, they will produce a legal contract which states all IP and copyrights are owned by my self in exchange for free copies of _{redacted}_ for all MUS engineers. The free offer doesn’t extend to partner companies. This review process has taken longer than hoped as we are obliged to review our contractual position with the _{redacted}_ and also with our employer _{redacted}_. However, _{redacted}_ are willing to release all IP an copyrights on the condition that we continue to use _{redacted}_ for our _{redacted}_ engineers and receive a 15% royalty on the profits derived from the sale of _{redacted}_ licences over a term to be agreed. I am more than happy to discuss this proposal with you at a mutually convenient time, and we can use your legal advisors or ours to draft a IP transfer agreement. Kind regards, _{redacted}_


Node.JS testing with Jasmine, databases, and pre-existing code

I've recently built the start of a core system which is likely going turn into a monster product. I'm building the system with node.js, and decided after I got a small base built, that It'd be a great idea to start using some sort of automated test suite to test the application. I decided to use jasmine, as it seems pretty solid and has a lot of features for stubbing spying and mocking methods and classes. The application has a lot of external data stores and api access (kestrel, mysql, mongodb, facebook, and more). My issue is, I've got a good amount of code written that I want to start testing - as it represents the underpinnings of the application. What are the best practices for testing methods/classes that access external APIs that I may or may not have control over? As an example, I have a data structure that fetches a bunch of data from a MySQL database. I want to test the method that retrieves the data; and I'm not sure how to go about it. I could test the `fetch` method which is supposed to return an array of objects, but to isolate the method from the database, I need to define my own fixture data. So what I end up doing is stubbing the mysql execution, and returning a static dataset. So, I end up writing a function that returns the dataset that makes my test pass. That doesn't seem to actually test the code, other than verifying a method is being called. I know this is kind of abstract and vague, it seems that the idea of testing is very much abstract though, so hopefully someone has some experience and can guide me in the right direction. Any advice, or reading I can do is more than welcomed. Thanks in advance.


How long does one have to wait to consider design change in code?

I had a few days ago. I was having trouble with threads. Had lots of questions asked on StackOverflow and honestly for the first time I did not get the answer I was looking for. Finally, I decided to do a huge re-design of my system code and magically within a few hours I found a solution. So my question is, is it normal to often do a re-design if I get stuck with a problem or should I push on hard till I find a solution? Mind you this is the first time I was stuck for this long on a piece of code.


Team Software Development using Ruby on Rails

I used to work alone on small to medium sized programming projects before and **have no experience working in a team environment**. Currently, there will be 3 of us in an in-house software development team that is tasked to develop a number of software for an academic institution. We have decided to use the web for the majority of the projects and are planning to choose Ruby on Rails for this and I would like to ask for your inputs, advices and approaches with regards to software development as a team using the RoR web framework. One thing that has really confounded me is how you divide the programming tasks of a project if there are 3 of you that are really doing the coding. It’s obvious that we as developers approach a problem in a modular way and finish it one after another. If the project consists of 3 modules, should each one of us focus on each of those modules? Would it be faster that way? How about if the 3 of us would focus on one module first (that’s what I really prefer). Is using a distributed version control system such as Git the answer to this type of problem? Please don’t forget to put your tips and experiences with regards to team software development. Cheers!


Storing menu items with user permissions

I'm creating a menu system in PHP and MySQL. I will have several different menus and each menu will have a set of menu items connected to it. On the site, I also have different user permissions, some users can see all menu items and some items are hidden from some users. I'm curious on how I could handle the permissions in a clean way that will allow for more types of users in the future to be easily added. What I have thus far is something like this:               -------------------     |Menus     -------------------     |id| |display name|     -------------------          ----------------------------------------------------------     |Menu items     ----------------------------------------------------------     |id| |menu_id| |label| |link| |parent| |sort| |permission|     ----------------------------------------------------------      I'm thinking that the `permission` column could either be a comma separated string that I can match against the current user's permission id. It could also be a reference to some other table that defines all possible combinations of the currently existing permissions. One solution could also be to simply store multiple menu items where the only difference is the permission although this would lead to duplicate storage and perhaps a pain to administer. I'd love to hear some thought on how to structure this and what could be considered clean, dynamic and crappy. Thanks.


Testing vs Don't Repeat Yourself (DRY)

Why is repeating yourself by writing tests so highly encouraged? It seems that tests basically express the same thing as the code, and hence is a duplicate (in concept, not implementation) of the code. Wouldn't the ultimate target of DRY include elimination of all test code?


How to infer my Assumptions I based my time estimate on?

In an answer on how to make time estimates it is said to write down all your assumptions you made when estimating a project. Seems like a good plan. Problem is, by assuming I already made an ass out of myself without realizing it. Assumptions are those evil things that like to stay hidden, things I took for granted. So when reviewing my estimate, what techniques can I apply to discover the assumptions I based my time estimate on?


Factory design pattern - getting the types from a table

I've implemented a generic factory as described here I need to register elements to the factory hard-code like this:               Factory.Register(1, typeof(MyClass));      this factory will have to be correlated with a simple domain data type table [id,Display], in this case id 1 is related to MyClass. I was thinking to add a column to that table with the qualified type, so I can simply retrieve the id to types. table will be [id,Display, typeName] and I will use the factory like this:               Factory.Register(id, Type.GetType(typeName));      I tried it and it's working ok. **is this a good design?** **are there any security flaws?** **is there a better way to do things?**


Mocking the DAL/Repository that I pass to the BLL/ViewModels for testing purposes is not much different than creating an in-memory DAL. Right now I'm using an in-memory DAL in a new project instead of mocking it and it's working very well so far (even easier than setting up the mocks I'd say). Since I haven't seen this done in online/book examples I thought I'd ask. Is there a problem with writing an in-memory DAL for testing the BLL/ViewModels? On my architecture all components share a common library with all the relevant interfaces. Things are late bound which allows me to swap any component for another of the same interface.


What happened to Borland Delphi?

I have the impression that Delphi isn't very popular anymore. But now at work I had to make some changes to an old Delphi program that we are still using. I used Borland Developer Studio 2006 and it was very pleasant and intuitive to work with, even though I had practically no previous exposure to it. Is Delphi still widely-used and I am simply not aware of it or are there other reasons for its decline?


Experience of Python's “PEP-302 New Import Hooks”

I'm one of the developers of Ruby (CRuby). We are working on Ruby 2.0 release (planned to release 2012/Feb). Python has "PEP302: New Import Hooks" (2003): > This PEP proposes to add a new set of import hooks that offer better > customization of the Python import mechanism. Contrary to the current > **import** hook, a new-style hook can be injected into the existing scheme, > allowing for a finer grained control of how modules are found and how they > are loaded. We are considering introducing a feature similar to PEP302 into Ruby 2.0 (CRuby 2.0). I want to make a proposal which can persuade Matz. Currently, CRuby can load scripts from only file systems in a standard way. If you have any experience or consideration about PEP 302, please share. Example:   1. It's a great spec. No need to change it.   2. It is almost good, but it has this problem...   3. If I could go back to 2003, then I would change the spec to... I'm sorry if such a question is not suitable for here. I posted here because I'm not sure that I can ask this question at python-dev (of course, the list is not for cruby development). This post is moved from http://stackoverflow.com/questions/11188229/experience-of-pythons-pep-302-new- import-hooks.


Why use partial classes?

In my understanding, the `partial` keyword does nothing but allow a class to be split between several source files. Is there any reason to do this other than for code organization? I've seen it used for that in generated UI classes. It seems a poor reason to create a whole keyword. If a class is big enough to require multiple files, it probably is doing too much. I thought that perhaps you could use it to partially define a class for another programmer somewhere to complete, but it would be better to make an abstract class.


Is implementing an interface defined in a subpackage an anti-pattern?

Let's say I have the following:               package me.my.pkg;     public interface Something {         /* ... couple of methods go here ... */     }      and:               package me.my;     import me.my.pkg.Something;     public class SomeClass implements Something {         /* ... implementation of Something goes here ... */         /* ... some more method implementations go here too ... */     }      That is, _the class implementing an interface lives closer to the package hierarchy root than does the interface it implements_ but they both belong in the same package hierarchy. The reason for this in the particular case I have in mind is that there is a previously-existing package that groups functionality which the `Something` interface logically belongs to, and the logical (as in both "the one you'd expect" and "the one where it needs to go given the current architecture") implementation class exists previously and lives one level "up" from the logical placement of the interface. _The implementing class does not logically belong anywhere under me.my.pkg._ In my particular case, the class in question implements several interfaces, but that feels like it doesn't make any (or at least no significant) difference here. **I can't decide if this is an acceptable pattern or not. Is it or is it not, and why?**


How do I express subtle relationships in my data?

"A" is related to "B" and "C". How do I show that "B" and "C" might, by this context, be related as well? ### Example: Here are a few headlines about a recent Broadway play:   1. David Mamet's Glengarry Glen Ross, Starring Al Pacino, Opens on Broadway   2. Al Pacino in 'Glengarry Glen Ross': What did the critics think?   3. Al Pacino earns lackluster reviews for Broadway turn   4. Theater Review: Glengarry Glen Ross Is Selling Its Stars Hard   5. Glengarry Glen Ross; Hey, Who Killed the Klieg Lights? ### Problem: Running a fuzzy-string match over these records will establish some relationships, but not others, even though a human reader could pick them out from context in much larger datasets. How do I find the relationship that suggests #3 is related to #4? Both of them can be easily connected to #1, but not to each other. Is there a (Googlable) name for this kind of data or structure? What kind of algorithm am I looking for? ### Goal: Given 1,000 headlines, a system that automatically suggests that these 5 items are all _probably_ about the same thing. To be honest, it's been so long since I've programmed I'm at a loss how to properly articulate this problem. (I don't know what I don't know, if that makes sense). This is a personal project and I'm writing it in Python. Thanks in advance for any help, advice, and pointers!


What is the difference between Microsoft.Web.Helpers and System.Web.Helpers? Did one take the place of the other (same thing, different version/name), or are they separate things. If so, how do they differ? What is the raison d'etre of each, and are there scenarios where you might use both of them?


Would you show your production code to candidates at the interview?

I have seen this happen multiple times: The candidate likes the company, succeeds at the interview. Then comes to work and at the end of the first day he is sure the codebase/project is not what he would like to spend time with. So he leaves quickly. I think that introducing candidates to the codebase at the interview could potentially solve this problem. Maybe even better: mixing this with interview questions like "how would you improve this part of the code?" This way, it would be obvious if the candidate is a "good fit for the codebase". Have you seen this approach applied anywhere? Would you show your own codebase to the candidates at the interview: if they asked/as part of the interview process?


Do you contribute to open-source software?

Recently John Resig (creator of the jQuery library) wrote on his twitter that "When it comes to hiring, I'll take a Github commit log over a resume any day.". As much as I respect that (motivating developers to give back to the community), it also puzzles me, as not all of us have the opportunity to do so, for a number of reasons (family, employer agreements, etc). How would you make a case for the non-contributor developer? Do you think that developers that do not contribute to open-source software are doomed from certain kinds of organizations?


Do you think asking to sign contributor license agreement for a open source project creates a resistance for contributors?

I am working on a open-source project which is backed by an organization. Organization pays a team to make this open-source project. This project will be licensed with GPLv3. We are debating on having a CLA for contributors. Do you think mandating a CLA will reduce the number of contributors? I have observed that people have no issues in signing a CLA when the project is really popular. So do you think CLA will create a resistance to contribute?


If you were the manager of a team of 25 developers, how would you motivate them?

Imagine yourself hired by a new startup backed with few millions coming from venture capitalists. Your mission: `organize the development of the next killer app`. 25 developers is too much to take care of each individually, so **what decision(s) you would make to motivate them?** _I will appreciate any answers from stock options to free cookies ;)_ Of course the trick here (unless you are really a manager of a such startup), is put yourself in the shoes of one of those programmers. EDIT: it's an imaginary context. The purpose of this story is to stimulate your wishes. I want to capture what motivates developers.


When programming: How much time is spend navigating/scrolling and how much typing?

When your programming you often have to go and look at other pieces of code for reference, search for something etc. I'm looking for some numbers on the ratio of time spend actually typing the code(coding) and the time spend going back and forth between other parts of the system, not even counting browsing the internet, reading documentation. Ofcourse this depends on a large number of factors, probably also on your IDE, programming language etc. I just need some rough estimates, or researches on the subject. Background: I want to investigate how much network latency is tolerable for a programmer to work on virtual machines (if any).


Open Source Projects & ITAR/EAR

What's the story on contributing to open source projects with respect to the International Traffic in Arms Regulations (ITAR) or the Export Administration Regulations (EAR)? From how the laws read it seems like just working on open source SW could put you in violation of export control laws. Is there any precedence on this? Has there been any court cases involving this?


Managing large downloadable content on mobile devices

This is a general question of how to best manage large downloadable content on mobile devices. Lets consider a situation whereby a mobile app needs to download a number of very large content items, like HD videos, that are over 500MB but under 2GB. Now, lets assume this content delivery system should be scalable. Would it be a fair assumption that:   * A reputable cloud service would be needed - if so, what is a reliable and cost effective cloud service for mobile devices based on anyone's experience?   * Large content downloads should only be attempted over a wifi connection, so the end user doesn't incur large costs, e.g. when travelling.   * Downloads should carry on in the background if possible, as the user won't want to wait in an app for long periods. If the downloads don't finish, or the OS quits the app, all downloads should carry on when the app is next activated? Are there any other pitfalls anyone may have experienced when managing large content on mobile devices? Thanks.


How to test Java web applications

So far I haven't been testing or learning how to test my java web applications. If you do, what are the tools you need, and is it really necessary to test a web application if doesn't need scaling or it won't be handling big traffics and multi transactions? What things should I test and what approaches should I take to ensure my application works correctly?


algorithm from scientific paper

In my application I want to use a mixture of several algorithms described in some recently published scientific papers. But I have some legal questions. **Q1** If an algorithm was published in a scientific paper, and the authors were affiliated with academia not some private company, can it be protected by a patent at the same time? I read somewhere that it is not possible to obtain a patent for something that was described in details in a publicly available source. **Q2** If I use some algorithm described in a paper do I **have** to give credit in "legal" or "about" sections in my program or is it just voluntary and would be simply nice of me? It is **not** that I don't want to give credit. It is rather that I don't want to reveal what the program is based on internally and would like to hold copy- cats off for as long as possible.


How should one effectively use time at software conferences?

Microsoft (through the Student Insider program) has generously flown me out to Microsoft TechEd North America 2011. It seems like the website suggests that one should just make a schedule of the interesting talks, and that's that. However, it seems like several people don't spend much time in the talks and spend the time "networking" (the people kind, not the software kind) instead. How should one maximize the effectiveness of their time at software conferences?


Why does my employer want a list of my past & present side projects?

I work in Delaware and live in PA. The law in Delaware is clear: My side programming projects are my property and not my employer's, unless I do something on the side that's very similar to the paid work. (See DE code chapter 19 section 805 here: http://codes.lp.findlaw.com/decode/19/8/805). Nevertheless my employer doesn't want to provide me with a piece of paper recognizing my right to my own side projects or even the legitimacy of that DE statute. Still they wanted a list of all my projects before I started, which is perhaps 20 total. Since then I've put out over 10 iOS apps that I wrote in the evenings. What are they up to? What are my options?


Writing algorithm on 2D data set in plain english

I have started an introductory Java class and the material is absolutely _horrendous_ and I have to get excellent grades to be accepted into the master's degree, hence my very beginner question: In my assignment I have to write algorithms (no pseudo-code yet) to solve a board game (Sudoku). Essentially, the notes say that an algorithm is specification of the input(s), the output(s) and the treatments applied to the input to get the output. My question lies on the wording of algorithms because I could probably code it but I can't seem to put it on paper in a coherent way. The game has a 9x9 board and one of the algorithms to write has to find the solution by looking at 3 squares (either horizontal or vertical) and see if one of the three sub-squares match the number you are looking for. If none match then the number you are looking to place is in one of the other 2 set of 3 sub-squares (see image to get a better idea). **Note:** The task is not to write a complete solver. Only an algorithm to solve the particular case I have described. I really can't get my head around how to formulate the solution into the terms described above or maybe it's just too simple, here's what I was thinking: **Input:** A 2-dimensional set of data of size 9 by 9 to be solved and a number to search for. **Ouput:** A 2-dimensional set of data of size 9 by 9 either solved or partially solved. **Treatment:** Scan each set of 3x9 and 9x3 squares. For each line or column of a 3x3 square check if the number matches a line (or column). If it does then move to the next line (or column). If not then proceed to the next 3x3 square in the same line (or column). Rinse and repeat. Does that make sense as an algorithm written in plain english ? I'm not looking for an answer to the algorithm per se but rather on the formulation of algorithms in plain english. ![enter image description here](http://i.stack.imgur.com/LWV1I.png) **Note** : Apparently this isn't clear: this is not about solving for all possible solutions. This is about solving only this very particular set of rules. I did not make the assignment. In any case, this is not even remotely relevant as this is not the focus of my question.


How to deploy a single website to multiple physical servers ?

I want to deploy my website to multiple physical servers. Is there possible methods to save files and setting (and also the user input), on all physical servers, so that servers do the following jobs:   1. Servers used as a network, speeding up the process giving a robust thing to the end user.   2. Data to be stored on all the servers' hard drivers, and   3. Every server have the internet connection from different provider, so for example      1. if any of the internet providers gets down, or     2. there occur any hardware or power failure, the website still runs, without a break and without any data loss. Does anyone know about some online course or some comprehensive tutorials about this topic ?


Is this paragraph in Code Complete 2 backwards, or am I misunderstanding it?

In chapter 13, when talking about pointers, there is a paragraph: > Sometimes, however, you would like to have the semantics of pass by > reference—that is, that the passed object should not be altered—with the > implementation of pass by value—that is, passing the actual object rather > than a copy. It seems like the author made a mistake and mixed the two up. Is this true, or am I not understanding what he's saying correctly?


Is online freelance work viable by American standards?

I've always been curious about trying out online freelance sites... it would be nice to work from home, feel independent, get to choose what I want to work on, get to work on different technologies, lose the PHB, etc. However I never really gave them a chance because I'm used to American rates and assumed that I would be competing with people from India, Russia, China, etc. that would severely undercut me, and it wouldn't be viable for me. Am I correct in this assumption or should I give it a shot? What kind of hourly rate would I be able to expect on short-term programming work?


Standardized Programming Languages

Is there an organization similar to W3C that creates standards for programming languages? If so, are there any programming languages, like browsers would using W3C standards, that implement these standards? I have done my own research and I have been unsuccessful thus far hence the question. The answers and most of the comments so far are very useful but essentially I'm looking for a language or list of languages that have an open and reliable licensing system. I think W3C has been the most successful at this up until now with HTML so I am looking for a language that has a similar licensing structure. Java has certain specifications like the EE servlet specification which has providers like Tomcat implement it but then at the end of the day that is still an Oracle owned standard isn't it?


When should I pass setting-like value as class' variable and when as an assoc. array?

Following my other question, is there a general rule of thumb, when we should pass a setting-like value, that controls class' behavior (for example displayed texts) as as class' constant or variable, one-by-one, and when it is better to "pack" them to one associative array? Or is it just a choice of the developer? For example -- is this approach better (PHP code):               class SomeClass     {         public $errorIncorrectProtocol = 'Please, don't use GET protocol in this context!';         public $errorMissingId = 'The ID can't be empty or equal zero...';     }      than this one:               class SomeClass     {         public $errorMessages = array         (             'IncorrectProtocol'=>'Please, don't use GET protocol in this context!',             'MissingId'=>'The ID can't be empty or equal zero...'         );     }      and if yes -- then, why?


How to use ORM in MVC?

If I want to use ORM in MVC system Which is/are correct?   1. Use ORM object to replace Model   2. Encapsulate ORM inside the Model   3. Use ORM outside the Model, use ORM to access DB, and then use one instance to store one record of data.   4. Other better practise Please give me some example


Design for an interface implementation that provides additional functionality

There is a design problem that I came upon while implementing an interface: Let's say there is a `Device` interface that promises to provide functionalities `PerformA()` and `GetB()`. This interface will be implemented for multiple models of a device. What happens if one model has an additional functionality `CheckC()` which doesn't have equivalents in other implementations? I came up with different solutions, none of which seems to comply with interface design guidelines:   * To add `CheckC()` method to the interface and leave one of its implementations empty:               interface ISomeDevice     {         void PerformA();         int GetB();         bool CheckC();     }          class DeviceModel1 : ISomeDevice     {         public void PerformA() { // do stuff }         public int GetB() { return 1; }         public bool CheckC() {             bool res;             // assign res a value based on some validation             return res;         }     }          class DeviceModel2 : ISomeDevice     {         public void PerformA() { // do stuff }         public int GetB() { return 1; }         public bool CheckC() {             return true; // without checking anything         }     }      This solution seems incorrect as a class implements an interface without **truly** implementing all the demanded methods.   * To leave out `CheckC()` method from the interface and to use explicit cast in order to call it:               interface ISomeDevice     {         void PerformA();         int GetB();     }          class DeviceModel1 : ISomeDevice     {         public void PerformA() { // do stuff }         public int GetB() { return 1; }         public bool CheckC() {             bool res;             // assign res a value based on some validation             return res;         }     }          class DeviceModel2 : ISomeDevice     {         public void PerformA() { // do stuff }         public int GetB() { return 1; }     }          class DeviceManager     {         private ISomeDevice myDevice;         public void ManageDevice(bool newDeviceModel)         {             myDevice = (newDeviceModel) ? new DeviceModel1() : new DeviceModel2();             myDevice.PerformA();             int b = myDevice.GetB();             if (newDeviceModel)             {                 DeviceModel1 newDevice = myDevice as DeviceModel1;                 bool c = newDevice.CheckC();             }         }     }      This solution seems to make the interface inconsistent.   * For the device that supports `CheckC()`: to add the logic of `CheckC()` into the logic of another method that is present in the interface. This solution is not always possible. So, what is the correct design to be used in such cases? Maybe creating an interface should be abandoned altogether in favor of another design?


Do markup languages have the equivalent concept of `semantics` that you can find in C or C++?

Maybe I miss something, but do the so called markup languages have the equivalent concept of `semantics` that you can find in C or C++? Judging from how you parse the language, you don't really have too many options, there isn't too much context, you just parse your tokens and apply them to the source code. I'm tempted to say that not only semantics doesn't exist in this case, but this only happens in markup languages: am I right?


OO Design when using communication

I have 2 applications one is written in C++ and one is written in Java. the applications communicate by passing byte arrays which represent a serialized object. each communication object represent a Command and holds the command id and the associated data. I will use an example to describe my problem. Let's say I have 3 components. one is responsible for the data storage and file system, one is responsible for presenting UI , and one is responsible for security and authorizing users. One way to access a specific component is by having one entry point that will do a switch case on all the possible commands ids. pseudo:                   switch(commandId)     {     case SAVE_FILE:     DATASTORAGE::Save();     break;     case LOAD_FILE:      DATASTORAGE::Load();      break;     case AUTHORIZE:      SECURITY_CONTROLLER::authorize();      break;     case DENY_ACCESS:      SECURITY_CONTROLLER::denyAccess();      ...     }      In this case if I need to change the security controller, I need to change this main entry point. so instead I added an extra field to the communication object, that holds the id of the component that need to process the command. In this case if I want to preform authorize I will do the following:               communicationObject.commandId = AUTHORIZE;     communicationObject.target = SECURITY_CONTROLLER_ID;      And the main will switch case on the possible targets and pass the command id to the specfic component which is responsible for that command.                  switch(target)     {     case SECURITY_CONTROLLER_ID:     SECURITY_CONTROLLER::Process(commandId);     break;     case DATASTORAGE_ID:      DATASTORAGE::Process(commandId);           ...     }      I also don't like this new design since it requires that the sender will know the inner structure of the receiver. on the other hand, if I had direct access to the other application classes (not using byte [] for communication) then the second option will be mapped to something like: SECURITY_CONTROLLER::Authorize(); while the first option will be mapped to something like Main.AUTHORIZE(), which is definitely not the way to go! what is the best approach in this case?


How to design modular "screen configurator" for database application

I am currently working with a product that is effectively a glorified CRUD application. (It is a C# .NET 4.0 desktop application backed by an Oracle 11gR2 database.) The client program presents a list of "screens" that the user can open; each presents a view of some data and a number of buttons used to perform operations on the data. Currently, these screens are configurable to the extent of deciding what data to show on the screen and what each of the buttons should do. However, what I would like to do is to make each control a "module" and allow the user doing the configuration to drag and drop these modules into a wireframe to create a customised screen on-the-fly. For example, I would like a "grid" module (we effectively already have this as a WPF control) such that I could have as many "grids" on a screen as I like, and each could have a different configuration - e.g. what fields are shown, and which fields are editable. Further, each grid could be linked so that selecting an item in one grid would cause related data to load in another grid. How do I approach this design?


Intermittent flickering on mouse move

We have an internal website that is written in javascript and jquery and is only used in with ie8. Everything is fine but after a certain time, screen flickering starts to occur when the mouse transitions between certain elements (which can be annoying for the users). I can't really put any code up because there is quite a lot but I just wondered if anyone might know what initiate this strange problem or have ever had similar issues!?!? The script makes 4 ajax calls on page load which dynamically loads content and is also within an iFrame. I have looked into a few possible sources, i.e, Memory issues/leaks, jquery/modal, timers, iFrames, but I just don't understand why it is not consistent?


How should code in version control be stored? **Developer friendly**? so that programmer can quickly take the latest and able to run from his editor without doing many changes? (like config files pointing to dev DB..etc) or Should it be **production friendly**? source should be in a manner which is easy to deploy on production environment and when developer takes the latest, he should perform changes as per his development needs.


Best approach for a server configuration data collection and reporting solution from a legacy script?

I have a project which involves collecting config data from windows servers in our (very large) server estate. My manager wants me to collect over 150 data items across all configuration areas including network config data, disks, registry values, BIOS version, dll versions, you name it. The server support team currently use a nasty vbScript script which is massive, messy and has been passed around and grown organically over time. The script is currently used to collect the data and produce a very basic flat HTML report with a column for each of the 150+ items it collects data for. My job is to tranform it into a proper software solution with new bells and whistles, a website, reports etc. The idea is a sys admin will go to an intranet website, puts the server name in and presses the go button, the solution collects the data and pushes it into the DB for reporting later. My manager wants the solution to collect the data, some of it referencing known desired values (e.g. RAID card drivers for ABC model servers is at v1.2.5.1) to see if they are correct or up to date, store it in a SQL database, and then use the front end web site for producing reports. In the reports, he wants it to be able to compare two datasets; for example, one for server ABC123 and one for server DEF987 in one report, highlighting any differences between the two. It gets messy pretty quick as some data will be collected for on some servers but not others (domain controllers wont have data collected about exchange services running status). There are many miscellanous items which don't fit into a data model area and don't really have a home ... it's a mess. I'm ok with collecting the data (using .Net), but I'm at a loss as to where the best place is to do such things as store and lookup/compare items to good known values (XML, DB?). Should I do it as part of the data collection phase and then push it into the DB. Or should I marry it all up as part of the reporting data? I'm going with a data warehouse (de-normalised) schema for the DB. There will probably be about 20 tables which the data will need to be pulled from, so I have no real idea what the best way to compare the dataset from one server data collection, with another, with such a massive set of fields to compare. What do you guys think my best options are for approaching this project and the architecure of the solution?


How do you go from intermediate to expert?

Some would say: write a lot of code. That's certaintly true, writing a lot of code has helped me. I seen see the pitfalls. I refactor. I read. I've read countless books and I acknowledge design patterns. However, when it comes to actually using them in real life they escape me. I see code littered with fancy features and elegant solutions and I wonder: gee, why didn't I think of that? How does one go from intermediate to expert? What things should you be reading daily? How can you improve your skill? Your apt for problem solving? Ultimately, how can you bridge the gap from good to great?


Will a copyrighted code get into public domain once its copyright expires?

Since source code license is protected through the Copyright Law (Berne Convention to be precise), and all copyrighted material will be in public domain for certain number of years, depending on which country.   1. Will a copyrighted source code, closed or open source, be in public domain once its copyright expires?   2. For closed source, can I ask the company for the closed source code once it got expired (just assuming based on what I've understood so far :-) )?   3. Assuming question 1 is true, how can I prevent a source code from getting into public domain once the copyright expires, if it's possible?


How can I best manage making open source code releases from my company's confidential research code?

My company (let's call them Acme Technology) has a library of approximately one thousand source files that originally came from its Acme Labs research group, incubated in a development group for a couple years, and has more recently been provided to a handful of customers under non-disclosure. Acme is getting ready to release perhaps 75% of the code to the open source community. The other 25% would be released later, but for now, is either not ready for customer use or contains code related to future innovations they need to keep out of the hands of competitors. The code is presently formatted with #ifdefs that permit the same code base to work with the pre-production platforms that will be available to university researchers and a much wider range of commercial customers once it goes to open source, while at the same time being available for experimentation and prototyping and forward compatibility testing with the future platform. Keeping a single code base is considered essential for the economics (and sanity) of my group who would have a tough time maintaining two copies in parallel. Files in our current base look something like this:               > // Copyright 2012 (C) Acme Technology, All Rights Reserved.     > // Very large, often varied and restrictive copyright license in English and French,     > // sometimes also embedded in make files and shell scripts with varied      > // comment styles.      >      >      >   ... Usual header stuff...     >     > void initTechnologyLibrary() {     >     nuiInterface(on);     > #ifdef  UNDER_RESEARCH     >     holographicVisualization(on);     > #endif     > }      And we would like to convert them to something like:               > // GPL Copyright (C) Acme Technology Labs 2012, Some rights reserved.     > // Acme appreciates your interest in its technology, please contact xyz@acme.com      > // for technical support, and www.acme.com/emergingTech for updates and RSS feed.     >      >   ... Usual header stuff...     >     > void initTechnologyLibrary() {     >     nuiInterface(on);     > }      Is there a tool, parse library, or popular script that can replace the copyright and strip out not just #ifdefs, but variations like #if defined(UNDER_RESEARCH), etc.? The code is presently in Git and would likely be hosted somewhere that uses Git. Would there be a way to safely link repositories together so we can efficiently reintegrate our improvements with the open source versions? Advice about other pitfalls is welcome.


Proxy to redirect DNS during development

I am using Genymotion to test an app. The app is basically a browser that connects to my website. I do not have the app's source. I do the development and testing of the website in a domain like this: dev.mywebsite.com The app connects to mywebsite.com. Genymotion allows me to use an HTTP proxy. My question is, is there any software for windows or linux that would work as a proxy and redirect all requests to mywebsite.com to dev.mywebsite.com ?


When a function is called in Javascript, is there then an easy way to find where a function is declared in?

It would be great if some IDE offered the way to right mouse click when a function is called and have the immediate option to jump to the function when it is defined. Is this possible in Javascript? Maybe I've just been oblivious - is there a name for this technique?


How to implement DDD in a distributed application with NHibernate?

I have an ASP.NET MVC web site working in this way: (In the controller)               var user = _applicationService.GetUserById(1);     user.ChangeEmail("mynemail@somewhere.com");     user.ChangeAddress("my new street", "21");      (In a HttpModule)               void EndRequest(){         if (HttpContext.Error is null){             _sessionFactory.GetCurrentSession.Transaction.Commit();          }      This way is possible because the session factory is built in the web site application start. Is posible to call multiple domain methods and call commit once in the end of the request. But in a distributed application isn't posible to use domain objects directly, instead a WCF service must receive a DTO. Now my question is: how you design the methods `ChangeEmail` and `ChangeAddress` for a distributed scenario? Each one must be a distinct operation in the Web service? If so, then when a user changes his email AND his address must be necesary to call two times to the service. Or instead I must model a web service like this:               var userDTO = _wcfService.GetUserDTOById(1);     userDTO.Email = "mynewemail@somewhere.com";     userDTO.Street = "My new street";     userDTO.StreetNumber = "21";     _wcfService.PersistChanges(userDTO)


What should I think about when switching from Python to Java?

> **Possible Duplicate:**   >  Java dev learning Python: what concepts do I need to wrap my head around? I was a Java developer in the early 2000s, switched to Python in 2008 and now I am working in Java again. How has Java changed since the early 2000s? What are the major updates besides generics? Is there anything special you think I should keep in mind when going back to a Java environment? I used to work with EJB 1.0, I didn't work with EJB 2.0 and now we have JPA instead. I'm comfortable programming in Java and my new job with Java is much better than my Python job even though Python is my favorite language the tools and others things about my Java job makes it much better. I found when I searched jobs that demand for Java developer was much greater than demand for Python programmers - do you have a similar experience?


When to stop writing user stories, and start coding?

When discovering stories for the first sprint, how do you know when to stop writing and move forward? I've asked a few people I know, and basically the response I've gotten is, it depends on the context the project exists in and how timeboxed the overall project is as well. Is there any standard way for knowing when to stop writing user stories, and if so, what is the basis for this, and how does it apply to future sprints?


How do you keep your unit tests working when refactoring?

In another question, it was revealed that one of the pains with TDD is keeping the testing suite in sync with the codebase during and after refactoring. Now, I'm a big fan of refactoring. I'm not going to give it up to do TDD. But I've also experienced the problems of tests written in such a way that minor refactoring leads to lots of test failures. How do you avoid breaking tests when refactoring?   * Do you write the tests 'better'? If so, what should you look for?    * Do you avoid certain types of refactoring?    * Are there test-refactoring tools? **Edit:** I wrote a new question that asked what I meant to ask (but kept this one as an interesting variant).


What is beautiful code?

I often read that developers must write beautiful code, but for a beginner as I am it remains obscure of what is beautiful code and how do you recognize it? The corollary question is: **How to write beautiful code and what are some practical habits to improve your code's quality?** , what should I care about to make the code I write beautiful (and what shoud I learn).


Does connection pooling work fine to execute 60 DB queries to load a page?

We use Linq2Sql in an ASP.NET application. Unfortunately the eager-loading in Linq2Sql isn't as powerful as in Entity Framework, so a lot of the data has to be lazy loaded as needed. Taking connection pooling into account, is it OK for a web page to execute 60 queries to load a page? Executing a single big query probably won't be much better, as those 60 queries will all those connection pooled connections and not open a new connection each time (which I realize is slow). Any thoughts?


How to document business rules

I am wondering what would be the formal and the most commonly practiced method of documenting business rules? Also how do you document the UI specifications of development artifacts (e.g. Documenting form fields and how buttons behave on form, info text .. etc)


Lost my touch with markup, move into new resources or refresh with old?

I haven't touched XHTML/CSS for many months now. I'm no where near efficient coding as I used to be. Creating more complex things is taking me a lot of time lately. What should I do to brush up on my skills? Just work a bunch of tutorials? Go through some old documentation before moving into HTML5 and CSS3?


Parallelism implies concurrency but not the other way round right?

I often read that parallelism and concurrency are different things. Very often the answerers/commenters go as far as writing that they're two entirely different things. Yet in my view they're related but I'd like some clarification on that. For example if I'm on a multi-core CPU and manage to divide the computation into _x_ smaller computation (say using fork/join) each running in its own thread, I'll have a program that is both doing parallel computation (because supposedly at any point in time several threads are going to run on several cores) **and** being concurrent right? While if I'm simply using, say, Java and dealing with UI events and repaints on the Event Dispatch Thread plus running the only thread I created myself, I'll have a program that is concurrent (EDT + GC thread + my main thread etc.) but not parallel. I'd like to know if I'm getting this right and if parallelism (on a "single but multi-cores" system) always implies concurrency or not? Also, are multi-threaded programs running on multi-cores CPU but where the different threads are doing totally different computation considered to be using "parallelism"?


Training a 'replacement', how to enforce standards?

Not sure that this is the right stack exchange site to ask this of, but here goes... **Scope** * * * I work for a small company that employs a few hundred people. The development team for the company is small and works out of visual foxpro. A specific department in the company hired me in as a 'lone gunman' to fix and enhance a pre-existing invoicing system. I've successfully taken an Access application that suffered from a lot of risks and limitations and converted it into a C# application driven off of a SQL server backend. I have recently obtained my undergraduate and am no expert by any means. To help make up for that I've felt that earning microsoft certifications will force me to understand more about .net and how it functions. So, after giving my notice with 9 months in advance, 3 months ago a replacement finally showed up. Their role is to learn what I have been designing to an attempt to **support** the applications designed in **C#**. * * * **The Replacement** Fresh out of college with no real-world work experience, the first instinct for anything involving data was and still is listboxes... any time data is mentioned the list box is the control of choice for the replacement. This has gotten to the point, no matter how many times I discuss other controls, where I've seen 5 listboxes on a single form. Classroom experience was almost all C++ console development. So, an example of where I have concern is in a winforms application: Users need to key Reasons into a table to select from later. Given that I know that a strongly typed data set exists, I can just drag the data source from the toolbox and it would create all of this for me. I realize this is a simple example but using databinding is the key. For the past few months now we have been talking about the strongly typed dataset, how to use it and where it interacts with other controls. Data sets, how they work in relation to binding sources, adapters and data grid views. After handing this project off I expected questions about how to implement these since for me this is the way to do it. What happened next simply floors me: An instance of an adapter from the strongly typed dataset was created in the activate event of the form, a table was created and filled with data. Then, a loop was made to manually add rows to a **listbox** from this table. Finally, a variable was kept to do lookups to figure out what ID the record was for updates if required. How do they modify records you ask? That was my first question too. You won't believe how simple it is, all you do it double click and they type into a **pop-up prompt** the new value to change it to. As a data entry operator, all the modal popups would drive me absolutely insane. The final solution exceeds 100 lines of code that must be maintained. So my concern is that none of this is sinking in... the department is only allowed 20 hours a week of their time. Up until last week, we've only been given 4-5 hours a week if I'm lucky. The past week or so, I've been lucky to get 10. * * * **Question** **WHAT DO I DO?!** I have 4 weeks left until I leave and they fully 'support' this application. I love this job and the opportunity it has given me but it's time for me to spread my wings and find something new. I am in no way, shape or form convinced that they are ready to take over. I do feel that the replacement has the technical ability to 'figure it out' but instead of learning they just write code to do all of this stuff manually. If the replacement wants to code differently in the end, as long as it works I'm fine with that as horrifiying at it looks. However to support what I have designed they **MUST** to understand how it works and how I have used controls and the framework to make 'magic' happen. This project has about 40 forms, a database with over 30 some odd tables, triggers and stored procedures. It relates labor to invoices to contracts to projections... it's not as simple as it was three years ago when I began this project and the department is now in a position where they cannot survive without it. How in the world can I accomplish any of the following?:   * Enforce standards or understanding in constent design when the department manager keeps telling them they can do it however they want to   * Find a way to engage the replacement in active learning of the framework and system design that support must be given for   * Gracefully inform sr. management that 5-9 hours a week is simply not enough time to learn about the department, pre-existing processes, applications that need to be supported AND determine where potential enhancements to the system go... Yes I know this is a wall of text, thanks for reading through me but I simply don't know what I should be doing. For me, this job is a monster of a reference and things would look extremely bad if I left and things fell apart. How do I handle this?


I have to compromise: DRY, or Command-Query-Separation?

I was recently refactoring a method that was both a command and a query method. After separating it into a one command method and one query method, I found that there are now multiple places in the code where I am calling the command then getting the value from the query, which seems like a violation of the DRY principle. But if I were to wrap that common code into a method, that method would be both command and a query. Is this acceptable?


New nodes joining distributed genetic algorithm

I'm sort of torn on what to do for implementation of my distributed genetic algorithm problem. I would like to be able to have nodes join and part at will and not take down the whole system. But this introduces the problem of mismatch of generations. Often times a genetic algorithm simulation is capped by a certain amount of generations and if I have a node that is on 75 out of 100 generations and a brand new node joins the cluster I'm not sure if I should fake it and start at 75 and copy one of the other nodes as a starting point or have it start out at 0 and potentially have the results delayed until the end of execution of the new node. I was hoping someone had some input on what they could see as problems in addition to a long wait time with this new node if I start at 0, I am struggling to think of what could go wrong in both approaches other than that.


Do I have to release source code because I'm using JavaFX?

I'm using JavaFX for gui of my app. Its license is GPL+Linking Exception. GPL requires me to release my source code. But what's the linking exception?? (I'm just using it as a library. Not modifying or using its source code.)


Copyright notices: What if I change my surname? What if someone else has the exact same name?

I'm adding copyright notices to all my source code files:               Copyright (C) 2013 My-First-Name My-Surname        1. But what if someone else is also named _My-First-Name My-Surname_? What does courts think about that? How would they know who is the real author? Is there something I can/should do about this situation? (So they'd know for sure)   2. What if I change my surname. Then, how do other people know that I'm still the copyright holder? Is there something I can/should do, to avoid trouble with copyright, after I've changed my name? **An example** of when the above could be of interest: Someone gets married and change his/her surname and moves to a new address. Then, even if s/he has submitted his/her source code to the U.S. Copyright Office, that was done using his/her old name and address. Now s/he however has a new name and address. But there is perhaps other people that have the old name (but not also the old address). (In my country, for any first + middle + surname, there are usually many people with that full name.) Apparently people think this is a weird question, but I've read about rather many very decisions made in courts, e.g. someone suing for hot coffee and winning millions of dollars.


Specifying the format in which I want to get a response through POST

It's a good practice to let a client specify the format in Web REST API:               GET /api/items/123.csv      However, not only `GET` can return some answer, but `POST` also can do               Status: 201 Created          {       mgs: "Your item has created successfully",       href: "/example.com/items/123"     }      How should `URI` look like for a `POST` (`PUT` or whatever, but not `GET`) request which returns a response so that a client can specify the format they want the response to be in? Like this?:               POST /api/items/.csv       Or suppose there is an error when a client sends a POST request and the server must inform the client about it:               Status: 400 Bad Request     {       mgs: "this is a bad request",       devMessage: "it's bad because ...."       friendlyMessage: "something bad happened..."     }      What format should it respond in, why and how do I specify it as a client? P.S. - I'm aware about REST - Tradeoffs between content negotiation via Accept header versus extensions


Why does java.util.Calendar use static factory methods?

It is considered better to have a separate factory class than having static methods in same class. See this question. But the standard API uses both approaches. Separate factory:               DatatypeFactory.newInstance().newXMLGregorianCalendar(...)      Static methods in same class:               Calendar.getInstance(...)      Why is this? In what case would having static methods be better than having a separate factory?


Contract Programming - Deposit % and Payment Methods? Any advice is appreciated

I'm pretty new to doing contract work and finally landed a decent paying project. The guy actually offered to put down a deposit and I'm just wondering what percentage I should consider asking for. I was thinking around 25% since its not a terribly large project (only about 20 hours). Also, I can't use PayPal (have had a terrible experience with them freezing funds for no good reason) so I'm wondering if anyone can suggest other methods for the client to send the deposit / payment. I want to make it as easy as possible for them.. thanks for any advice


How to unit test without mocks and not be tied to a concrete implementations of an interface

I consider myself to be a 'mockist' on the 'mockist' vs 'classicist' debate, but I am trying to understand the other point of view. Imagine I have this class, where a concrete instance of `IDependency` is injected by an IoC container. `IDependency` does not access a remote resource like a database or web service (in which case I would definately mock it), it is just another class containing some business logic.               public class UnitUnderTest     {         public UnitUnderTest ( IDependency dependency )         {         }     }      Using this pattern, I am free to change the concrete implementation of `IDependency` by changing the class injected by the IoC container. I am not _tied_ to any particular implementation. If I was to test this class without mocking `IDependency`, wouldn't I have to instantiate my _real_ `IDependency` to pass in to the constructor?               public class My_Unit_Test()     {         IDependency concreteDependency = new ConcreteDependency();         var unitUnderTest = new UnitUnderTest(concreteDependency);     }      In this example, if I write a replacement to `ConcreteDependency`, I would have to not only change my IoC container configuration, but all of my unit tests that use `ConcreteDependency`. Or.. do I use the same IoC container within my unit tests (which seems like it goes against the idea of testing things in isolation)?


Keeping documentation / manuals up-to-date in a rapidly changing project

### Background I work on a relatively large project (~570 KLOC) in a relatively small team (formerly 5 developers, now 2). Large amounts of code can appear and then vanish in months; for example, a few years ago an investment bank launched a new stock exchange, then shut it down 7 months later—thousands of LOC were written to support that exchange's interface, then deleted. To help operations and support teams as well as new developers, we have an internal wiki (a modified DokuWiki, if it matters) with things like retrospective specs (we're writing specs as we go, unfortunately) and what various settings, flags, and status codes mean and do. ### Problem Due to the fast pace of development, however, much of our wiki content becomes obsolete in months, if not weeks. And it's not as simple as updating a single wiki section about whatever component is being changed; with numerous interlocking components, changing one thing, like a setting in the algorithmic trading component, might require looking through a hundred references to this setting and/or component in the wiki, many whose sections may need updating. The main issue, I believe, is a motivational one. Developers know that whatever they write has a good chance of becoming obsolete soon, so it's rarely worth it (nor is it practical) to go searching throuh the wiki to update all relevant pieces, especially when 2 or 3 days later there might be a request to change, say, the format of a setting, or even its functionality. This leads to distrust of the wiki—even amongst ourselves, we're never sure whether what we're reading indeed describes the latest functionality. And that, I feel, ultimately feeds a vicious cycle akin to the broken windows theory: the perception of disorder demotivates any action to bring back order. ### Idea My idea was to migrate the wiki to something more like Stack Exchange—for example customizing Question2Answer. For two reasons:   1. I hope that putting all information in Q&A form encourages documentation to be written with the thought in mind, "What question am I trying to answer? Who am I trying to help?" This is unrelated to this post, though.   2. More importantly, my idea is to use tags—a tag for each component, each setting, each business term, etc.—so that it's _easier_ to find _posts_ that need updating, rather than going through every instance of a keyword—and keyword searches are context-less already, on their own. ### Question Before I go through with this idea, though, I thought I might benefit from advice if anyone else has worked in such a context. I'm open to all ideas and alternatives! _How do you keep highly cross-referenced documentation up-to-date in a rapidly changing project?_


LLVM case: is the success due to the algorithms?

I'm not sure if this is a subjective question, I hope not but I'm not proficient with LLVM so I'm just wondering: how come it's become so popular and so widespread used in the industry? Were the optimization algorithms used in gcc/icc/msvc just worse than the LLVM ones? Is it possible that a university project managed to outperform such known and long-standing compilers? I know that LLVM is modular, but can then a design be the cause of that much success? I can't understand the real reasons behind that, this is also probably related to a subjective question like "is the success of a software always related to a new or semi-new algorithm that speeds something up?" but I'd like to get objective reasons to my first question if possible


TFS SQL Deployment Data Script

We are using TFS and SQL Server 2005 (looking to upgrade to SQL Server 2012 if that makes a difference). We store our database schema in a Visual Studio Database project (VS 2010). When code is released to live we currently use the Visual Studio Database Project to build a script for all our schema changes. The problem we have been getting is having to alter or add to that script to add/fix data for the deployment. For example if we add a new non-nullable column to an existing table we need to populate that column with data during the insert. Other times we may want to create new records in transactional tables (e.g. assign specific users to a new security access). Do Visual Studio Database Projects have a way to store these scripts that only need to be run once and somehow include them in the build? Does it know which scripts need to be run (for example if we are inserting default data we don't want to do that again a second time)? OR Is there a better way to manage these scripts?


Patterns to refactor common code in multi-platform software

I have a Django application and a PyQt application that share a lot of code. A big chunk of the PyQt application are copied verbatim from the Django application's views. As this is a game, I have already an engine.py module that I'm sharing among the two applications, but I was wondering how to restructure the middle layer (what in Django corresponds to the largest part of the views minus the return HttpResponse part) into its own component. In the web application the components are those of a classic Django application (with the only exception that I don't make any use of models):   * the game engine   * the url dispatcher   * the template   * the views My PyQt application is divided into:   * the game engine   * the UI definition where I declare the UI components and react to the events (basically this takes the place of the template and the url dispatcher in the Django app)   * the controller where I instantiate the window object and reproduce the methods that map the views in the Django app


I need some help creating a non-binary tree (or some other data structure that will better solve my problem)

I have about ten lists of numbers and some strings. Each list has about <= 30K lines. Each line on a list has a distinct number. I need to build an efficient way of finding all the lines in each list that has the same 'control' number (or key for dB guys) and comparing what is in their string parts. I am writing this in Java. Let me give an actual example of what I am trying to do..... I have ten lists each containing about 30K records. Each record looks like 901234(key)- 1.0987(float)-kadfnfj(Description String)-01/01/01(date) and all lists have similar records some keys may be available in some lists but not guaranteed!.. I want to find a way to search through all lists for one particular key and compare the attendant float value. Due to the size of the lists, i am worried about the memory usage and due to the number of records, I am worried about the efficiency of the data structure used. I have thought about using trees but my brain cells are about burnt now. I need some help.


Are there well-known PowerShell coding conventions?

Are there any well-defined conventions when programming in PowerShell? For example, in scripts which are to be maintained long-term, do we need to:   * Use the real cmdlet name or alias?   * Specify the cmdlet parameter name in full or only partially (`dir -Recurse` versus `dir -r`)   * When specifying string arguments for cmdlets do you enclose them in quotes (`New-Object 'System.Int32'` versus `New-Object System.Int32`   * When writing functions and filters do you specify the types of parameters?   * Do you write cmdlets in the (official) correct case?   * For keywords like `BEGIN...PROCESS...END` do you write them in uppercase only? It seems that MSDN lack coding conventions document for PowerShell, while such document exist for example for C#.


Why Does F# Contain Both Modules and Namespaces?

I've been assuming that F# includes the module keyword in addition to the namespace keyword due to backwards compatibility with OCaml. Is this the only reason for the inclusion of the module keyword or are there other reasons module was included?


What are the PHP web server architecture components and the purpose of each one of them?

Given below is an image of a basic PHP web server architecture: ![PHP web server architecture](http://i.stack.imgur.com/2H0eh.gif) Would someone please explain the several components available and how they interact?   I'm more concerned of how the **PHP Core** operates and relates to the other components, so feel free to elaborate on this point specifically. This Diagram was taken from here.


When to use REST to handle requests vs using AJAX to handle requests

On my web page, if I wish to display dynamic dropdowns (e.g city names based on country selected), I can do it using AJAX. But I can also do it using a REST call. So which should I use? My problem is I really don't get the difference between REST and any other HTTP browser request.(a.k.a a form submit). I have looked at the formal definitions of REST and it seems identical to a HTTP request. So how is REST inherently different from AJAX?


Organization standards for large programs

I'm the only software developer at the company where I work. I was hired straight out of college, and I've been working here for several years. When I started, eveeryone was managing their own data as they saw fit (lots of filing cabinets). Until recently, I've only been tasked with small standalone projects to help with simple workflows. In the beginning of the year I was asked to make a replacement for their HR software. I used SQL Server, Entity Framework, WPF, along with MVVM and Repository/Unit of work patterns. It was a huge hit. I was very happy with how it went, and it was a very solid program. As such, my employer asked me to expand this program into a corporate dashboard that tracks all of their various corporate data domains (People, Salary, Vehicles/Assets, Statistics, etc.) I use integrated authentication, and due to the initial HR build, I can map users to people in positions, so I know who is who when they open the program, and I can show each person a customized dashboard given their work functions. My concern is that I've never worked on such a large project. I'm planning, meeting with end users, developing, documenting, testing and deploying it on my own. I'm part way through the second addition, and I'm seeing that my code is getting disorganized. It's still programmed well, I'm just struggling with the organization of namespaces, classes and the database model. Are there any good guidelines to follow that will help me keep everything straight? As I have it now, I have folders for Data, Repositories/Unit of Work, Views, View Models, XAML Resources and Miscellaneous Utilities. Should I make parent folders for each data domain? Should I make separate EF models per domain instead of the one I have for the entire database? Are there any standards out there for organizing large programs that span multiple data domains? I would appreciate any suggestions.


What tools can be used to facilitate code reviews after commits?

I've been evaluating a number of code review tools (mostly free ones), but they all seem to be aimed at reviewing patches before they are committed. This wouldn't really fit within our workflow with Subversion, so I've been looking for alternatives that better support reviewing committed revisions instead of just diffs. Any recommendations? I would prefer free or inexpensive tools.


Why is C so high in TIOBE index of popularity, while C++ is just under here too, but not as popular?

I can't get my head around this. If C is so much used, but C is not C++, can someone explain to me the most important reasons that makes C more used than C++ ? Where is all this C code written for ? Is this about the industrial sector which heavily rely on imperative programming but can't support the cost of implementing or tuning C++ compilers ? Are there that many kernel hackers ? Is tiobe relevant ? I never stumbled into any article or post commenting or explaining how singular tiobe's ranking is, and what it actually says about what the industry likes, and what it can tell about what the industry actually uses, to pinpoint the industry real needs. It's hard to explain. I just find it odd many companies want C#, php, java jobs, and not C or C++ jobs (just relating my unemployment and my interviews here) even if those C/C++ jobs are crap. I would take those instead. Or does this mean language hype plays a strong role here ?


What is a manifest and when is it appropriate to use one?

I hear the usage of manifests in various ways but never have had the need—to my knowledge—to use one. What are they and how are they used? EDIT: I'm curious about manifests in general with any language.


Why should I use the function migration in codeigniter?

What is wrong with using database tables with phpmyadmin or mysql? What are the benefits, if I'll use 'migration'?


Can we create a program that writes out its source code?

Can we create a program that print out its source code what if we (or the program itself) compile than the new program would have the **same exact functionality** what the original program has? So somehow it would reproduce himself in perfect clones that can reproduce too.   The program **shouldn't use any external files** othervise it would be realy easy to implement: we just need to create a program that reads a file than writes it out, than copy and paste the source code to the external file.   My first attempt was to write a program that has a print function than copy- paste the source code to this print function, but this program can reproduce himeself for only once, and doesn't have the same functionality because the second program cant print out the source code.


Why should you prevent a search engine from indexing your development server?

I've heard that you shouldn't let search engines index your development server. The reasons given were:   * Duplicate content penalties   * Customers making purchases from an unsecured domain (if eCommerce) These issues may seem relatively minor and I'm not sure it would be enough to convince someone to put in the effort to lock down the server. Aren't there broader security concerns? What should be secured and why?


C: What is a good source to teach standard/basic code conventions to someone newly learning the language?

I'm tutoring someone who can be described as a rank newcomer in C. Understandably, she does not know much about coding conventions generally practiced, and hence all her programs tend to use single letter vars, mismatched spacing/indentation and the like, making it very difficult to read/debug her endeavors. My question is, is there a link/set of guidelines and examples which she can use for adopting basic code conventions ? It should not be too arcane as to scare her off, yet inclusive enough to have the basics covered (so that no one woulc wince looking at the code). Any suggestions ?