Extending database model of ORM in subproject

I have a maven project which contains some entities which are stored in a database. The purpose of this project is to manage personal information, users, locations, etc. This project can work on its own. I also have a project which depends on the first which imports data into the database. But it's more than a simple import so it needs additional information to these entities. This information is only needed if it's imported data otherwise it is not set. ## The problem The problem is that I don't know how to "attach" this information to the entities in the first project without declaring them there. It wouldn't make sense to declare them there because the y don't belong there and it would just mix two domains. Putting both projects into one is not an option either because both are already big and still growing. ## Approach to the problem One approach I was thinking of is to use another entity which contains all information needed in the importer project and associate it with the original entity. This would almost work but it would create a terrible database model which I would never create if I wouldn't use an ORM. I'm starting to think if I even should use a ORM because of the ORM I use (Hibernate) I also had to make several changes of the design to the worse just because the ORM doesn't support it (using the Null Object Pattern or Interface segregation principle, for example).


Menu building pattern

I'm having troubles getting my head around the active-state handling of a menu when the menu isn't used for routing. I come from Drupal where the menu system handles the routing as well. so setting active state and active-trail state is handled by the route (that acts as a menu rendereing system aswell). Now, a lot of PHP frameworks have Router classes that handle the routing. This seems a good seperation since a Menu should not be aware of POST || OPTIONS || ... requests. But when writing the frontend, I found myself hardcoding the menu. Or storing everything in the DB and passing those values to a view. What I don't like of this approach is that you are kind of creating a copy of what you allready wrote in your Router but now using the Menu class. An example:               Route::get('/somewhere','routename.somewhere','showStuffController');     Route::post('/somewhere','routename.somewhere','saveStuffController');          Menu::add('label.somewhere','routename.somewhere');      You are seperating concerns here, so that is nice. But Menu depends heavily in Route to set it's active state. Menu will also have to know about hierarchy to set active-trail. So yes, setting active trail, and active status classes is actually a view thing. But having               if ( Route::currentName() === $menuitem->getRouteName() ) { print 'active'; }      allover your views seems stupid. Then add all those noying active-trail if's and its a real bloat. Handling that before the view get renders and setting a active-trail flag to true just seems so ugly the way I do it know (a foreach looping over all children that loop over all children, ...) My question is: Is there a pattern or a smart way to get this cleaner, better, ... ? How should one handle the active-trail 'problem'? I was thinking of rendering child -> parent. So start of ad the deepest level and then work my way up. But then the child knows about it's parent but the parent knows nothing about his children (seems weird).


Why do we need to serialize data using a serialization framework e.g. avro

In this book, the author is using avro to serialize data before it is being processed by pig. What I don't understand is, why we need to do it using a serialization framework like avro? Why don't we just use json as the serialization data format? This way we can just use serializer/deserializer library in a language e.g. `data.json` in clojure.


From Delphi to C# for Dummies

I'm a Delphi and C# coder and have been given the assignment to introduce the most fundamental concepts of .Net/C# to my coworkers in some trainings. They are seasoned Delphi Win32 coders but still use an fairly old version, so they aren't familiar with some language features which are commonplace today like generics and they never used .Net before. Now I'm thinking about the best way to tackle this. Which are the most predominant topics I should cover? I will have maybe 1-2 days for this so I can't delve into specifics too far but have to give them a good birds eye view especially of the features that will matter to them. I plan to emphasize the differences to Delphi, I think this will help them. I'd like to build a small Zoo-application and add something to it for every step I explain. So they can have a look at the created examples later whenever they want. My topics so far:   * Short introduction of .Net, CLI, CLR   * Short introduction of Visual Studio   * Showing class/object equivalents, inheritance, creating some objects Animal->Cat->Tiger, explaining Namespace on the way   * Garbage Collection and Interfaces (very different from Delphi), Bird gets ICanFly   * Events / Delegates (short multicast example), Ape calls all other apes because he found a bunch of bananas or something like that   * Generics, creating generic animal list   * LINQ, query animals by categories   * Parallel Task Libary, the same but this time multithreaded Some topics I'm not sure I should include:   * Attributes   * Operator Overloading   * Anonymous Methods / Lambdas   * Nullable Types   * Reflection   * P/Invoke Maybe this should be delayed to a second session, maybe its too much for the beginning, I'm not sure. I'm also undecided if I should include the coming asynchrony functionality in .Net 4.5. Maybe this is premature. Then I will have to introduce WPF but I think this should be a question for itself.


Should every front-end developer understand the basic aspects of design?

I'd say that we're developing software in a world where the front-end of an application is probably the most important. The increasing ability for a user to access and interact with software almost instantly in the cloud is making the first few minutes of user interaction crucial in determining whether the application will get any further attention, making UI design and the "intuitiveness" of the application extremely important factors. As a developer, I've never really appreciated the important of the design of my applications. I usually write the code that works, and take advice from either a graphics designer or project leader on ways to improve the usability / look of the app. But maybe this isn't the way to develop any more. I can't help but wonder the time and resources wasted on a developer being told by a graphics designer to move a button 2 pixels to the left (for example) when, if that developer had a basic understanding of software front-end design, they'd be able to make the decision themselves. I can understand large design decisions, such as the overall look of an application and the global fonts used etc, are all jobs that should be done by someone with the appropriate knowledge of such an arena, but should we, as the developers of the front-end, know enough of design theory to be able to make smaller design decisions by ourselves?   * Should the front-end design of software and some basics of user interaction be taught alongside the current programming package?    * What level of knowledge should a developer expect to have in regards to user interaction & design?   * Should an understanding of design hold a higher ground than it does at present in the context of resumés and qualifications? The subject is somewhat of a hobby for me, I find it fascinating studying users' interaction with a program, but it should it be part of the core of software development? Just to clarify, when I talk about "design" I'm talking about front-end design, rather than the design of the software architecture (something which every developer should understand).


Auto Create VM and display IE

I have just acciquired an old Dell Poweredge SC1425 from an old friend, this server will act as a development box for web based applications. All has been going well, I have installed the following packages onto the system. **Packages**   1. Apache2   2. PHP5 (including MCrypt & PHP5-JSON)   3. MySQL   4. SSH Server & Client   5. Git & Subversion   6. SFTP Server   7. VirtualBox   8. Node.JS   9. Python   10. Buildlibs (g++, build essentials, fakeroot, make, checkinstall)   11. WebMin   12. Samba The server is running Debian 7 64bit with the included packages above, I have setup some virtual machines (Windows XP & Windows 7) and what I would like to do is when the user starts the VM I want the OS to start Internet Explorer automatically. The reason why is so that i can test my web based applications on older OS's and browsers. After the user has finished with the box or mistakenly left it switch on for X amount of time, I would like the VM to shutdown automatically and also wipe any data which was added during that session. Am not sure if what I am asking can be done so I thought I would ask.


How to Think like a computer Scientist. Chapter 3, Question 2

http://interactivepython.org/runestone/static/thinkcspy/PythonTurtle/helloturtle.html I'm stuck on question 3. Give three attributes of your cellphone object. Give three methods of your cellphone. This is just a intro question. We haven't created a cellphone class, so I don't know how to instantiate a cellphone object yet (Is this the right lingo?). Can someone help me with what are looking for? How do I find the properties and methods of the cellphone object? Is the question just asking for possible future properties of my cellphone? Is it just assuming that I will create some code that will allow me to change the properties of my phone? So all I need to do is list 3 properties of my cellphone like color, brand, and length? Is that it? Oh, and possible methods would be cell number dial, web browser address, and address book addition? Is that it? If so, please upvote this so I can ask questions again in stackexchange.


Why can't arrays be passed as function arguments in C?

Following this comment, I've tried to google why, but my google-fu failed. Comment from link: > [...] But the important thing is that arrays and pointers are different > things in C. > > Assuming you're not using any compiler extensions, you can't generally pass > an array itself to a function, but you can pass a pointer, and index a > pointer as if it were an array. > > You're effectively complaining that pointers have no length attached. You > should be complaining that arrays can't be passed as function arguments, or > that arrays degrade to pointers implicitly.


What is a typical team size for a complex half million lines-of-code C# desktop application?

Imagine the following scenario:   * Codebase of 600,000 lines of code (C#)   * All in a single desktop application   * All written by a single developer (myself) over 8 years (3 years worth of actual coding time).   * The software is powerful and flexible (obviously vague), thus there is inherent complexity in the code, even if it is modular and low in debt.   * The software is in a niche machine control industry, so there is a very long ramp up for domain knowledge of both the machines, and the code.   * The software will become more and more custom where individual customers get their own addons and enhancements What would be a recommended software team size for a half million line codebase (C# desktop) like the one above? What would be ideal for a typical 500k LOC C# desktop application? This software is not 'end to end' lifecycle. It is 'end to infinity' meaning it will continue to grow and get bigger and and more powerful and complex. Especially as more engineers are added to the team.


Could a reflog replace tags for bookkeeping?

My repository has a branch `production` and is filled with countless tags of the format `production-20130101-1234` that point to what has been actually shipped on the given datetime. I think this solution is somewhat messy and unwieldy and I wonder if reflogs would skip in here better. The objective is **"make sure you can always find out what version has been deployed and when exactly"**. Tags do the job, but reflogs sound even nicer because:   * They are made automatically,   * They allow a good amount of awesome, like in the form of `git checkout origin/production@{3 months ago}`. That said, I don't know that much about reflogs and I'm not sure about possible downsides of such approach.   1. I assume `origin/production` has its own reflog totally independent of my local remote-tracking `production` \- is that correct?   2. Doing 3 consecutive no-ff merges from an integration branch to my local `production` branch would make 3 entries in my local reflog, but pushing it to the central repo (as a part of the deployment procedure) would make 1 new entry in the "oracle" `origin/production` reflog, correct?   **I'd like to maintain the "1 deployment = 1 record" invariant.**   3. How to make sure a reflog of `origin/production` isn't pruned and continues to provide complete historical information for everyone?   4. Any downsides or possible problems I didn't think of?


Contract Based Programming vs Unit Test

I am a somewhat defensive programmer and a big fan of Microsofts Code Contracts. Now I cannot always use C# and in most languages the only tool I have is assertions. So I usually end up with code like this:               class     {                function()         {                 checkInvariants();              assert(/* requirement */);                   try              {                  /* implementation */              }              catch(...)              {                   assert(/* exceptional ensures */);                                }              finally              {                   assert(/* ensures */);                   checkInvariants();              }         }              void checkInvariants()         {              assert(/* invariant */);         }     }      However, this paradigm (or whatever you would call it) leads to a lot of code cluttering. I have started to wonder if it is really worth the effort and whether proper unit test would already cover this?


Compiler doesn't inline anything?

I've rolled my own _SIMD_ -accelerated math library. It's gotten pretty complete, so naturally I went to conduct speed tests and optimize it. Btw this isn't premature optimization, the lib is actually complete in functionality, I really need it to be fast now. So anyway, I'm testing some vector dot product methods against the ones in Microsoft's DirectXMath. The difference between my vectors and the ones in DirectXMath is, that in DirectXMath XMVECTOR is just a naked __m128, while mine is a __m128 inside a vector_simd class that is 16 byte aligned and with an aligned allocator. Now one would assume that with all possible optimizations enabled in release mode they would compile to the same thing. I mean `int a;` and `int arr[1];` compile to the same thing in release mode, just like my array template class has the same performance as a raw array and so on... but to my surprise my class's methods came up _2 times_ slower. I even tried just pasting the SSE code from DirectXMath into my class's method, it still came out slower. So the only thing left was the difference that one is a class and the other is raw. It seemed for a while that the overhead of accessing it as a class member and/or the extra overhead from the constructor (which is empty...). However I put all the definitions of my vector class methods in it's header and still it came up 2x slower than DirectXMath. Maybe the overhead comes from the __m128 being a class member? I don't understand why the compiler can't optimize that away, it's like having a struct with a single integer in it?Has anyone else had such issues? **EDIT:** OK, so it seems that my vector_simd class is 32 bytes, while __m128 is only 16 bytes, which is strange. When I removed the 16-byte alignment from my class it also became 16 bytes large. But this makes no sense, aligning a 16-byte class to 16 bytes should make it remain 16 bytes....


What's the best Git workflow for working with an open source project with employer-specific changes?

At my current employer, we are using an open-source project hosted on Github as a component of our application. I have been working on this project to both add some features that we need and to integrate it with our build systems. My manager and I are in agreement that we would like to submit as much of our work on this component as is reasonable back to the open-source project. My question is about what the best workflow/technique is to maintain my Git commits in such a way that I can easily seperate out things that make sense to add back to the open-source project - bug fixes and new features that are sufficiently general - from things that are specific to our project, like build locations and application constants. What I have been doing so far is to maintain a private Git branch where I commit all of my changes, with appropriate granularity. I then use `cherry- pick` to add the open-sourceable commits to the master branch, and submit those back to Github. It seems like I ought to be using merge to do this, so that I don't keep creating separate commits with identical contents, but I'm not sure how to do this while excluding the company-specific commits and keeping a reasonable workflow. For example, I suppose I could commit open-sourceable things on master and company-specific things on the private branch, and then merge master into that branch as needed, leaving the master branch pointing at the commit before the merge, such that I could commit open-sourceable things to it again and then merge again. What seems awkward about this workflow is that I would need to decide in advance for everything I do which branch it belonged on, work on that to what seemed like completion, then commit it and merge before testing. One of the things that I really like about Git is how easy it is to just do whatever you need to make your application work, and then decide later how and where to commit your changes. As far as I can tell, if you're currently on a branch and have some work done, there's no easy way to just submit some of that work to another branch, since changing to that branch would require a clean working directory. Is what I'm doing a reasonable workflow for long-term contributions? Can anybody recommend a different workflow that might be better, and why it's better?


Doesn't dockerfile initial configuration defeat one of the key arguments of docker?

I'm very excited about Docker, if you're a developer in a big project you've suffered too much at the _machine_ hands of environments and multi-platforms. One of the key selling points of Docker is that by snapshotting/committing image state you avoid the risk of building an environment with a different version, possibly incompatible, of a given dependency. I get that, great! Doing the tutorials on dockerfile, isn't this exactly the same concept as running `npm`, `chef` or `bower`. Of course unix libraries would be more stable than most of the ones found on these library stores I just mentioned but isn't this the same workflow that docker is fighting? Isn't the goal to tailor a container to your needs and then commit it's state to then multiply at will? Am I missing something trivial, or this is the case? Does docker still gives you a chance for building up images from script files and by that it steps on it's toes?


DDD, creating an aggreagate from outside the application service layer

I have a service(webservice) that is used to access to the domain logic. One of the methods of the webservice is createFoo, where Foo is my aggregate. So the class that implements the webservice's method calls my application service that contains the createFoo method which is responsible of doing some stuff and persisting the new Foo instance. This new Foo instance the is returned by the application service to the class that implements the web service's method. Finally, the Foo instance is converted to something like FooWsResponse and then the web service returns the FooWsResponse instance. Right now all this is more or less implemented like this:               public class CreateFooService{              private FooService appService;              private Converter<Foo, FooWsResponse> converter;              public FooWsResponse createFoo(CreateFooParams params){             Foo foo = FooFactory.createFoo(params);             foo = appService.createFoo(foo);             return converter.converter(foo);         }     }      The problem with the code above is that the Application Service method is misleading because is not creating a Foo instance, is only working on the domain logic associated to the creation of Foo and persisting the instance. So, the things that I want to know are:   1. Is it ok create the aggregate outside the service layer?. I know that I can pass the CreateFooParams as parameter appService.createFoo but I don't want to do this because my service layer will be coupled to the web service framework. Also, I don't want to pass all the properties of the class CreateFooParams as parameters of appService.createFoo because I will end with a method with 15 parameters!. Finally, creating the Foo instance before calling appService.createFoo method but now the method's name is not accurate and also all clients of my appService should need to create how to create an instance of Foo to pass it as parameter of appService.createFoo which is very bad and may lead to many issues.   2. Should I create a FooDto that receives all the data of CreateFooParams and pass it to appService.createFoo method?. This looks like a better option but having 3 different classes with almost the same properties feels very redundant I want to know what is the right thing to do according to the DDD guidelines. Thanks for your help.


Is "call and return" a pattern or an antipattern?

Imagine to have this code:               class Foo:       def __init__(self, active):         self.active = active       def doAction(self):         if not self.active:           return           # do something          f=Foo(false)     f.doAction() # does nothing      This is a nice code; I actually have (not in Python) a global active variable called "dosomething" and a routine called "something," where the first thing happening inside the "something" routine is `if not dosomething return`. An alternative implementation would call to a routine that always performs an action, and the flag is checked at invocation time, as in the following code:               class Foo:       def doAction(self):         # do something          doaction = False          f=Foo()     if doaction:       f.doAction()      What is your opinion on this? I personally find that the first solution violates the least surprise principle: The caller is invoking an action which is never performed in response to a status which has been set somewhere else, but from the code it looks like the action is performed. Would you consider it a total pattern, a total antipattern, or just an option with no strong opinion for or against it?


Standard survey questions for gauging job satisfaction

Are there any standard surveys or questions that are useful for gauging software engineer or programmer job satisfaction? I hypothesize that determining software engineers' attitudes toward their jobs can reveal problems within an organization. I'm thinking about questions such as the following:   * Are you reaching your full potential?   * Are you learning or improving skills that you could put on a resume?   * Are your skills valued within the company?   * Are your skills utilized?   * Is your voice heard?   * Do you have a mentor?   * Are you satisfied with your supervisor's leadership?   * Are you able to experiment and try new ideas? Obviously the questions would need to be tweaked to get useful answers from a survey.


How common is string manipulation, really?

I've noticed a lot of programming introductions (almost any language) usually include a heavy barrage of string manipulation quite early, such as:   * Count the number of "xx" in the given string. We'll say that overlapping is allowed, so "xxx" contains 2 "xx".   * Reverse the given string and remove all vowels from it.  Not just online courses, but even in degree programmes. But the thing is, I've never encountered a situation in "real life" where you had to do anything like that. Is it just luck, or do you really need to do heavy manipulation in the above manner in some fields of programming? Can you give a description or an example where it is needed? Edit:   Just to clarify, not necessarily string processing itself as in echoing variables to a html template, or other basic stuff like that, but the more arcane type of processing, like reading every second character? But yes, perhaps it is just for training purposes instead of direct needs. The file format conversion is a good note, though.


In a module-core program, how should modules interact with each other?

Short background: I'm using MEF/C# for developing a program that has one core (singleton) and multiple MEF parts (I call them modules, each module is a separate assembly with one class that contains the MEF export). The core imports all parts that are needed/available and initializes them (makes them read their configuration files, that stuff happens in the constructors, business as usual) Now, my problem is that I need modules to interact with each other (say, module A, a graphical user interface, needs to get some data from a database, it'd need to somehow call a function on the database module (module B).) How'd I do that? Sure, I could just make those parts/modules public in my core, add a reference to the core in my module and be done with it, but somehow, that'd feel ugly/bad. (mainly because I've security concerns over such an implementation, everyone could just call that function, unless I use something like this, but still it doesn't feel right). Another approach would be to put all of those functions into the core, where they just call the corresponding function of the module. That feels bad, too because I'd have to add a lot of stuff to my core and in some cases that'd be something that a potential customer won't ever use because he doesn't need/have the specific module. Does anyone know a better method of doing this? Maybe my train of thought went completely wrong somewhere?


Can I use the code created by another agency when working for a client?

Let's assume that my client ( _C_ ) has a corporate website, created by an agency ( _A_ ). _A_ created a pretty simple, yet well designed website which uses plain HTML and no backend to edit any of the data. _C_ has to issue (and of course pay) _A_ every time they want any changes to their website which has become pretty expensive. Now _C_ asks _Me_ to write a dynamic module that integrates into the existing website. This module should be an event-planner that enables _C_ to change at least that part of the website on his own. I am a little bit worried whether it is ok for me to simply take some of _A_ 's graphics and HTML/CSS to use on my project (since I need the new module to be a part of the website). Is there any legal stuff to be considered? Who's property is the already existing website? Can one make a general assumption at all or is this something that necessarily needs to be issued in a contract?


What design patterns are the worst or most narrowly defined?

For every programming project, Managers with past programming experience try to shine when they recommend some design patterns for your project. I like design patterns when they make sense or if you need a scalbale solution. I've used Proxies, Observers and Command patterns in a positive way for example, and do so every day. But I'm really hesitant to use say a Factory pattern if there's only one way to create an object, as a factory might make it all easier in the future, but complicates the code and is pure overhead. _So, my question is in respect to my future career and my answer to manager types throwing random pattern-names around:_ Which design patterns did you use, that threw you back overall? **Which are the worst design patterns** , that you shouldn't have a look at if it's not that only single situation where it makes sense (read: which design patterns are very narrowly defined)? (It's like I was looking for the negative reviews of an overall good product of amazon to see what bugged people most in using design patterns). And I'm not talking about Anti-Patterns here, but about Patterns that are usually thought of as "good" patterns. **Edit:** As some answered, the problem is most often that patterns are not "bad" but "used wrong". If you know patterns, that are often misused or even difficult to use, they would also fit as an answer.


Should Version Control Softwares be used from Command Line or GUI

I was going through some tutorials on TortoiseHg. Despite having a rich GUI, the first examples are given using command line options. Does the ideal usage involve command line or it was started that way so one has idea of what is happening under the hood and GUI internally uses this command anyway.


Separation of concerns: Whose concern is this?

My senior reviewer colleague wants me to do the following. We have (on iOS, iPhone) a hierarchy of views in one of our screens. There is a simple rectangle that represents a Business card of a person (visually matches business cards style). As this card is reused many times in many screens, I have written a custom class called `PFXBusinessCard` that has four labels, each label representing person's data like Name, Phone number, account and email. These four labels are exposed as properties of that custom class. In my controller, I am passing the data for a particular label in a following manner. I get the person, read the particular value for a property and set this property in a controller. That is, I am setting the name, phone number etc.. But my colleague says I should instead handle this inside the `PFXBusinessCard` class. I should create a `populateWithPersonsData` method in the class, and I would just pass a person to the card in my controller. The card would then populate its labels itself. Is this approach ok? Why would the card should know about the person? The UI object should not know anything about the data. Should it?


Be liberal in what you accept... or not?

_[Disclaimer: this question is subjective, but I would prefer getting answers backed by facts and/or reflexions]_ I think everyone knows about the Robustness Principle, usually summed up by Postel's Law: > Be conservative in what you send; be liberal in what you accept. I would agree that for the design of a widespread communication protocol this may make sense (with the goal of allowing easy extension), however I have always thought that its application to HTML / CSS was a total failure, each browser implementing its own silent tweak detection / behavior, making it near impossible to obtain a consistent rendering across multiple browsers. I do notice though that there the RFC of the TCP protocol deems "Silent Failure" acceptable unless otherwise specified... which is an interesting behavior, to say the least. There are other examples of the application of this principle throughout the software trade that regularly pop up because they have bitten developpers, from the top off my head:   * Javascript semi-colon insertion   * C (silent) builtin conversions (which would not be so bad if it did not truncated...) and there are tools to help implement "smart" behavior:   * name matching phonetic algorithms (Double Metaphone)   * string distances algorithms (Levenshtein distance) However I find that this approach, while it may be helpful when dealing with non-technical users or to help users in the process of error recovery, has some drawbacks when applied to the design of library/classes interface:   * it is somewhat subjective whether the algorithm guesses "right", and thus it may go against the Principle of Least Astonishment   * it makes the implementation more difficult, thus more chances to introduce bugs (violation of YAGNI ?)   * it makes the behavior more susceptible to change, as any modification of the "guess" routine may break old programs, nearly excluding refactoring possibilities... from the start! And this is what led me to the following question: When designing an interface (library, class, message), do you lean toward the robustness principle or not ? I myself tend to be quite strict, using extensive input validation on my interfaces, and I was wondering if I was perhaps too strict.


Which web framework to use under Backbonejs?

For a previous project, I was using Backbonejs alongside Django, but I found out that I didn't use many features from Django. So, I am looking for a lighter framework to use underneath a Backbonejs web app. I never used Django built in templates. When I did, it was to set up the initial index page, but that's all. I did use the user management system that Django provided. I used the models.py, but never views.py. I used urls.py to set up which template the user would hit upon visiting the site. I noticed that the two features that I used most from Django was South and Tastypie, and they aren't even included with Django. Particularly, django-tastypie made it easy for me to link up my frontend models to my backend models. It made it easy to JSONify my front end models and send them to Tastypie. Although, I found myself overriding a lot of tastypie's methods for GET, PUT, POST requests, so it became useless. South made it easy to migrate new changes to the database. Although, I had so much trouble with South. Is there a framework with an easier way of handling database modifications than using South? When using South with multiple people, we had the worse time keeping our databases synced. When someone added a new table and pushed their migration to git, the other two people would spend days trying to use South's automatic migration, but it never worked. I liked how Rails had a manual way of migrating databases. Even though I used Tastypie and South a lot, I found myself not actually liking them because I ended up overriding most Tastypie methods for each Resource, and I also had the worst trouble migrating new tables and columns with South. So, I would like a framework that makes that process easier. Part of my problem was that they are too "magical". Which framework should I use? Nodejs or a lighter Python framework? Which works best with my above criteria?


Why are zero-based arrays the norm?

A question asked here reminded me of a discussion I had with a fellow programmer. He argued that zero-based arrays should be replaced with one-based arrays since arrays being zero-based is an implementation detail that originates from the way arrays and pointers and computer hardware work, but these sort of stuff should not be reflected in higher level languages. Now I am not really good at debating so I couldn't really offer any good reasons to stick with zero-based arrays other than they sort of feel like more appropriate. Why _is_ zero the common starting point for arrays?


Is it necessary to start variable from zero (var i = 0 ) of ' for loop '?

Is it necessary to start variable from zero (`var i = 0`) of any looping ? When should I use `var i = 1;` and when `var i =0;`?


Why is first column of list called 0th in so many languages?

If you want first element of list or array you reference it as 0 in many languages (like C or Clojure). Is there are some really good reasons why the programming languages was design this way? In old days in assembly languages it makes perfect sense because all possible values needs to be used. But what are nowadays to keep it this way? There is very little advantage when modulo arithmetic and ranges (Wikipedia article.) but not much more. On a disadvantages side it should be: It makes confusion because it human language the first is connected with 1 (1st and it is not in english only). It makes confusion even in XPath (W3School:"Note: In IE 5,6,7,8,9 first node is[0], but according to W3C, it is [1]."). There are troubles between languages who use 1-based and 0-based system. Want to know hat are the good reasons to use zero-based numbering and why even creator of new languages (like Clojure) choose this way?


"static" as a semantic clue about statelessness?

this might be a little philosophical but I hope someone can help me find a good way to think about this. I've recently undertaken a refactoring of a medium sized project in Java to go back and add unit tests. When I realized what a pain it was to mock singletons and statics, I finally "got" what I've been reading about them all this time. (I'm one of those people that needs to learn from experience. Oh well.) So, now that I'm using Spring to create the objects and wire them around, I'm getting rid of `static` keywords left and right. (If I could potentially want to mock it, it's not really static in the same sense that Math.abs() is, right?) The thing is, I had gotten into the habit of using `static` to denote that a method didn't rely on any object state. For example:               //Before     import com.thirdparty.ThirdPartyLibrary.Thingy;     public class ThirdPartyLibraryWrapper {         public static Thingy newThingy(InputType input) {              new Thingy.Builder().withInput(input).alwaysFrobnicate().build();         }     }          //called as...     ThirdPartyLibraryWrapper.newThingy(input);                    //After     public class ThirdPartyFactory {         public Thingy newThingy(InputType input) {              new Thingy.Builder().withInput(input).alwaysFrobnicate().build();         }     }          //called as...     thirdPartyFactoryInstance.newThingy(input);      So, here's where it gets touchy-feely. I liked the old way because the capital letter told me that, just like Math.sin(x), ThirdPartyLibraryWrapper.newThingy(x) did the same thing the same way every time. There's no object state to change how the object does what I'm asking it to do. Here are some possible answers I'm considering.   * Nobody else feels this way so there's something wrong with me. Maybe I just haven't really internalized the OO way of doing things! Maybe I'm writing in Java but thinking in FORTRAN or somesuch. (Which would be impressive since I've never written FORTRAN.)    * Maybe I'm using staticness as a sort of proxy for immutability for the purposes of reasoning about code. That being said, what clues _should_ I have in my code for someone coming along to maintain it to know what's stateful and what's not?   * Perhaps this should just come for free if I choose good object metaphors? e.g. `thingyWrapper` doesn't sound like it has state indepdent of the wrapped `Thingy` which may itself be mutable. Similarly, a `thingyFactory` sounds like it should be immutable but could have different strategies that are chosen among at creation.  I hope I've been clear and thanks in advance for your advice!


Documenting a REST interface with a flowchart

Does anybody have suggestions on creating a flowchart representation of a REST-style web interface? In the interest of supplying thorough documentation to co-developers, I've been toying around in dia modeling the interface for modifying and generating a product resource: ![enter image description here](http://i.stack.imgur.com/tSwye.png) This particular system begins to act differently with user authentication/resource counts, so before I make modifications, I'm looking for some clarification:   * Complexity: how would you simplify the overall structure to make this easier to read?   * Display Symbol: is this appropriate for representing a page?   * Manual Operation Symbol: is this appropriate for representing a user action like a button click? Any other suggestions would be greatly appreciated. My apologies for the re-post. The main stackexchange site suggested this question was better presented on programmers.


Is kick-starting myself into the programming world by reading from a book about VS 2008 & .NET 3.5 a bad idea?

Basically what the title says. I'm completely new to programming and decided C# to be the best language to start learning, so I went ahead and installed Visual Studio Express 2010 C# to get started. I started reading Learning C# 3.0: Master the fundamentals of C# 3.0 and got worried when I got to the part, which to quote said: > "Unless we specifically say otherwise, when we refer to C# in this book, we > mean C# 3.0; when we refer to .NET, we mean the .NET 3.5 Framework; and when > we refer to Visual Studio, we mean Visual Studio 2008." Does this mean that the book is out-dated and I should find something else? Does this mean I should just read the book anyway and continue in Visual Studio 2010? Does this mean I should uninstall 2010, and get VS 2008, and continue reading? I don't want to learn something that is outdated, and I'm aware of .NET 4.0 being available so I'm not sure if it would be a waste of time. I don't even know if there is a difference, does it just add more features and one could still use the same "basic" code in each? Sorry for being a clueless, I have never programmed before, I just need a kick-start in the right direction so I can start LEARNING just don't want to do so in the wrong way :)


Efficient way to create a code estimation/technical specification in a fast-moving environment

To better understand my question, let me elaborate the background of the subject matter. I work in a financial institution where the business module (credit finance) is constantly changing. In the IT world, however, the developers have a 6 week cycle taking list of projects/enhancements, put it in a timeline and business expect delivery on those projects. During each cycle, each developer gets assigned work that needs to be completed by a certain date. That date is already finalized by IT Change Managers and codes must be done by then. The code will then be synced, built to create a package and deployed to the test environment for QC (Quality Centre) team to test. The problem, however, is that developers get given the code 3 weeks before the code cycle ends. We are then told to do a technical specification and work estimation for each project/enhancements/bug fixes we are going to do. I have constantly talked to my managers that that is a backward mentality having to do estimations knowing when we need to deliver the finished code. My challenge: Is there a better estimation/technical specification model that cater for this kind of environment? If not, how can I tackle this issue such that it doesn't conflict with the deadline. Thanks. PS: I totally disagree in providing a business requirement to developers and expecting them to do a technical specification document as well as estimations during a code cycle. I do believe that technical specification document should be done before-hand and completed as well with functional/non-functional document and signed off by business. This is not happening currently.


Are "normal order" and "call-by-name" the same thing?

I was studying the book Structure and Interpretation of Computer Programs and in section 1.1.5 The Substitution Model for Procedure Application the author explains the concepts of _normal order_ and _applicative order_ , which I believe I have understood well. Now, I am taking a course on Coursera called Function Programming Principles in Scala and there the professor Martin Odersky (who based much of his course in the book cited above) explains the same concepts under the names of _call- by-name_ and _call-by-value_. In his course, professor Odersky says the substitution model is based on the Lambda Calculus, so I consulted a book on my library An Introduction to Functional Programming Though Lambda Calculus and in page 22, the author does define the terms as applicative order and normal order. Interestingly in his definition he says that applicative order is like Pascal's call-by-value whereas normal order is like Algol's call-by-name. The use of the words "is like" in his explanation is what made me doubt. Thus my questions:   * Are these two terms equivalent or are there any subtle differences?    * Can I use one or the other interchangeably without risking making a mistake in the meaning they convey?   * Are there any reasons you know about that justify the existence of different terminology to refer to the same thing?


I'm not sure what this license allows me to do

I'm using the BigRational class from bcl.codeplex.com. It will be opensourced when it's finished, and it's modified. However, I don't get legal jargon, so even though it's quite short, could someone explain to me what it does/doesn't allow you to do?


Byte code weaving vs Lisp macros

I have been reading about the libraries people have written for languages like Java and C# that make use of byte code weaving to do things like intercept function calls, insert logging code, etc. I have also been reading up on Lisp/Clojure macros in an attempt to better understand how to utilize them. The more I read about macros, the more it seems like they provide the same kind of functionality as byte code weaving libraries. By functionality, I mean the ability to manipulate code at compile time. Examples of libraries I have been looking at would be AspectJ, PostSharp, and Cecil. Is there anything that can be done with one and not the other? Do they actually solve the same problems or am I comparing apples and oranges?


Format text in a generic and reusable way

I would like to write some long text in some structure to allow a set of operations on that text. The question is which structure or format should I use, which suits best the use that I plan to do of that text? Next I describe that use:   * I would like to write text in natural language, possibly with translations to several languages. Translations would simply be the same structure with different data (text).   * I would like to keep that text in a VCS, check diffs, branch and merge, etc. The structure should fit well this use.   * I would like to keep the text free of as much clutter as possible so that it is human-readable.   * I would like to easily convert the text to other formats, not necessarily many but at least html and pdf would be fine.   * I would like to be able to manipulate that text easily, for instance changing the order of some elements, filtering them, etc. based on metadata in that text.   * Metadata is data, that means it may be printed or not, or it may be printed in different ways. Here are the main options I have considered so far:   * **Latex** : basically it is a language designed for this task. The problems I see are that it is not as readable as other options, for instance Markdown, and it is not really structured text. The text is there and the metadata about formatting options and so on can be separated with a set of macros, but the text is not really structured, changing the order requires either parsing it or defining all the text as macros so that only the order of the macro invocation needs to be changed. It's great for what it does, but becomes clumsy when it falls short in some feature, as structuring the text. I don't see a good separation between control information and data to be printed. It is a very good option to convert to pdf.    * **XML** : The structure in this case is fairly good, but in the current context, I see no advantage in using XML when HTML could be used instead, it provides the same features and some more.   * **HTML** : the conversion to HTML would be immediate in this case but the conversion to pdf is not so clear. In terms of human readability maybe markdown could be better, but HTML is probably the most widespread and used language for the task at hand, there are supporting languages like CSS (Less, Sass, too many options) that can make life easier, Javascript can handle it, anyone with a browser can easily read it, etc. Maybe some special HTML could be converted to quality Latex and there to pdf, I don't know.   * **Markdown** : a very good option in terms of readability, but I'm uncertain about how could it be manipulated, maybe through conversion to HTML and then using DOM manipulations or any other processing that could be done on XML and thus on proper HTML. I'm uncertain about how flexible may be for defining metadata (for instance a paragraph that is a summary of other paragraphs) when this could be easily done with XML or HTML via classes or other attributes.   * **JSON** : most languages include a parser for JSON thus it is very friendly for programming languages and easy manipulation m. Obviously some standard should be defined for JSON, but the same holds for the rest of the options, including latex (macros).   * **CoffeeScript** : this removes some clutter from the usual JSON, it may be more readable and can be converted into JSON easily.   * **Mixing** : the problem with JSON and CoffeeScript is that the structure to hold the contents is very flexible (maybe too much) but it doesn't support in a natural way inline annotations. A possible solution is to use Markdown or HTML for these fragments of text, including bold text or what may be needed. The objective is to write a manifesto, or something that looks like a manifesto and evolves. This is based on some ideas that recommend using VCS systems. The point is to have a structure that allows to write once and publish as many times as may be needed and in different ways, maybe blog posts, pdfs, etc., because a lot of effort to reach the consensus has to be put to write the text, rewriting and rewording does not seem a good idea. This discards some other nice options, like a wiki, but it would be nice to be able to have it structured in some way such that a set of pages like a wiki could be built from the source data. In the end the technology may not be there yet, but I think it is not too far. There are actually so many options that a clever use of some of them should be enough.


Best-practice to manage concurrency into a basket in a e-commerce website

What is the best practice to manage the case where two customers add in the same time a product whose the stock was only 1 ? Must there be a check in the code of the basket to avoid one of these 2 customers to add the same product ? Or does this check must be carried out in the payment phase in doing for instance a second query to confirm the concerned product is still present in stock (means not bought yet by the concurrent customer) ?


Novice to node.js, what is the advantage gained using callbacks over events?

I am a novice JavaScripter and have no real knowledge of what goes on inside the V8 engine. Having said that, I am really enjoying my early forays into the node.js environment but I find that I am constantly using events.EventEmitter() as a means to emit global events so that I can structure my programs to fit a notifier-observer pattern similar to what I would write in say an Objective-C or Python program. I find myself always doing things like this:               var events = require('events');          var eventCenter = new events.EventEmitter();          eventCenter.on('init', function() {         var greeting = 'Hello World!';         console.log('We're in the init function!);         eventCenter.emit('secondFunction', greeting);     });          eventCenter.on('secondFunction', function(greeting) {             console.log('We're in the second function!);             console.log(greeting);         eventCenter.emit('nextFunction');     });          eventCenter.on('nextFunction', function {         /* do stuff */     });          eventCenter.emit('init');      So in effect I'm just structuring 'async' node.js code into code that does things in the order I expect, instead I'm kind of "coding backwards" if that makes sense. Would there be any difference in doing this in a callback-heavy manner, either performance-wise or philosophy-wise? Is it better to do the same thing using callbacks instead of events?


Are there any SQL servers that support compiled queries?

Can SQL queries be compiled into byte code or equivalent to enhance performance? I know that most database servers support prepared statements, but is that the same thing as compiling? Most applications have to prepare statements on run- time so there is no benefit of pre-compiled byte code. Since it's prepared each time the application runs. I'm also not referring to stored procedures, but strictly SQL statements you execute to get a result set.


Erlang and Go concurrent programming, objective differences between CSP and Actors?

I was looking into concurrent programming in Erlang and Go programming languages. As per my finding they are used Actor model and CSP respectively. But still I am confused with what are the objective differences between CSP and Actors? is it just theoretical different only but the same concept?


JSON object and storage of nosql

I have read Would a NoSQL DB be more efficient than a relational DB for storing JSON objects? and am building a small test project in Asp.Net. I have a webapi up in Azure. It returns a `List<Company>` and Company is my object which has several properties and child list and a lat/long value.               //id, name etc.     public List<Certification> Certifications { get; set; }     public float Latitude { get; set; }     public float Longitude { get; set; }     public GeoCoordinate Cordinate // etc. GeoCoordinate is from System.Device reference      I return this List of companies and use the JSON output. Now internally, loading this list I load the complete list of companies out of a json file. and if there is no file, a file will be created. This is all good. But the Latitude and Longtitude is empty on the initial basis. So I fill it using googles reverse geocode. That works, but has a request limit. So I'd like to load the list and if lat/long is empty, retrieve the values from google's service and store it. But I am looking for a solution not to store the complete json list to a file again. And I am not looking for a relational database solution, because that is something that I have done enough. Now I have read about mongoDB. But it is a bit hard to set up on Azure. I have had Redis on Azure. What easy and fast solution do you recommend for me to store my list of objects? Do you even recommend it to store it as JSON? or something else? like XML? and use xpath to update values? So I am looking for an architecture/design to update all lat/longs untill google gives the quota limit error and give it a go next try I access the list of companies. ps. I do not want to store a list of `Certification`'s. I am curious if I can keep it as property of company and store the complete company project.


How to maximise the features of MySQL when used with php

I asked this question a while back on SO (http://stackoverflow.com/questions/15506040/maximising-the-features-of-php- and-mysql-when-used-together) but it's a recurring topic, so I thought I'd ask in a different way over here. Basically, we are stuck with the infamous php and MySQL combination (for various reasons), and are trying to produce applications which follow best- practice as much as possible. We notice that time and again, we are tightly coupling the application to the database and vice-versa, despite trying to adhere to SOLID principles. One of the main reasons is to maximise the features of a relational database (such as strict datatypes, hierarchical data structures, relationships, enforcing foreign keys, firing triggers, etc.) This means that some of the application logic bleeds over into SQL. However, there are features that other RDBMS's offer which MySQL doesn't (such as CHECK constraint most notably) so, we end up using php to get round those. This means we end up using php for some of things MySQL doesn't do well and we use MySQL to do things which aren't feasible in php. So, even though every text book encourages programmers to keep things loosely coupled, does anyone have any examples of how to overcome limitations you have come across, or examples of other applications that mix the two up in a similar way?


delegating program logic to lower-level objects

I'm writing a library for use in scientific computing and ran into a bit of a quandary. The types at work here are a class `M` which consists of some `data` and a reference to a container class `C`. There are many different implementations of `C` and I devoted a lot of work to making sure that `M` objects could use `C` objects without knowing their internal representation. The code may be used for high-performance scientific computing someday, so speed actually is a concern. If `M` were to break the encapsulation of `C` objects, the code could run faster. I tested this and indeed I could get a 50% speedup. But, that would involve lots of repeated code and violation of the open-closed principle. Alternatively, I can take the behavior that `M` needs to perform and delegate it to `C`. By default, `C` will use the same implementation-agnostic algorithm that I had before, but the logic has just moved downtown to a new class. The advantage of this approach is that, if `CO` is an implementation of `C` which can do substantially better than the default implementation, it can override that method with its own version. There is, at present, only 1 method that `M` will need to delegate to `C`. I can imagine at most 2 more behaviors that will need to be dealt with in this way. There may be a bit of repeated code, but it could be handled with a code generator too. Is this a common approach? If so, what's it called? If not, is that because it's a terrible idea for some reason that I haven't noticed? It's not quite the strategy pattern; most of the container objects don't even bother implementing their own strategy, they use the default.


How would I do a vim-style character text editor in a graphical application?

There's a cool guitar tabbing application that I've used before where you can use the keyboard to move around a character grid. You can put any digit in any character cell. Here is an image: ![enter image description here](http://i.stack.imgur.com/tIcil.png) This is similar to the VIM editor, where you have a block cursor and you can move around and place characters on the grid. I am using Qt as my GUI application. How would I go about adding this type of single-character editor control in my application? I have not run across this type of widget in any of my exposure to GUI programming; hence, I'm not even sure what to call it or how to describe it succinctly. Thanks.


How the Stream.filter() method works?

I know how the lambda expresion works and I know it is an argument for `.filter()` that establish the criteria to filter with. But I don't get how `.filter()` uses the argument, in this case a lambda expression, because .filter() does't have an implementation or at least require one at compile time. I search for this unknown implementation in the Oracle's site but there are just a few words explaning how it works and no code at all. Is that implemetation hidden or is created automatically by the java compiler? Does an aggregate operation need one?               double average = roster       .stream()       .filter(p -> p.getGender() == Person.Sex.MALE)       .mapToInt(Person::getAge)       .average()       .getAsDouble();      `roster` is a `List<Person>` instance of `ArrayList<Person>` `Person` is a simple class that represents a person


Whole Program in CASE

I'm going to start by saying, this may not be the correct place to post this. So...I'm working in Embedded Development, using C. Is there any benefit or disadvantages to doing the following:               while (1)     {        i++;        switch (i)        {           case 1:              x_get_inputs();              break;           case 2:              x_react();              break;           case 3:              x_set_outputs();              i = 0;              break;           default:              break;         }     }      Rather than a standard list of function calls? I think this is similar to a _Round Robin RTOS_? My logic is that the program cycle time will be shorter, and as such this should be more efficient?


How would I change the precision of a variable in Python?

I'm working on a 2D-physics engine, and I need a certain variable to be precise only to the hundredths. Are there any methods for basically shaving off all of that unneeded precision? I have tried things like               "{0:.2f}".format(a)      but that obviously produces a string, not a number. I'm moving an object based upon its speed, and I want it to(obviously) stop when its value is 0.0, but it keeps going because its speed is really something like 0.0000562351.


C# LinqExtensions implement multiple inheritance

According to WikiPedia "Some languages do not support mixins on the language level, but can easily mimic them by copying methods from one object to another at runtime, thereby "borrowing" the mixin's methods. Note that this is also possible with statically typed languages, but it requires constructing a new object with the extended set of methods." 1) LinqExtensions static library functions ( .Where() ) applied to collections of regular objects (int[]) that implement IEnumerable do essentially this. They use a _new object_ (LinqExtensions) to add the _extended set of methods_ ( Where(),etc ). Conclusion. LinqExtensions are mixins with all classes that support IEnumerable. 2) According to WikiPedia "In object-oriented programming languages, a mixin is a class which contains a combination of methods from other classes. How such combination is done depends on language, but it is not by inheritance. If a combination contains all methods of combined classes it is equivalent to multiple inheritance." By mixing **ALL** methods of classes that support IEnumerable ( List.HashCode, List.ToString, other List hierarchy baseline capabilities ), with **ALL** methods from the LinqExtensions static library ( .Where(), Max(), etc ) **an equivalent to multiple inheritance** is produced. An equivalent to multiple inheritance is produced, yes or no?


What are the benefits of using Dependency Injection and IoC Containers?

I'm planning to do a talk on Dependency Injection and IoC Containers, and I'm looking for some good arguments for using it. What are the most important benefits of using this technique, and these tools?


What OO Design to use ( is there a Design Pattern )?

I have two objects that represent a 'Bar/Club' ( a place where you drink/socialise). In one scenario I need the bar name, address, distance, slogon In another scenario I need the bar name, address, website url, logo So I've got two objects representing the same thing but with different fields. I like to use immutable objects, **so all the fields are set from the constructor**. One option is to have two constructors and null the other fields i.e:               class Bar {          private final String name;          private final Distance distance;          private final Url url;               public Bar(String name, Distance distance){               this.name = name;               this.distance = distance;               this.url = null;          }               public Bar(String name, Url url){               this.name = name;               this.distance = null;               this.url = url;          }               // getters     }      I don't like this as you would have to null check when you use the getters In my real example the first scenario has 3 fields and the second scenario has about 10, so it would be a **real pain having two constructors** , the amount of fields I would have to declare null and then when the object are in use you wouldn't know which `Bar` you where using and so what fields would be null and what wouldn't. What other options do I have? Two classes called `BarPreview` and `Bar`? Some type of inheritance / interface? Something else that is awesome?


Technology Choice for a Client Application

Not sure this is the right place to ask... I'm involved in the development of a new system, and now we are passing the demos stage. We need to build a proper client application. The platform we care most about is Windows, for now at least, but we would love to support other platforms, as long as it's free :-). Or at least very cheap. We anticipate two kinds of users:   1. Occasional, coming mostly from the web.   2. Professional, who would probably require more features, and better performance, and probably would prefer to see a native client. Our server exposes two APIs:   1. A SOAP API, WCF behind the scenes, that supports 100% of the functionality.   2. A small and very fast UDP + Binary API, that duplicates some of the functionality and is intended for the sake of performance for certain real-time scenarios. Our team is mostly proficient in .Net, C#, C++ development, and rather familiar with Web development (HTML, JavaScript). We are probably intending to develop two clients (for both user profiles), a web app, and a native app. Architecturally, we would like to have as many common components as possible. We would like to have several layers: Communication, Client Model, Client Logic, shared by both of the clients. We would also like to be able to add features to both clients when only the actual UI is a dual cost, and the rest is shared. We are looking at several technologies: WPF + Silverlight, Pure HTML, Flash / Flex (AIR?), Java (JavaFx?), and we are considering poking at WinRT(or whatever the proper name is). The question is which technology would you recommend and why? And which advantages or disadvantages will it have regarding our requirements?


understanding the encoding scheme in python 3

I got this error in my program which grab data from different website and write them to a file:               'charmap' codec can't encode characters in position 151618-151624: character maps to <undefined>      I am not familiar with all the encoding decoding thing and I have been okay with what python 2 did. Although the python officially said that they made the change in order to make things better, it seems to get worse. I have no idea how to fix these errors. However I am a pro-active person so I would really like to know what is causing the problem and how to solve it. I have check the official site but the words are hard to understand. Could I have a simple elaboration on that? Another page is also acceptable. EDIT: I've check this page, the Unicode HOWTO in Python 2.7. My understanding is that we must translate the unicode string into binary format while we're writing it to file and it require an encoding. Obviously 'utf-8' is the best one, but why it didn't force the python interpreter to use 'utf-8'? Instead, it use some strange codec such as 'charmap' and 'cp950' and 'latin-1'.


When should method overloads be refactored?

When should code that looks like:               DoThing(string foo, string bar);          DoThing(string foo, string bar, int baz, bool qux);          ...          DoThing(string foo, string bar, int baz, bool qux, string more, string andMore);      Be refactored into something that can be called like so:               var doThing = new DoThing(foo, bar);          doThing.more = value;     doThing.andMore = otherValue;          doThing.Go();      Or should it be refactored into something else entirely? In the particular case that inspired this question, it's a public interface for an XSLT templating DLL where we've had to add various flags (of various types) that can't be embedded into the string XML input.


Pronunciation in programming?

How do you correctly or erroneously pronounce programming terms? Any that you find need strict correction or history into the early CS culture? **Programming** `char` = "tchar" not care? `!` = bang not exclamation? `#` = pound not hash? Exception `#!` = shebang `*` = splat not star? `regex` = "rej ex" not "regg ex"? `sql` = "s q l" not "sequel" (already answered, just i.e.) **Unixen** `|` = pipe not vertical bar? `bin` = bin as in pin , not as in binary? `lib` = lib as in library , not as in liberate? `etc` = "ett see" , not "e t c" (as in `/etc` and not "&c") **Annoyance** `/` = slash not backslash `LaTeX` = "laytek" not "lay teks"


In wikipedia it is referred that Remote Socket Address is the Client Socket Address but i doubt that

In the context of Network Socket , which one is the REMOTE SOCKET ADDRESS?? Does the Client Socket Address refer to the Remote Socket Address?


Algorithm for generating hyperexponential distribution

I need to generate a hyperexponential distribution for my project. I have already implemented a poisson generating algorithm given by Donald Knuth, but I couldn't find an algorithm for generating a hyper exponential random variable. I am provided with the mean and variance required of the distribution and I need an algorithm which can generate a random variable from this distribution when I execute it.


Subversion Pre-Commit Check

In a config file for a PHP project, I have some settings that should not go out in production. Can anybody offer some specific examples or help on how to automatically check these fields and make sure their values are not the development/demo settings before the files get committed into subversion? Our IDE is JetBrains PHP Storm, and we use the latest version of subversion. Some of us develop on Linux, while others are on Windows.


How would you unit-test or perform the most effective automated testing on graphics code?

I'm writing a game and the accompanying graphics engine on top of OpenGL in C++. Im also a fan of good coding processes and automated testing. Graphics code + testing seems pretty immiscible, since the output is often visual only, or very heavily visual-oriented. For example, imagine analyzing the raw image-stream that is rendered to the screen byte-by-byte - you need test-data to compare with, which is hard to create/obtain, and often the rendered images aren't identical on a byte level when running at different times - small changes in algorithms will wreck this approach completely. I'm thinking of creating a visual unit-test suite, in which I can basically render different test-scenes, showing stuff like shadow mapping, animation, etc etc etc. As part of CI, these scenes would then be rendered to a video file (or possibly leave it as a executable) with different metrics. This would still require manual inspection of the video file, but atleast it would be somewhat automated and standardised. What do you think? I'm hoping there are better ways?


How to edit existing user stories

I'm quite new to working in Agile and with user stories and scenarios in the BDD tool Cucumber and ideally I'll need to go on a course of all of this. I have a set of user stories that need to be edited for an upcoming release. As an example one of the user stories is:               'As a user     I want a visual indicator on entry into the application'      This needs to be changed to:               As a producer, I don’t want a textured background in the application       The Acceptance Criteria (In Gherkin format for those familiar with Cucumber) for the original user story (the first one above) is                   Scenario: Show background image when video is not playing              Given the application restarts      When the home menu is displayed     Then the full-screen textured background should be visible at the correct resolution      For the new user story (second one above), the acceptance criteria that I have written, but not certain of is:               Scenario: Show dark grey background when video is not playing          Given the application restarts      When the home menu is displayed     Then the dark grey background should be visible at the correct resolution      Does this look right? Or am I missing information? I'm, quite new to this, so please bear with me.


Knowing who is the user in every request (every action, every view, every time)

I have many model classes that are mapped from/to tables using EF. Two of them are `User` and `UserCookie`, which are stored in tables `Users` and `UserCookies`.               public class User     {         public long UserId { get; set; }         public string Fullname { get; set; }         public string Email { get; set; }              (...)     }          public class UserCookie     {         public long UserCookieId { get; set; }         public long? UserId { get; set; }         public virtual User User { get; set; }         public string CookieValue { get; set; }     }      Every controller in my ASP.NET MVC application is a child (inherits) of `MyController`, which is like this:               public class MyController : Controller     {         protected MyDbContext dbContext;         protected UserCookie userCookie;         protected User currentUser;         protected string cookieValue;              public MyController() : base()         {             this.dbContext = new MyDbContext();             this.cookieValue = "";             this.currentUser = null;             this.userCookie = null;         }              protected override void OnActionExecuting(ActionExecutingContext filterContext)         {             base.OnActionExecuting(filterContext);                  HttpCookie cookie = Request.Cookies["LoginCookie"];                  if (cookie != null)             {                 this.cookieValue = cookie.Value;                 this.userCookie = db.UserCookies.SingleOrDefault(c => c.CookieValue.Equals(cookieValue));                      if (userCookie != null)                     this.currentUser = userCookie.User;             }         }              protected override ViewResult View(string viewName, string masterName, object model)         {             ViewBag.CurrentUser = currentUser;             ViewBag.UserCookie = userCookie;             ViewBag.CookieValue = cookieValue;                  return base.View(viewName, masterName, model);         }     }      When the user sign in successfully, I create a cookie in him with a random value, like this:                  public ActionResult Login(...)         {             (...)                  HttpCookie cookie = new HttpCookie("LoginCookie");             cookie.Value = Guid.NewGuid().ToString();             Response.Cookies.Add(cookie);                  userCookie.User = user;             userCookie.CookieValue = cookie.Value;             db.UserCookies.Add(userCookie);                  db.SaveChanges();      The problem with all this that I've shown is that I'm doing a request to the database in every HTTP request (that is, in every call to one of my actions). I'm also not happy with the table `UserCookies` because it has to be cleaned and is not intuitive. Also the generated `Guid` is not safe. I know **how wrong** is all this, but... I can't figure out an elegant way of achieving the same benefits. The main benefit of this is that I have access to `currentUser` in every action, so I can do stuff like this easily:                   if (!currentUser.Privileges.Any(p => p.Privilege == PrivilegesEnum.Blah))         {              (...)         }      I also have access to `currentUser` in all of my views. Questions:   1. What is the most common way of achieving this in real professional software?   2. If I wanted to use cache (like Redis), do I have to change a lot of stuff in the presented scenario?    3. If I do use cache, should I store just the `userId` instead of the entire User object?


Increasing User Changes/Requirements in Agile Methodology

My question is quite simple. How to handle a situation where the team is applying agile methodology in software projects and there so many iterations and change in requirements, that the schedule is highly affected? Plus you have your manager who is always wanting things to get done within schedule and it is something you cannot control?


Testing vs QA - output?

I was trying to find a relevant source of information for the above, but I failed. What is the output of software testing? Some say its "list of bugs", others say "answer whether or not the software conforms to what customer wanted". I know testing is a part of QA but not sure what is its aim and output in this context.


When to use functional programming approach and when not? (in Java)

let's assume I have a task to create a `Set` of class names. To remove duplication of `.getName()` method calls for each class, I used `org.apache.commons.collections.CollectionUtils` and `org.apache.commons.collections.Transformer` as follows: _Snippet 1:_               Set<String> myNames = new HashSet<String>();     CollectionUtils.collect(             Arrays.<Class<?>>asList(My1.class, My2.class, My3.class, My4.class, My5.class),             new Transformer() {                 public Object transform(Object o) {                     return ((Class<?>) o).getName();                 }             }, myNames);      An alternative would be this code: _Snippet 2:_               Collections.addAll(myNames, My1.class.getName(), My2.class.getName(), My3.class.getName(), My4.class.getName(), My5.class.getName());      So, when using functional programming approach is overhead and when it's not and why? Isn't my usage of functional programming approach in _snippet 1_ is an overhead and why?


How often are the unfortunate stereotypes associated with older techies true? When people get settled into a career--Do people lose their passion to learn new things? Do people get comfortable and stuck with one skillset and incapable of change? **How common is this?** I don't mean to be offensive with this question. I know many skilled older programmers. But you do sometimes see a "failure mode" when people get too comfortable in their jobs, skills, and lifestyle--too much so that they get irritated at the thought of having to learn something new. I see this and I'm deathly afraid of it happening to me. I want to emphasize I think there is also a "failure mode" for youth -- not really having the experience to know how to get a project done. The "youth" failure mode may be worse then the one I'm describing. I think the best teams have both junior and senior members. Am I just rehashing old, wrong stereotypes? Is there something to guard against when one gets settled into a career? Or am I just another ageist young programmer keeping the old-(wo)man down?


Will git whine if I create my projects in multiple directories?

I'm new to git (and github). I work in Java and Python. Right now, I manage my projects in only one directory - let's call it `Code` and the folder is on my Desktop. I want to group my projects by the language I code in. So, I want:               /Code/     ++ /Java/     ++ /Python/      I do not know if Git would be happy with this or not. If it would be, what should I set my home directory to be? And how should I manage it with my github account? For example, I create a new repo on GH for a `new-project` in Python (but I already have files on my local machine in `/Code/Python/new-project`), how should I about committing the files to GH making sure any other directories are not messed up with? EDIT: Just to be clear, I have unrelated projects in `/Code/project_1`, `/Code/project_2`, `/Code/project_3` etc. But I want to arrange them as `/Code/Java/project_1`, `/Code/Java/project_1`, `/Code/Python/project_1` etc.


how do live tutorials work e.g http://try.mongodb.org/ and http://try.redis.io/

I was wondering how do http://try.redis.io/, http://try.mongodb.org/ etc. work? Do they have one live (dedicated) user session on the server per user session in the web?


Underlying infrastructure behind something similar to Code School

I'm working on a venture similar to Code School: it features a code editor (currently, i'm using ACE Editor) and a real-time "Run" option. I have no idea how Code School works with this... i thought about creating/destroying VMs on Amazon for each student, but that would be very expensive. Or, does it run inside an application that delegates execution to many different machines? And what about security?


Managing an undercover SVN repository

The project I am working on is version controlled by SVN, and the unspoken rule at work is to commit only when a new stable feature is added (in order to have a "clean" revision history with no revert) so I work sometimes for a few days without commiting. However I am kind of a commiting maniac (several commits per day on my previous git projects) and this workflow doesn't suit me. Ideally I would like to fork the project, commit unstable version under the "submarine repo" and merge into the stable one whenever the feature is stable enough ( my unstable commits must not appear in the stable repo). How can I do this ? With SVN : I've look for Vendor Branches and Externals but I didn't really find what I want. With Git : is it possible to use Git on the undercover unstable repo and SVN for the stabilized repo without conflicts between the two CVS during merges ?


High-Load Java Server for Multiplayer

I am making a multiplayer game. Now I am trying to choose the technology to connect the android devices to the server. The clients run on Android, and the game is MMORPG. I would like to write the server in java. Right now I have only 3 ideas for it: _**1) creating multithreading environment with plain java and sockets. In this way it will be easier to perform full-duplex connection between the game client and the server. But I have the following concerns:_** 1.1) The game is MMORPG with a large number of objects, and I am not sure how such solutions are scaled if there are for example 5000 people playing at the same time. How many threads will I be able to run on java Machine? How can I approximately calculate that? In case 1 thread is reading for each socket and 1 thread is writing to the socket (so 2 threads for 1 player). 1.2) When the number of players grows, how will I be able to scale my self- written jar-archive to distribute over several servers? Maybe there is some special trick to do that? 1.3) A lot of programming overhead - sockets API is quite low level. _**2) Creating a Servlet-interface for serving HTTP requests._** 2.1) Easy to control sessions (and authorization) as long as each player has his/her own session. 2.2) can connect to java EE EJB or whatever - a lot of complications with system-level programming are taken away. So I can concentrate on writing business logic. 2.3) Can serve all types of clients with HTTP - mobile devices + browsers. 2.4) High-speed - even 1 servlet container can serve a few thousand requests per second so it will be really fast. 2.4) But this approach cant provide a full-duplex communication. I will have to send requests every 1 second to check for updates. 1 second delay does not make a lot of difference for the game as it is turn-based, but still it generates a lot of traffic. Is it feasible when there are many players playing? I heard about some COMET technology, but it seems like if the server has to push many messages in row, I will still have to send requests every time + this technology is not well established yet. _**3) Creating sockets and connecting them through JMS to the java EE server._** 3.1) Cool because allows for full duplex communication between clients and server + provides all cool features of java EE. Later can be extended to browser through servlet interface. 3.2) It seems like some kind of overengineering. Is it really how people would do that? I mean is it even the correct way? Would any sane developer do it like that? I would like you to help me out with the choice please. I dont have much experience with doing some work like that. And would like to stick to the best practices.


What do you do when one thinks the code isn't complicated enough?

After six months of development on a project, our stakeholders have had a "gut check" and have decided that the path that we've been walking (a custom designed application framework and data access layer) is holding us (the developers) back from quickly developing the features they would like to see. After several days of debate management and the development team have decided to scrap the current incarnation and start over using ASP.net MVC, with Entity Framework as the bases of the a 'quick and dirty', lets just get it done project. In days following, our senior developer who has never worked with MVC or Entity Framework has finally gotten into a sample project and done some work. His take on ASP.net MVC, "this is not software engineering". So my question is this; what do you do, when one doesn't think the code is complicated enough?


A Unicode sentinel value I can use?

I am desiging a file format and I want to do it right. Since it is a binary format, the very first byte (or bytes) of the file should _not_ form valid textual characters (just like in the PNG file header1). This allows tools that do not recognize the format to still see that its not a text file by looking at the first few bytes. Any codepoint above `0x7F` is invalid US-ASCII, so that's easy. But for Unicode it's a whole different story. Apart from valid Unicode characters there are _private-use characters_ , _noncharacters_ and _sentinels_ , as I found in the Unicode Private-Use Characters, Noncharacters & Sentinels FAQ. **What would be a sentinel sequence of bytes that I can use at the start of the file that would result in invalid US-ASCII, UTF-8, UTF-16LE and UTF-16BE?**   * Obviously the first byte cannot have a value below `0x80` as that would be a valid US-ASCII (control)character, so `0x00` cannot be used.   * Also, since _private-use characters_ are valid Unicode characters, I can't use those codepoints either.   * Since it must work with both little-endian and big-endian UTF-16, a _noncharacter_ such as `0xFFFE` is also not possible as its reverse `0xFEFF` is a valid Unicode character.   * The above mentioned FAQ suggests not using any of the _noncharacters_ as that would still result in a valid Unicode sequence, so something like `0xFFFF` is also out of the picture. What would be the future-proof sentinel values that are left for me to use? * * * 1) The PNG format has as its very first byte the non-ASCII `0x89` value, followed by the string `PNG`. A tool that read the first few bytes of a PNG may determine it is a binary file since it cannot interpret `0x89`. A GIF file, on the other hand, starts directly with the valid and readable ASCII string `GIF` followed by three more valid ASCII characters. For GIF a tool might determine it is a readable text file. This is wrong and the idea of starting the file with a non-textural byte sequence came from Designing File Formats by Andy McFadden.


Career change question: going from systems analyst to embedded systems development

How should I go about making a switch from doing help desk type work to embedded software development or any type of development that is done at a lower level? I will finally finish my degree in December and really want to get started building systems. My degree is an Applied Computer Science degree. I have taken classes in Assembly, C++, VB.NET, and Java but have not been able to use any of these to a great extent in any of my jobs. If anyone has advice on how to go about getting into the embedded development field that would be great.


Fastest way to find the closest point

I have a list in Python 2.7 of about 10000 point co-ordinates, like               [(168, 245), (59, 52), (61, 250), ... (205, 69), (185, 75)]      Is there a faster way to search for all the points in a bounding box, instead of just iterating over the entire list each time and checking if the co-ord is inside the 4 sides??   I'm using this "algoritm" to see if any point, which is randomly moving, has come inside the stationary bounding box..(if it helps)


Which programming language first introduced 'Hello World' as a first program to code for beginners?


Job Interview Challenges

I'm not entirely sure if this belongs here, so feel free to move/close it, if necessary. The other day, in our PHP class, our teacher gave us a challenge used by a friend of his in job interviews. It works in every programming language, so it's not limited to PHP. He said that his friend uses this 'riddle' to weed out the people who can't think of a fast answer when it comes to logical challenges. The people that don't solve it won't get a job, of course. The riddle is as follows:                   $a = 3;         $b = 7;              echo "a = $a";        // has to become 7         echo "<br />";         echo "b = $b";        // has to become 3      You basically have to switch the contents of both variables without doing lame things like `$b = $a + 4`. You **cannot** use a temporary variable either! I struggled with this, I have to admit that; I was like 'oooh yeah' when we finally got the answer. I don't want to spoil this for anyone, so instead of posting the solution I'll just put a link. Now, as for my question. I was wondering if there are more riddles like these out there, that people (that's you, SO) use in job interviews, etc. Perhaps even a bit harder than this one. My goal is to train my logical thinking a bit and get better in solving issues like this. Perhaps there are any books or websites out there devoted to stuff like this?


What web development frameworks questions should I include in my thesis?

I'm busy working for my thesis about Web Development Frameworks. I want to write about frameworks that have been used in the past and frameworks that have a good chance of lasting in the future, such as JQuery and PrimeFaces for example. I also want to do a survey and I am looking for good questions to ask on this survey. My questions is what web developers themselves are most interested in answering and what you think would be good questions in this survey to ask? For example, I was thinking about giving a list of current technologies and giving the possibility to give a score from 1 tot 10 to indicate which they prefer the most.


Is there a pattern or logical structure I can follow for Event Log Numbers?

What are some ideas or structure I can use when assigning EventID to events that will be saved to the Windows Event Log? ![enter image description here](http://i.stack.imgur.com/UT2UA.png) Some options I've considered   * Sequential (0... int.Max)   * Multiple of 10, where the "0" is replaced with how noisy the debugLevel is set.   xxx0 may represent exceptions, critical information, start, stop etc.   * ...? What numbering approach gives you the most insight when a user describes the event in an email or phone? What is the most useful to support staff?


Good use of try catch-blocks?

I always find myself wrestling with this... trying to find the right balance between try/catching and the code not becoming this obscene mess of tabs, brackets, and exceptions being thrown back up the call stack like a hot potato.  For example, I have an app I'm developing right now that uses SQLite. I have a Database interface that abstracts the SQLite calls, and a Model that accepts things to go in/out of the Database...  So if/when an SQLite exception occurs, it has to get tossed up to the Model (whom called it), who has to pass it off to whoever called the AddRecord/DeleteRecord/whatever...   I'm a fan of exceptions as opposed to returning error codes because error codes can be ignored, forgotten, etc., whereas an Exception essentially has to be handled (granted, I _could_ catch and move on immediately...)   I'm certain there's got to be a better way than what I've got going on right now. **Edit:**  I should have phrased this a little differently.  I understand to re-throw as different types and such, I worded that poorly and that's my own fault.   My question is...   how does one best keep the code clean when doing so?   It just starts to feel extremely cluttered to me after a while.


Do you use debugging in rails application? Why, when and how?

In Java, C and C++ I see people using intensively debugging strategies (because mostly they don't know about TDD). On the other hand, debugging too can help to understand software abstractions. So, when and how do you use debugging in Rails applications?


What does "Human Readable" mean? Is it a misnomer?

Two examples spring to mind:   * One of the reasons that .Net programmers are encouraged to use .config files instead of the Windows Registry is that .config files are XML and therefore human-readable.   * Similarly, JSON is sometimes considered human-readable compared with a proprietary format. Are human-readable formats actually readable by humans? In the example of configuration data:   1. The format doesn't change the underlying meaning of the information - in both cases, the data represents the same thing.   2. Both registry and .config file are stored internally as a series 0s and 1s. To that extent, the underlying representaion is equally unreadable by humans.   3. Both registry and .config file require a tool to read, format and display those 0s and 1s and convert them into a format that humans can read. In the case of configuration stored in the Windows Registry, this is a Registry Editor. In the case of XML it could be a text editor or XML reader. Either way, the tool makes the data readable, not the data format. So, what is the difference between human-readable data formats and non-human- readable formats?


Give advice from experienced to beginner programmer on reinventing my wheel(solution)

i ve just tried to do coding bat exercise. There are posted solutions to the problem i tried to solve. However, I was stubborn, i ignored them and tried to code it up my own way(basically reinventing my own wheel - square,bad working wheel). After 4 hours it looks nasty and fails some tests. Now i realize that my logic was totally wrong and wasteful. So the question :   * When do you start to give up solving problem your own way(reinventing the wheel) and start to look around to see other solution?    * How long should a developer be 'stubborn' in trying to find his 'unique' or complicated solution?    * When do you give up and begin to search for another logic?


Complexity limits of solutions created in Google Spreadsheets

I am creating a solution where I essentially put all rules regarding communication with customers (including automatic invoicing, reminder emails, welcome emails, etc.) into a Google Sheets and use Ultradox to create emails and PDFs based upon Google Docs templates. For the three automatic emails I have currently implemented this is working out really well, the whole thing is very transparent to our organization since even non-technical people can inspect and correct the "Excel"-formulas. My concern is that in 2-3 years we will probably have 200 unique emails and actions that we need to send out for the various occasions and given the various states that customers can be in. Of course I could aim at limiting the number of emails and states that our customer can be in, but this should be choice based upon business realities and not be limited by the choice of technology. **My question** is therefore, what are the limits of complexity (when will it become unmaintainable) that can be reasonably implemented in a solution based upon Google Apps Scripts and Google Sheets, given that I will attempt to expose as many of the rules as possible to Google Sheets? And what pitfalls should I be aware of when basing myself on a spreadsheet formulas, and what strategies should I follow to avoid the pitfalls? **Some of my own strategies** So far I have come up with the following strategies to increase maintainability:   1. Using several Google Sheets, each with its own purpose, each with its own dedicated "export" and "import" sheets so it is clear, which columns are dependent on the Google Sheet. Such sheets also help maintain referential integrity when inserting columns and rows.   2. Using multi-line formulas with indentation for formula-readability   3. Experimenting with the "validation" function to reduce the variability of data   4. Experimenting with Arrayformulas to ensure that formulas will work even if additional rows are added   5. Potentially offloading very complex formulas to Google Scripts and calling them from spreadsheet formulas   6. Using Named Ranges to ensure referential integrity Please notice that I am not asking about performance in this question, only maintainability. Also, I am unsure of how software complexity can be measured, so I am unsure of how to ask this question in a more specific way.


Server should accumulate several requests and to retrurn response for all

For example I have a server [c#] and 4 clients. When the first client sends a request to the server I want to push a notification to the other 3 clients that they should send a request to the server with some required data. After I receive requests from all clients I want to send the same response to all of them. What is the best way/pattern to implement something like this?


What is the main goal of MVVM pattern?

Could you tell me what is the goal of the MVVM pattern? What are the arguments or the reasons I can give to a team and product owner to respect and develop according to this pattern? I would like a simple answer. Something in one sentence or one word. Is it for   * maintenance   * security   * testing   * something else?


Are Persistence-Ignorant objects able to implement lazy loading?

_Persistence Ignorance_ is an application of single responsibility principle, which in practice means that Domain Objects ( **DO** ) shouldn't contain code related to persistence, instead they should only contain domain logic. a) I assume this means that the code which contacts lower layers ( ie persistence layers ) lives outside of the domain model in other classes ( **OC** ) of a business logic layer? b) If my assumption under _a)_ is correct, then **DO** , say `Customer`, never contains methods such as `GetCustomers` or `GetCustomerByID`? c) If my assumptions under _a)_ and _b)_ are correct, and assuming `Customer` domain object uses lazy loading for some of its properties, then at some point `Customer`'s internal logic must contact **OC** , which in turn retrieves deffered data. But if `Customer` needs to contact **OC** to receive deffered data, then we can't really claim that Domain Objects don't contain logic related to persistence?! Thank you **REPLYING TO jkohlhepp** 1) I assume `OrderProvider` and `CustomerProvider` classes are contained within business logic layer? 2) I gather from your reply that my assumptions under _b)_ are correct? 3) > ... I would check to see if some private orders field was populated or if it > was null. If it is null ... But as far as I can tell, as soon as domain code needs to check whether private `order` field was populated, and if it isn't,contacting OrderProvider, we are already violating **PI** principle?!