Base class should have no knowledge of its subtypes?

What's the OO principle that states (in sum): > A base object should have no knowledge of its subtypes. I _thought_ it was Liskov Substitution but after reading that wikipedia article I don't believe I'm correct. Thanks in advance!


Separate the renderer from the business model

I have a small responsibility separation issue that I hope someone can clarify. I have a small model composed by 2 classes: GameBoard and GamePiece, and the obvious relationship is that a GameBoard can have several GamePieces. In the application I'm implementing, GameBoard and GamePiece contain data related to rendering in the screen (Update/Draw methods, Textures, etc) as well as their logic (gameboard number of squares, pieceType, etc). Updating/Drawing the GameBoard causes to update/draw the pieces as well. However, in order to keep the single responsibility principle, I decided to separate the logic from the rendering. But I have some troubles to implement it adequately. I came up to a couple of solutions and I'm not sure which one is the best: 1- Create GameBoardRenderer and GamePieceRenderer classes (who would store Textures, updating and drawing), and every instance these Renderer classes would be related to one GameBoard or GamePiece respectively. The problem I see is that it forces me to keep a dual relationship between GameBoard and GamePiece, and GameBoardRenderer and GamePieceRenderer, and ensure that it is always consistent. 2- Create GameBoardRenderer and GamePieceRenderer, but make them inherit from GameBoard and GamePiece respectively, bringing all the rendering stuff to those classes, while keeping the association at the GameBoard and GamePiece classes. The problem is that when I call the Update/Draw method of GameBoard, I won't be able to call the GamePieceRenderer Update and Draw method (as no relationship will be available). What should I do? Is there any better solution? Thank you very much.


Why are invariants important in Computer Science

I understand 'invariant' in its literal sense. I also recognize them when I type code. But I don't think I understand the importance of this term in the context of computer science. Whenever I read conversations\white papers about language design from famous programmers\computer scientists, the term 'invariant' keeps popping up as a jargon; and that is the part I don't understand. What is so special about it?


Resources on how to relate structured and semi- / un-structured information

I don't have a great background in information organisation / retrieval, but I know of a few ways of dealing with the problem. For structured information, it's possible to go OOish - everything "has-a" or "has-many" something else, and you navigate the graph to find relationships between things. For unstructured information, you have techniques like text search and tagging. I know about basic CS data structures and algorithms for structured data, but what I'm interested in goes beyond that. I want to know about how unstructured data can be related to structured data "intelligently", i.e. without users having to explicitly understand the object hierarchy. What resources - articles or books - are there that summarise the CS theory behind these techniques or could introduce me to others? Since so far it's been difficult to communicate exactly what kind of problem I'm dealing with, here's an example scenario. It is my own wording and the domain has been (radically) obfuscated to protect the client. > A wine enthusiast wants to build a website for her wine society. Wine farms > could capture many wine prices and enter their locations. Users would search > for wine tasting venues in their area. Or all wines which cost below X per > bottle. Nothing difficult about that so far, because we're dealing with > structured information in a straightforward graph of objects or database > tables. > > However, they also have advice articles (unstructured info), such as "10 > things to look out for in a good Red" (sorry, we're stretching the limits of > my knowledge about wine :). As a user, you'd want the website to display a > link to the article when you're viewing wine farms. If the enthusiast > decides to have a section where people can list "recipes for meals which go > well with wine" on her website, she might also want the article to appear > next to those recipes which go well with red wine. Now, you don't want the > enthusiast who captures the data to have to link every new article to every > meal (because it won't just be this one article that is relevant to recipes > or wines); and you don't want meal authors to be bogged down by exactly > which one, two or three articles are most relevant out of a library of 50. > You certainly don't want to introduce a "red wine advice" field on every > wine or meal. So that's where you might use tagging. Wines, recipes and the > red wine advice article could all be tagged, "red". Great solution that > really works for blogspot.com, right? Well yes, as long as the data > capturers know that the "red" tag exists. Maybe they decide to use "Claret" > instead. Doh! If there are only 5 tags, they probably get it right, but if > there are 50 tags, or even just 20 they might not. Worse still you get the > spam scenario where the author of a new article just applies every tag - > "red", "white", "shiraz", "chenin blanc" etc. > > At this point we need to consider other techniques, like text search. The > wine is marked as a red, the article is chock full of the word "red wine". > Done. Well, you might want to apply some of the data clustering techniques > that can help you to better identify what a piece of text's main topics is. > Or create an indexing process that drops out common words and punctuation. > No point matching two items because they both use the word "but" a lot. > Actually, the best results of all would probably be to use a combination of > everything I've mentioned. You may notice that in this example my tone moves from, "I know exactly what I'm doing" to "try do some stuff like...". So, I'm looking for resources that will teach me about dealing with the combination of structured and unstructured info - tagging, text search with smart indexing and clustering as well as any other techniques which I don't know about yet. Some discussion of strengths and weaknesses of each would also be appropriate.


How do you know if you've split your domain correctly

In DDD i struggle to understand whether or not my domain is split correctly into aggregate roots and then those aggregate roots are grouped correctly into bounded contexts. is there a way - like a set of rules/guidance i can use to decide whether or not i am placing things in the right AR/BC


Communication between nested directives

There seem to be quite a few ways of communicating between directives. Say you have nested directives, where the inner directives must communicate something to the outer (e.g. it's been chosen by the user).               <outer>       <inner></inner>       <inner></inner>     </outer>      So far I have 5 ways of doing this ## `require:` parent directive The `inner` directive can require the `outer` directive, which can expose some method on its controller. So in the `inner` definition               require: '^outer',     link: function(scope, iElement, iAttrs, outerController) {        // This can be passed to ng-click in the template        $scope.chosen = function() {          outerController.chosen(something);        }     }      And in the `outer` directive's controller:               controller: function($scope) {        this.chosen = function(something) {        }     }      ## `$emit` event The `inner` directive can `$emit` an event, which the `outer` directive can respond to, via `$on`. So in the `inner` directive's controller:               controller: function($scope) {       $scope.chosen = function() {         $scope.$emit('inner::chosen', something);       }     }      and in the `outer` directives controller:               controller: function($scope) {       $scope.$on('inner::chosen, function(e, data) {       }     }      ## Execute expression in parent scope, via `&` The item can bind to an expression in the parent scope, and execute it at an appropriate point. The HTML would be like:               <outer>       <inner inner-choose="functionOnOuter(item)"></inner>       <inner inner-choose="functionOnOuter(item)"></inner>     </outer>      So the `inner` controller has an 'innerChoose' function it can call               scope: {       'innerChoose': '&'     },     controller: function() {       $scope.click = function() {         $scope.innerChoose({item:something});       }     }      which would call (in this case) the 'functionOnOuter' function on the `outer` directive's scope:               controller: function($scope) {       $scope.functionOnOuter = function(item) {       }     }      ## Scope inheritance on non-isolated scope Given that these are nested controllers, scope inheritance can be at work, and the inner directive can just call any functions in the scope chain, as long as it doesn't have an isolated scope). So in the `inner` directive:               // scope: anything but a hash {}     controller: function() {       $scope.click = function() {         $scope.functionOnOuter(something);       }     }      And in the `outer` directive:               controller: function($scope) {       $scope.functionOnOuter = function(item) {       }     }      ## By service injected into both inner and outer A service can be injected into both directives, so they can have direct access to the same object, or call functions to notify the service, and maybe even register themselves to be notified, in a pub/sub system. This doesn't require the directives to be nested. **Question** : What are any potential drawbacks and advantages of each over the others?


What does the Apache licensing mean by "Permitted: Commercial Use"

At choosealicense.com/licenses I am reading the Apache licensing, and see that under `Permitted` there stands `Commercial Use`: > This software and derivatives may be used for commercial purposes. Meaning, they can use (and modify) my app, in a commercial environment (e.g. Microsoft, Apple). Or, they can commercialize my app? English is not my native language and I am wondering if I am misinterpreting something.


What is the advantage of using map datastructure?

I am a member of some online coding website and today when I submitted a solution in C++, I saw there were much better answers in C++ itself which took considerably less time. The solutions were open so I went on through some of them and found all of them using map datastructure. I could not figure out where exactly it takes an edge. I made some googling but it was not convincing. Please help.


Should I HTML encode all output from my API?

I am creating a RESTful JSON API to access data from our website where the content is in German. A handful of the fields will return formatted HTML while most are single lines of text although they are highly like to include special characters. To make it easy to use I wanted consistency throughout. As the text in the HTML fields would not be easy to encode after they have the data my first thought was to encode all fields (they can always be un-encoded later int he other fields). Is this the best approach or should I suffix all the HTML fields e.g. description_html to imply they are already encoded or try something else? The plan is let people use the API however they want although initially to let our partners use our data on their website.


Difference between Javabean and Java Beans

I'm confused. I've seen two different terms: `Javabean` and `Java Beans`. Is there a significant difference between them?


Should I use a seperate class per test?

Taking the following simple method, how would you suggest I write a unit test for it (I am using MSTest however concepts are similar in other tools).               public void MyMethod(MyObject myObj, bool validInput)     {          if(!validInput)      {       // Do nothing      }      else      {       // Update the object       myObj.CurrentDateTime = DateTime.Now;       myObj.Name = "Hello World";      }     }      If I try and follow the rule of one assert per test, my logic would be that I should have a Class Initialise method which executes the method and then individual tests which check each property on myobj.               public class void MyTest     {         MyObj myObj;              [TestInitialize]         public void MyTestInitialize()         {             this.myObj = new MyObj();             MyMethod(myObj, true);         }              [TestMethod]         public void IsValidName()         {             Assert.AreEqual("Hello World", this.myObj.Name);         }              [TestMethod]         public void IsDateNotNull()         {             Assert.IsNotNull(this.myObj.CurrentDateTime);         }     }      Where I am confused is around the TestInitialize. If I execute the method under TestInitialize, I would need seperate classes per variation of parameter inputs. Is this correct? This would leave me with a huge number of files in my project (unless I have multiple classes per file). Thanks


What is a good way to comment if-else-clauses?

Whenever I'm writing a typical if-else-construct in any language I wonder what would be the best way (in terms of readability and overview) to add comments to it. Especially when commenting the else clause the comments always feel out-of-place for me. Say we have a construct like this (examples are written down in PHP):               if ($big == true) {         bigMagic();     } else {         smallMagic()     }      I could comment it like this:               // check, what kind of magic should happen     if ($big == true) {         // do some big magic stuff         bigMagic();     } else {         // small magic is enough         smallMagic()     }      or               // check, what kind of magic should happen     // do some big magic stuff     if ($big == true) {         bigMagic();     }     // small magic is enough     else {        smallMagic()     }      or               // check, what kind of magic should happen     // if:   do some big magic stuff     // else: small magic is enough     if ($big == true) {         bigMagic();     } else {         smallMagic()     }      What are your best-practice examples for commenting this?


Strategy for backwards compatibility of persistent storage

In my experience, trying to ensure that new versions of an application retain compatibility with data storage from previous versions can often be a painful process. What I currently do is to save a version number for each 'unit' of data (be it a file, database row/table, or whatever) and ensure that the version number gets updated each time the data changes in some way. I also create methods to convert from v1 to v2, v2 to v3, and so on. That way, if I'm at v7 and I encounter a v3 file, I can do v3->v4->v5->v6->v7. So far this approach seems to be working out well, but I haven't had to make use of it extensively yet so there may be unforseen problems. I'm also concerned that if the objects I'm loading change significantly, I'll either have to keep around old versions of the classes or face updating all my conversion methods to handle the new class definition. Is my approach sound? Are there other/better approaches I could be using? Are there any design patterns applicable to this problem?


What is the reason to put prefixes in new CSS features?

Is there a valid reason for the browsers to prefix new CSS features, instead of letting the webmasters use the non-prefixed version? For example, a sample code for the background gradient looks like:               #arbitrary-stops {       /* fallback DIY*/            /* Safari 4-5, Chrome 1-9 */       background: -webkit-gradient(linear, left top, right top, from(#2F2727), color-stop(0.05, #1a82f7), color-stop(0.5, #2F2727), color-stop(0.95, #1a82f7), to(#2F2727));            /* Safari 5.1+, Chrome 10+ */       background: -webkit-linear-gradient(left, #2F2727, #1a82f7 5%, #2F2727, #1a82f7 95%, #2F2727);            /* Firefox 3.6+ */       background: -moz-linear-gradient(left, #2F2727, #1a82f7 5%, #2F2727, #1a82f7 95%, #2F2727);            /* IE 10 */       background: -ms-linear-gradient(left, #2F2727, #1a82f7 5%, #2F2727, #1a82f7 95%, #2F2727);            /* Opera 11.10+ */       background: -o-linear-gradient(left, #2F2727, #1a82f7 5%, #2F2727, #1a82f7 95%, #2F2727);     }      What's the point in forcing webmasters to copy-paste the same code four times to have the same result? * * * Note: one of the reasons often quoted is that **prefixed styles are intended to be temporary while either the browser does not implement the spec correctly, or the spec is not definitive**. IMO, this reason is a nonsense:   * If the browser engine does not implement the spec correctly, the browser will not be compliant, no matter if it does not implement it in a non-prefixed form or it does not implement it in a prefixed form.   * If the spec is not definitive, it may matter when there were previous implementations with the same name. For example if CSS2 had `linear-gradient`, but CSS3 was intended to extend `linear-gradient` with additional features, it would be clever to temporary prefix the new, draft, implementation by `-css3-<style>` differentiate between the working CSS2 one, and the experimental CSS3 one. In practice, CSS2 doesn't have `linear-gradient` or other CSS3 novelties. I would also understand if **different browsers had different implementation formats** : for example let's say Firefox required, for text shadow, `<weight- of-shadow distance-x distance-y color>`, while Chrome required `<distance-x distance-y weight-of-shadow color>`. But actually, this is not the case; at least all new features of CSS3 I've used so far had the same format.


Is there a name for this design pattern, using hooks/callbacks?

I've seen/used some objects that have a structure like so, designed to let children extend the functionality of functions without having to override them. Is there a name for this pattern? code example:               class CrudModel {       public function create($data) {         $data = $this->pre_create($data);         //create logic       }            public function delete($data) {         $data = $this->pre_delete($data);         //delete logic       }            protected function pre_create($data) { //empty }       protected function pre_delete($data) { //empty }           }          class SpecificCrudModel extends Model {         protected function pre_create($data) {           //custom logic for this object.         }          }


How can I estimate hosting costs on Heroku into the hundreds of thousands of users?

Heroku's pricing page is clear when looking at what I'm paying and what I'm getting, but it is not helpful for predicting future costs of an app. If I have an app that is still being developed, how can I get even a ballpark estimate on what my app will cost at 10, 100, 1000, al the way to 100,000 users?


GIT Permissions

There is something not clear for me and this is how to prevent other people read my code. The thing is that I want people create their own branches but not to view the other's branches. If someone is responsible for networking, I don't want this guy to view graphics codes. S/He must be forced to work on his branch only.


Overloading to support multiple related types (especially pointers)

# Problem I was just trying to debug a set of file-manipulation routines I wrote for a program I am working on. One of them kept returning an `INVALID_HANDLE` error. # Explanation I figured out what the problem was. It turns out that because I provided several overloads so that I could call the function with either a file handle or filename, I ended up creating ambiguous overloads. For example (not variadic functions; the ellipses are just for simplification purposes):               INT CopyFileSection ( HANDLE fIn, HANDLE fOut, … );     INT CopyFileSection ( HANDLE fIn, TCHAR* fOut, … );     INT CopyFileSection ( TCHAR* fIn, HANDLE fOut, … );     INT CopyFileSection ( TCHAR* fIn, TCHAR* fOut, … );      The first one (`HANDLE, HANDLE`) does the main work while the others just open the file pointed to by the filename and call the first function. The problem is that a `HANDLE` is just a pointer, so the compile can’t figure out which one I am calling (even though to me it was obvious), and ends up calling `HANDLE, HANDLE` even when I pass a pointer to a string, so naturally it fails since the pointer is not a file handle. # Question I want to provide maximum flexibility, so short of re-writing to use `std::string` _instead of_ `TCHAR*` for the filenames (which I actually did include as well), what suggestions are there to deal with this sort of scenario?    # Related As a related side note—a separate question?—I was wondering about the ease, safety, and feasibility of providing overloads for all (or at least a set of) possible permutations. For example, with a function that takes two files, you could use `HANDLE`, `TCHAR*`, and `string` (probably others, but in this case we’ll stick with these three). This means there are up to nine overloads just for the files: `HH, HT, HS, TH, TT, TS, SH, ST, SS`. Let alone if there are other arguments that could provide more overloads. Surely there must be a better way to both provide flexibility in calling the function and clean, understandable, and maintainable code.


What arguments can I use to "sell" the BDD concept to a team reluctant to adopt it?

I am a bit of a vocal proponent of the Behaviour Driven Development methodology (aka BDD). I've been applying BDD for a couple of years now, and have adopted StoryQ as my framework of choice when developing DotNet applications. Even though I have been unit testing for many years, and had previously shifted to a test-first approach, I've found that I get much more value out of using a BDD framework, because my tests capture the intent of the requirements in relatively clear English within my code, and because my tests can execute multiple assertions without ending the test halfway through - meaning I can see which specific assertions pass/fail at a glance without debugging to prove it. This has really been the tip of the iceberg for me, as I've also noticed that I am able to debug both test and implementation code in a more targeted manner, with the result that my productivity has grown significantly, and that I can more easily determine where a failure occurs if a problem happens to make it all the way to the integration build due to the output that makes its way into the build logs. Further, the StoryQ api has a lovely fluent syntax that is easy to learn and which can be applied in an extraordinary number of ways, requiring no external dependencies in order to use it. So with all of these benefits, you would think it an easy to introduce the concept to the rest of the team. Unfortunately, the other team members are reluctant to even look at StoryQ to evaluate it properly (let alone entertain the idea of applying BDD), and have convinced each other to try and remove a number of StoryQ elements from our own core testing framework, even though they originally supported the use of StoryQ, and even though the code they wish to remove doesn't impact on any other part of our testing system. Doing so would end up increasing my workload significantly overall and really goes against the grain, as I am convinced through practical experience that it is a better way to work in a test-first manner in our particular working environment, and can only lead to greater improvements in the quality of our software, given I've found it easier to stick with test first using BDD. To further clarify, the majority of the unit tests we have tend to be quite brittle and difficult to maintain, a holdover from years of poorly applied testing where a reluctance to stick with a test-driven process has seen developers fall back on old habits and do all of their testing at the end of the project (these same people claim to be Agile!). So the question really comes down to the following:   1. What arguments can I use to really drive the point home that it would be better for this team to use StoryQ, or at the very least to adopt the BDD methodology?   2. Can you point me to any anecdotal evidence that I can use to support my argument to adopt BDD as our standard method of choice?   3. What counter arguments can you think of that could suggest that my wish to encourage the team to adopt BDD might be in error? Yes, I'm happy to be proven wrong provided the argument is a sound one. **NOTE** : I am not advocating that we rewrite our tests in their entirety, but rather to simply start working in a different manner for all future testing work, and preferably in the manner in which we engage our customers. And for those of you wishing to learn more about BDD, the following links may be useful:   * http://dannorth.net/introducing-bdd/   * http://en.wikipedia.org/wiki/Behaviour_driven_development   * http://behaviour-driven.org/Introduction * * * For those interested in more details, we're a small team of 4 working on about 5 large projects. The "pilot trial" for BDD ran for about 2 months initially, with another approximately 4 month period following. Team accepted that I should continue to work this way and were to do their own trials. I've been BDD-ing for about 2 years now since the trial ended, while the others have become very good at ducking the issue. Rather than forcing a "confrontation" over the issue, I'm looking for ways to gently persuade the team to get off their collective behinds and make the time to do their bit.


Algorithm for determining grid based on variably sized "blocks"?

I'm trying to convert a set of "blocks" in to a grid-like layout. The blocks have a width of either 25%, 33%, 50%, 66%, or 75% of their container and each row of the grid should try to fit as many blocks as possible, up to a total width of 100%. I've discovered that trying to do this while leaving no remaining blocks in the original set is very hard. Eventually, I think my solution will be to upgrade/downgrade various block sizes (based on their priority or something) so they all fit in to a row. Either case, before I do that, I thought I'd check if someone has some code (or a paper) demonstrating a solution to this problem already? And bonus points if the solution incorporates varying block heights in to its calculations :)


Set of specific values implementation vs. using some sort of generic set with advanced checks

I am working on a set implementation in JavaScript currently. This should kind of simulate generics as known from Java or C#. I need a mutable version of that (allows for adding/removing set values) and an immutable one. My constructor signature looks like this:               new GenericSet( 'number', [ 10, 20, 30 ] );      ,                // mutable set of mixed values (allows to add further values via "add")      new MutableGenericSet( '*', [ 'foo', 42, {}, /./ ] );      or               // DataValues.prototype.equals will be used by the set for determining equality.     new GenericSet( { type: DataValue, valueComparison: 'equals' }, [ dv1, dv2, dv3 ] );      ## Just GenericSet or one set implementation per type? Initially, my main purpose for this was to have sets of values of one type. E.g. a _DataValuesSet_ which would only accept data Values. I could then define interfaces with functions that require a _DataValuesSet_ instance. I could not use inheritance (and guess that would be bad anyhow), so I would use composition and have a _GenericSet_ / _MutableGenericSet_ instance internally. An alternative approach would be to always take _GenericSet_ and implement and use `GenericSet.requireSetOfType( type )` which would throw an error if the set's type was not the required one. My concern with doing it this way is that my interface definitions would look less explicit. Take               /**      * @param DataValuesSet dataValues      */     function printDataValues( dataValues ) {         if( !( dataValues instanceof DataValuesSet ) ) {             throw Error( '...' );         }         // ...     }      vs.               /**      * @param GenericSet dataValues Has to be a set of DataValue instances.      */     function printDataValues( dataValues ) {         // Throws error if dataValues is not a set or it it is a set with values of wrong type.         GenericSet.requireSetOfType( dataValues, DataValue );         // ...     }      perhaps using `@param GenericSet(DataValues) dataValues` for documenting the second choice would be alright? Does anyone see any further implications with the second approach or are there any alternative suggestions? To me the, second one looks more intuitive and my concern with the first one is that I would just create more overhead with constructors while I can not see any clear advantage right now.


How do you come up with algorithms?

I picked up some Project Euler questions today and decided to find more effective ways to Answer the questions l had already answered. So on the question about finding the sum of the even Fibonacci terms up to 4 million; I noticed that if we had a separate sequence for the even Fibonacci terms (starting with 0 & 2 as the first & second terms respectively), the progression would be `[0,2,8,34,144,610,...]` If two values from two successive terms are known, then the next term could be gotten with this expression:               [ T(n) = (4 * T(n-1)) + T(n-2) ]     ...     Where;     T(n) : is the nth term,     T(n-1) : is the (n-1)th term,     T(n-2) : is the (n-2)th term,     and '4' is a constant.      However, so far I've been unable to derive an adequate expression to find the value in an arbitrary position without knowing the values of the two preceding terms. My question:   1. Is this how equations (/algorithms) are derived?   2. Is this an efficient algorithm? Footnote: The other less efficient method (in my opinion), is to:   1. Create a function to generate all the numbers in the Fibonacci sequence under 4 million,   2. Get the even numbers among them,   3. Find their sum.


Is it better to use a Database or a data structure for network stack?

I've built a multi threaded messaging application in C and I'm currently using a MySQL Memory table to save the session ID, but I'm not sure whether this was a good decision or not. It works like this, the application sends a message and saves the source session ID in the MySQL table. When the application gets the success response it will remove the session's ID from the MySQL table, or if it received an error response then it will keep the ID to be retried later. I've built it this way so that I don't need to care about building a data structure by myself, and the Database provides flexibility when it comes to querying it. Do you think this is appropriate or do I need to use something else? Please note that the application is expecting to handle a large number of transactions/sec.


What are some potential pitfalls to using URL rewriting with SSL?

Using URL rewriting for session management for plain HTTP communication is a recipe for disaster, however, does some of that risk go away if you're using SSL (https)?


Peer review for tests just like code reviews

Does anyone practice the "code review" process for functional tests? Do you find it useful? The way that my current employer practices SCRUM we include functional testing as part of our "must have done" stuff in any given sprint.


Do I need a license before selling software?

I have a small time software firm. Recently we got a major project that the other company wants to sell. We will be making a website and multi-platform mobile apps We are coding in PHP, JAVA, HTML. Do I need any sort of license to use these languages? Seeing that we need to sell this... We will also be using google maps. What sort of permissions will we need from google?


Managed Coders vs Native Coders

I'm a coder and have experience with both native and managed code. I started out with Pascal and C, then moved into C++ and eventually into C#. Over the last year or so, I've been coding almost exclusively in C# and have lost a lot of what used to come naturally when I was a C++ coder. A few weeks ago when I sat down to write some native C++ code, I found myself fumbling around as I slowly got re-acquainted with the complexities, quirks, and idiosyncrasies of it all. I'm almost embarrassed to say that I had completely forgotten that passing a dynamically allocated array to a function without also passing its size would mean that the receiving function would have no way of knowing how long the array is. There are countless articles and documents which compare and contrast managed vs unmanaged code. We all know that native code, if well optimised, can run significantly faster and lighter than managed code. On the other hand, managed code has garbage collectors and run-time CPU-specific and OS-specific optimisation which can give native code a run for its money. Purely from a technical perspective, there is no clear winner. There is no doubt that managed code is orders of magnitude simpler to code and understand. Just look at difference in the number of lines necessary to construct a simple GUI in Win32 C++ vs C#. Back in my native-coding days, I mostly wrote mathematical simulations that ran on supercomputers. They had ugly CLIs and were mostly algorithm-focussed. Nowadays I write in C# and produce beautiful GUI applications, but would be lost if I had to make something of a similar calibre on a native language. Even with a framework such as QT, it would still take twice as long to produce something in C++/QT than it would in C#. Whenever I see someone who has written a large-scale, full-featured GUI application in C/C++, I can't help but feel a sense of awe and a hint of jealousy. I'm curious how other experienced coders see managed and unmanaged languages. Do you see managed code as _amateur-ish_? Do you see native coders as more _hardcore_?


OCR API (in Java) with Word (NOT MS-WORD) extraction

![word extraction illustration](http://i.stack.imgur.com/eDsJK.png) ## My Situation I need to develop an application which does crowd-sourced Image-To-Text service (just like google's reCaptcha). So I need an OCR API which can find words in an image with some text. ## My Research   * I have gone through JavaOCR Library.    * Also Tessaract (which is not implemented in Java & Tess4J Wrapper doesn't have anything I'm looking for). So basically I have nowhere to go, so I need help. ## What I want   * Is there any API (preferably in Java) that does exactly as I have shown in the image above?   * If no such API exists, is there any EXACT algorithms suitable for this process?   * If not, what's your suggestion to achieve this? Note: I don't want another just image-to-text APIs. I need an API which finds WORD LOCATIONS in the input image.


Instantiating Null Objects with Null-Coalescing Operator

Consider the following typical scenario:               if(myObject == null) {         myObject = new myClass();     }      I'm wondering what is thought of the following replacement using the null- coalescing operator:               myObject = myObject ?? new myClass();      I'm not sure whether I should be using the second form. It seems like a nice shorthand, but the `myObject = myObject` construct at the beginning seems like it could be a bit of a code-smell. Is this a reasonable thing to do, or is there a better shorthand that I am missing? Or maybe, "It's three lines, get over it!"? Edit: As has been mentioned, perhaps calling this a typical scenario is something of an overstatement. I usually find that I encounter this situation when I'm retrieving an entity from a database that has a child reference type property that may or may not be populated yet:               myClass myObject = myClassService.getById(id);     myObject.myChildObject = myObject.myChildObject ?? new myChildClass();


Design Pattern for data import of various source types and to various destination types

I have to design and build an import script (in C#) that can handle the following:   * read data from various sources (XML, XSLX, CSV)   * verify data   * write the data to various object types (customer, address) The data will come from a number of sources but a source will always have one import format (either csv, xml, xslx). Import formats can vary from source to source. New import formats may be added in the future. The destination object types are always the same (customer, addres and some more). I've been thinking about using generics and I read something about the factory pattern but I'm a pretty big noob in this area so any advice is more than welcome. What is an appropriate design pattern to solve this problem?


How to introduce testing in the development cycle

In our company, we are only two IT staffs, and I'm the only developper. I'm developping rich intranet applications using plain php and extjs as javascript framework. Our development cycle is usually very fast, such that often people are using tomorrow what I develop today. This is possible through an automated build script. ### Now the problem: It happens, that despite all the care, things break. And myself or the end users will notice it once the application update is published. Of course a testing framework (or mabe two, one for php and one for js) would be the solution. But this looks to me just as an unsurmountable barrier, because of these points:   * I never used a testing framework, and lack necessary knowledge   * A testing framework puts constraints on the way code is written (and I cannot judge for now, if my code fits any particular framework). I therefore fear that I had to refactor my code to be able to use a testing framework.   * I fear that writing the tests is likely to take more time than to write the code.   * Much of the code depends on the data present in different databases. How to make up mock data that can be used for testing. Can someone give me advice on how to introduce a testing framework in a setting where proficiency and time are scarce ? I know this question is really broad, but I hope I will get nonetheless some precious advices.


Inheritance with Entity Framework Code First

I'm starting work on a new personal project and I'm looking to get advice in regards to setting up my classes. My base class is a User. The User class will have the following general properties   * User ID   * User Name   * Password   * Address (this will be a complex/value type) I will then have a Subscriber class which is a User who has chosen to subscribe to a plan that I offer. The Subscriber class will have its own properties in addition to that of the User including:   * Subscriber ID   * Plan ID   * Date Subscribed   * etc Is inheritance the way to go here with User being the base class or is a foreign key from the Subscriber to User class the better way? If inheritance is preferred then which method? TPH or TPT? The plan is to have other classes with the User class acting as the base including Participants and Volunteers. Thanks!


Customer won't decide, how to deal?

I write software that involves the use of measured quantities, many input by the user, most displayed, that are fed into calculation models to simulate various physical thing-a-majigs. We have created a data type that allows us to associate a numeric value with a unit, we call these "quantities" (big duh). Quantities and units are unique to dimension. You can't attach kilogram to a length for example. Math on quantities does automatic unit conversion to SI and the type is dimension safe (you can't assign a weight to a pressure for example). Custom UI components have been developed that display the value and its unit and/or allow the user to edit them. Dimensionless quantities, having no units, are a single, custom case implemented within the system. There's a set of related quantities such that our target audience apparently uses them interchangeably. The quantities are used in special units that embed the conversion factors for the related quantity dimensions...in other words, when using these units converting from one to another simply involves multiplying the value by 1 to the dimensional difference. However, conversion to/from the calculation system (SI) still involves these factors. One of these related quantities is a dimensionless one that represents a ratio. I simply can't get the "customer" to recognize the necessity of distinguishing these values and their use. They've picked one and want to use it everywhere, customizing the way we deal with it in special places. In this case they've picked one of the dimensions that has a unit...BUT, they don't want there to be a unit (GRR!!!). This of course is causing us to implement these special overrides for our UI elements and such. That of course is often times forgotten and worse...after a couple months everyone forgets why it was necessary and why we're using this dimensional value, calling it the wrong thing, and disabling the unit. I could just ignore the "customer" and implement the type as the dimensionless quantity, which makes most sense. However, that leaves the team responsible for figuring it out when they've given us a formula using one of the other quantities. We have to not only figure out that it's happening, we have to decide what to do. This isn't a trivial deal. The other option is just to say to hell with it, do it the customer's way, and let it waste continued time and effort because it's just downright confusing as hell. However, I can't count the amount of times someone has said, "Why is this being done this way, it makes no sense at all," and the team goes off the deep end trying to figure it out. What would you do? Currently I'm still attempting to convince them that even if they use terms interchangeably, we at the least can't do that within the product discussion. Don't have high hopes though.


How do you unit test your javascript

I spend a lot of time working in javascript of late. I have not found a way that seems to work well for testing javascript. This in the past hasn't been a problem for me since most of the websites I worked on had very little javascript in them. I now have a new website that makes extensive use of jQuery I would like to build unit tests for most of the system. My problems are this.   * Most of the functions make changes to the DOM in some way.   * Most of the functions request data from the web server as well and require a session on the service to get results back. I would like to run the test from either a command line or a test running harness rather then in a browser. Any help or articles I should be reading would be helpful.


tail-like view on HTML logfiles

I'm working on an application that creates HTML log files. I'm tired of having to manually reload and scroll to the bottom in the browser to see the latest entries. A solution that does not really satisfy me is using the Firefox plugins ReloadEvery and ScrollyFox. In many situations reloading frequency and scrolling speed are just to slow. Of course I could actually use tail, but I would prefer a rendered HTML page. Do you have any suggestions? Firefox extensions are preferred, but any other tip is appreciated, too.


Trying to learn ASP.NET

I have a background in computers and have programmed for about 7 years. I switched careers, and became a Technical Writer, and now think I should jump ship again, back to being a programmer. Of course the natural course of action, in which I can spend, say two whole years, learning to code, might not be available any more. I am keen on ASP.NET as its the language that most products at my company are written in. I am sure this has been asked before, but here I go: where do I begin? I would really appreciate some practical advise.


What to do when the marketing department attempts to drive the development process?

I'm a fairly experienced web-developer working in a small startup, as the developer of an e-commerce website. The other three people involved are the Director, the Designer and the Marketing guy. The plan as I understood it, was for the Designer to make the logos and page mockups, me to turn them into a functional website, the marketer to oversee any messaging/blurbs/social-media, the Director to manage the business and oversee everything else. Recently, the Marketing guy asked about our plans for a RWD (responsive web design). I told him that due to our tight schedule and that I'm writing both the front-end and back-end code, I'd only be targeting the most popular mobile devices until we had a functional website, after which I'd focus on a more comprehensive responsive design to target everything. He didn't want to accept this and asked me why we couldn't just buy a WordPress template to handle the responsive aspect. Because the template requires WordPress, some e-commerce plugin for WP and modification of the template itself to match our design anyway, I replied that it wasn't a good idea and would probably only add extra development overhead at this point. His last response seemed to only reiterate his points without addressing mine. Rather than having some back and forth pissing match, I'm looking for a solution that will work best for the project as a whole, while avoiding any animosity if possible. Any ideas (technical, management or otherwise)?


Defect statuses: "WON'T FIX" vs "Cancelled"

I've been involved in several projects either as tester or developer. In many of projects there were following statuses for defects:   1. WON'T FIX   2. Cancelled Do you use such statuses and how do you differ them? I ask, because most people can't explain the difference. My understanding is: **WON'T FIX** \- developer will not fix the defect, due to it's not a defect;   **Cancelled** \- defect should not be fixed, because of lowest priority


How can a Right-Brainer Deal with Massive Left-Brainer Code?

I'm an artist, mostly, though I describe myself as a artist/physicist. While I can do math, deal with words, and the "logical" stuff considered left-brain, it's an effort and I make mistakes, whereas I do well with and most of the time think in terms of those things associated with right-brain thinking - spatial relations, holistic big-picture context, etc. Of course all that is fuzzy, as the right-left brain theory is oversimplified and no mental activity is so simple. Yet I do sense that I fit in fine with artists, video directors, chefs, and other non-verbal thinking, creative types, while most people in "IT" or hardcore software engineers have minds that work differently, with attention to detail, holding many details in mind at one time, and strong rational and verbal capabilities. So here I am in a job being paid to fix fussy and obscure bugs in a massive swarm of C++ software, very heavy on OO, and any one line of code makes no sense unless I hold in mind about twenty other class and method names, relations between them, the flow of execution (very spaghetti-like) and other detail. Besides that, I'm also rather strongly against much of contemporary C++ and OO styles. Those who wrote this code really drank the deep OO and Modern C++ kool-ade. I find it actually makes code much harder to follow, much harder to decide where to fix or change something. I don't know if this is part of the left/right differnce (or whatever you want to call it) or not. But work on the C++ I must - people depend on me for my income. What are tips and techniques to deal with this situation, to be as effective as possible for my employer?


What can you do about the quality of existing integration and unit tests while being the new guy in a team ?

A recurring theme that I came across in my career is being the new developer to arrive in a team, and quickly having an inherent distrust of the existing unit and integration test suites. During the interview you are told by the management that they "strongly support unit testing" and that they openly encourage it. They do, but everything about the tests themselves is just plain wrong. Like the fact that they are claiming 100% coverage when there is 100% integration test coverage but less than 10% repeatable unit test coverage. Some other problems I have found:   1. No clear indication between what is a unit test and what is an integration test. Unit and integration tests are mixed together in the same class.   2. Integration tests that have undeclared explicit dependencies on very specific dynamic data on a specific environment's database.   3. Non-transactional integration tests, basically tests that may or may not bother to clean up after themselves, sometimes requiring manual database "scrubbing" to make the test repeatable.   4. No mocking whatsoever, and application code requires a major overhaul just for mocking to be possible. In other words, design without testing in mind.   5. No clear naming conventions to quickly look at a test name and determine roughly what tests are being done. This is all not to say that ALL of the tests are useless or bad, a good deal of them are pretty good and worth keeping, but it feels like panning for gold sometimes. I would purposely avoid running tests just because I was afraid of screwing up the database for my black-box test cases. This has essentially given me an inherent **mistrust** of unit and integration tests that I have not personally written or reviewed in some way. At some level if you don't have faith in the quality of your test suite then it really brings no value to the team or the project whatsoever. What do you do when you find yourself in this situation? What do you feel the best plan of attack would be to tackle something like this? Should all of the tests be refactored in a monumental effort spanning across releases? Should you just abandon the idea that this legacy project may have one day solid unit test coverage?


Is it still relevant to learn C these days?

Back in the uni days, I had the opportunity to study C for one semester but I didn't take it any further because I can not see many job opportunities for C hence I learnt Java. These days I see more things are made with C, mainly programming language and database server. Is it still relevant to learn C? Will learning C land me a job these days?


Is this agile? Scrum? How to improve agility?

Is this **agile**? **Scrum**? Any suggestions on how this can be made more agile under the circumstances? Which points are positives and which can be improved?   * The product is developed for a customer who will re-sell it while paying us royalty.   * The team does not get to talk directly to the end user. Only to the reseller.   * A product requirements document was created before starting development.    * The requirements are rigid and do not change.   * A delivery schedule was agreed on with milestones such as "alpha", "beta" etc. and features/times attached to those milestones.   * All developers on the Scrum team report to the product owner, a software manager.   * Testers on the team report to a QA manager.   * The product owner has directed the team towards certain high risk technical tasks. The output of those tasks is not usable by the end user but rather some technology/code that will eventually be used in the product.   * The product owner has created a backlog based on the requirements.   * The product owner is unable to answer some questions regarding the product. He refers to others or to the documented requirements.   * The team goes through the motions of Scrum. Daily Scrum, Sprint Planning, Retrospective etc. There is a ScrumMaster.   * Every sprint the product owner and management decide what backlog items the team works on.   * There is a burndown chart. Scrum board with stories and tasks. The estimates on those come from the team.   * The team sits in an open floor "bull pen" shared with other teams, all visible and audible. There is cross-team noise and there is foot traffic around the team area.   * The team may be required to attend various meetings not directly related to the goals of the sprint.   * There are pressures to select certain technical solutions. Some tools and processes are mandated.


Microsoft exam 70-536: How to memorize all of this?

After 6+ years of .NET development, I decided to take the exams and get my certifications to fill in the gaps in my knowledge. I'm taking exam 70-536 (.NET Framework Development Application Fundamentals) in 18 days. Taking the practice exams, I notice that these questions are about minute details of dealing with the BCL libraries the exam focuses on. They aren't so much about "Here's your scenario. Which classes or approach is appropriate". It's more like "One of these (4) choices executes correctly. Which one?" Fine and all, but this is stuff that I could look up on MSDN in two seconds, but the exam is requiring you to memorize them! These questions could come from any of the thousands of classes that are covered in this exam. This is hard-core memorization. Are there any suggestions for memorizing so much information? Any patterns in the way the classes are developed that I could leverage in educated guesses in case I can't remember the exact syntax? For what it's worth, I have spent a lot of time preparing for this exam, so I'm not just trying to pass and get through it, I have learned a ton. But to pass, I need to have a LOT memorized, not just an understanding of the BCLs.


What is the real difference between a minified and uncompressed file? What are the benefits of each?

I often see something like "uncompressed for development / minified for production" when reading blogs or downloading frameworks. What is the real difference between the two, and if minified is "good for production" why is it not recommended for development?


Role of Quality Assurance (Not testing!) in Agile

From Wikipedia: > Quality Assurance refers to administrative and procedural activities > implemented in a quality system so that requirements and goals for a > product, service or activity will be fulfilled.[1] It is the systematic > measurement, comparison with a standard, monitoring of processes and an > associated feedback loop that confers error prevention.[2] This can be > contrasted with quality control, which is focused on process output. You can read the following article to understand the difference between QA and testing (quality control): http://blogs.msdn.com/b/alanpa/archive/2006/02/26/539527.aspx What I'd like to understand is whether there is a place for QA engineer who is not a tester in Agile/Scrum. Agile is deliberately short on processes and documentation (its even in the manifesto), and that's what QA specialize in. So should there even be a QA engineer in Agile? I myself am not a QA engineer (I am a test lead), but I have a friend who is, so that's why I am asking.


I have free time for Android development. I'd like suggestions on how to tackle this effectively

I'm finishing college for good tomorrow, then leaving my current programming job the next day. I'll be looking for opportunities, but I may end up with a month or two without a job, so with lots of free time to work on my Android development skills and improve my value for those jobs. I started thinking about what I'll be doing to make the most out of all this time, and figured I'd need a good plan. I haven't coded too much in Java, but feel like I can grasp the syntax quite quickly. I have already played with ADT and the whole Android setup a bit, but never completed an app due to lack of time. I'm looking for tips in order to finish the next month with the best skillset I can get in that time. Where to start with, tutorials, what to learn first, and so on. By the way, I do have an android device, so the emulator slowness or learning curve won't be an issue. Thank you


At what point do immutable classes become a burden?

When designing classes to hold your data model I've read it can be useful to create immutable objects but at what point does the burden of constructor parameter lists and deep copies become too much and you have to abandon the immutable restriction? For example, here is an immutable class to represent a named thing (I'm using C# syntax but the principle applies to all OO languages)               class NamedThing     {         private string _name;             public NamedThing(string name)         {             _name = name;         }             public NamedThing(NamedThing other)         {              this._name = other._name;         }         public string Name         {             get { return _name; }         }     }      Named things can be constructed, queried and copied to new named things but the name cannot be changed. This is all good but what happens when I want to add another attribute? I have to add a parameter to the constructor and update the copy constructor; which isn't too much work but the problems start, as far as I can see, when I want to make a _complex_ object immutable. If the class contains may attributes and collections, containing other complex classes, it seems to me the constructor parameter list would become a nightmare. So at what point does a class become _too complex_ to be immutable?


Question regarding Readability vs Processing Time

I am creating a flowchart for a program with multiple sequential steps. Every step should be performed if the previous step is succesful. I use a c-based programming language so the lay-out would be something like this: **METHOD 1:**               if(step_one_succeeded())     {         if(step_two_succeeded())         {             if(step_three_succeeded())             {                 //etc. etc.             }            }     }      If my program would have 15+ steps, the resulting code would be terribly unfriendly to read. So I changed my design and implemented a global errorcode that I keep passing by reference, make everything more readable. The resulting code would be something like this: **METHOD 2:**               int _no_error = 0;          step_one(_no_error);     if(_no_error == 0) step_two(_no_error);     if(_no_error == 0) step_three(_no_error);     if(_no_error == 0) step_two(_no_error);      The cyclomatic complexibility stays the same. Now let's say there are N number of steps. And let's assume that checking a condition is 1 clock long and performing a step doesn't take up time. The processing speed of Method1 can be anywhere between 1 and N. The processing speed of Method2 however is always equal to N-1. So Method1 will be faster most of the time. Which brings me to my question, is it bad practice to sacrifice time in order to make the code more readable? And why (not)?


Handling Errors In PHP When Using MVC

I've been using Codeigniter a lot recently, but one thing that gets on my nerves is handling errors and displaying them to the user. I've never been good at handling errors without it getting messy. My main concern is when returning errors to the user. Is it good practice to use exceptions and throw/catch exceptions rather than returning 0 or 1 from functions and then using if/else to handle the errors. Thus, making it easier to inform the user about the issue. I tend to go away from exceptions. My Java tutor at university some years ago told me "exceptions shouldn't be used in production code it's more for debugging". I get the feeling he was lying. But, an example, I have code that adds a user to a database. During the process more than 1 thing could go wrong, such as a database issue, a duplicate entry, a server issue, etc. When an issue happens during registration the user needs to know about it. What's the best way to handle errors in PHP, keeping in mind that I'm using an MVC framework.


Open source custom work

Many of the custom projects I take include things that could be useful to the open source community. I'd like them to open Github repos with them :) Most of them are jQuery plugins. I'm almost always ending up creating my own jQuery plugins for features I need to implement in the project, for example autocomplete, edit-in-place functionality etc. Would it be a good idea to offer a "discount" for people that accept to let me open-source part of the project? Like -15%, -25% etc? Do you think it would be unprofessional to ask them this?


Is there a marketplace for crowdfunding OSS work?

Currently there are a few OSS projects that I would like to create and then use, but I just don't have the time to put into the creation of them, or in the case of some projects (e.g. Emacs packages), don't have the experience with the language. I would be happy to pay someone else to do the development, but probably not to the tune of the whole development (assuming the minimum someone would work for is ~$5000). However, whilst discussing one of these projects with another programmer they expressed interest in using it, leading me to believe that there would be others similarly interested in the successful creation of one of these projects (or possibly not, but for arguments sake assume that the project would be useful to more than just me). It seems like the kind of thing that something like a cross between gun.io and Kickstarter would be suited to, in that it would both attract developers and allow others interested in seeing the development occur to suggest projects and put money towards the effort. Is there a platform that exists for this sort of crowdfunding to occur? NB. Kickstarter and its ilk seem more suited towards discrete products (like CMS systems and various applications), but maybe that is the best marketplace for it.


No programmer will build my semi-adult website. Why?

I've been looking for get this website done for a long time. I thought with a well organized write-up of what I wanted, as well as having clear examples done in photoshop of faux pages to give an idea of the vision, and no hidden surprises, I would be a programmer's dream job. Unfortunately, no company will touch the website. There is nothing illegal about it or even remotely offensive. It's an adult listing for professional Dominatrices. I don't see what the big deal is, when there are way worse and more hard-core sites out there, and this is just a listing. Pro Domination is a legal occupation in the USA and most of the world. People just don't want to touch the site. It's really strange. I have all of the information and details of the site laid out perfectly and clearly. I just either get no response or people who tell me they won't touch anything remotely adult. Is there a reason for this?


Should I ask for advance payment on custom work?

...for project-based work. So far I didn't, and always got paid when work was complete and didn't ran into any problems. Does this make me look unprofessional? :) Should I ask like 25% - 50% advance before I start working? The work I usually do also includes graphic design to some extent (user inteface for my app)


Improving the Java development workflow

I will like to assist my group standardize to a reproducable Java tooling environment that aligns with some good practices to improve on our workflow. We are predominantly a .NET shop that has been doing quite a bit of Java development recently and have been burned too many times with our current Java development process. The process is ad-hoc, since we are kind of new to all things Java. Each developer decides on their tool of choice (somewhat a good thing) and due to the lack of any kind of procedure in terms of 3rd party dependency management, we more often than not run into build or deployment problems and hit serious setbacks when developer machines have to be rebuilt for one reason or another. Our Java development environments are simply neither consistent nor repeatable from one machine to another. We do not have a similar problem with our .NET projects. Everyone runs the same version of Visual Studio, Resharper, and all 3rd party and open source libraries. Possibly because we pay for most of the stuff but there is also a consistent pattern across our C# projects where everything one needs is encapsulated into the solution file and all 3rd party dlls required for this solution are checked into sub a directory relative to the parent solution in source control. Visual Studio helps here too with its version check but this process is working well and I feel it could be replicated for our Java development efforts. To help achieve this goal, I have compiled the following list of questions to gauge what the experts are using out there.   1. What Java development IDE do you use? Eclipse, NetBeans or **IntelliJ** ?    2. Do you use a dependency management tool such as **Apache Maven** , Gradle, a standardize home grown solution, or does each developer determine what works best for them? What we have    3. If the answer to 2, is yes, how do you integrate such tools with your build system?   4. Do you standardize on a specific version of the IDE, related tools and runtime? For example, are all devs running Eclipse IDE for Java EE Developers 3.7, IntelliJ 12.1.6, JDK1.7 or 1.8 and are there any policies to enforce that all devs are using the same version?   5. How do you ensure that projects settings are consistent and repeatable across dev machines? Do you mandate checking in all of a project settings into source control or just the respective source files?    6. For each tool, including IDE, dependency management and build, what selection process did you use? Items highlighted in bold is what we are learning towards based on past experiences. But it will be good to learn from what others are doing. I will start by answering some of the questions, listing some of the problems we are facing:   1. Every developer uses Eclipse. However Eclipse and JDK versions could differ from one machine to another. Dev A could be running Eclipse Juno with JDK 1.6 while Dev B is running Eclipse Galileo with JDK 1.7. The build machine could be running something different and we will only know there is a problem next morning when build is broken. WIth resources also distributed across continents, this causes serious headaches. For IDE standardization, I am leaning towards IntelliJ for usability and consistency, just to name a few.   2. We do not use any such tool. Instead all 3rd party libs are stored in a 3rdParty central folder outside of the solution tree. Then we have an Eclipse project setup to reference these JARs. This works well but this 3rdparty folder is very large. So if you do not want to selectively checkout the JARs you need just to get this project compile, you are in for a long morning waiting to check out the entire 3rdParty folder from SVN. For dependency management, I am leaning towards Maven.   3. We use raw ANT scripts. Each developer needs to ensure that all the stuff required to build the project is checked into source control. But because these resources are all over the place, remember, the 3rd party folder is not part of the project tree, it is very easy to forget checking in that new dependent JAR downloaded from somewhere. And if you use Maven, like I do, I need to copy the JAR from my local Maven repo to the relevant centrll 3rdParty folder so that the build machine does not complain. However, there is still a good chance that this build will fail since the build environment could also be different. For build and packaging, I am also leaning towards Maven to ensure that the build environment is similar to the dev environment. I want to relieve the pain of having to remember where to put dependencies.   4. No. See answer 1.   5. We do not, possibly because we are not saving the entire Eclipse workspace into source control. So if I receive a new machine and check out an Eclipse project, I will have to spend a good portion of my day configuring project settings that should have been saved in source control. TIA for all comments. **EDIT:** Just to add that we do have a CI server and use Jenkins/ANT scripts for building. Klaus


Should we attempt to review all our code?

We're currently modifying out development process and I'm wandering if we should try to keep a 100% of our commits peer reviewed. What is your experience regarding code reviews?   * Do you tend to spend "a lot" of time on them (say 1/2 hours per day), or just skim over for 5/10 minutes max?   * Do you have a fixed amount of time to spend per day/week/sprint/project ?   * Most importantly do you think that the target should be for 100% of the code to be peer reviewed or that 100% is not necessary?


What is the technique called in which you return a never ending http response to keep returning lines of javascript for dynamic update effect?

There is a technique in which you don't end the response and this allows you to send content to the client in chunks like pieces of javascript or maybe xml document that can be parsed on the client side and give an effect of updating something in real time instead of polling the server again and again. Was there such a technique or am I dreaming? Do you have reference to an online article explaining this?


Paying for training when resigning?

Hi Programmers Community. I came across the following predicament during the past month when an employee at my company resigned. It is the company policy that when you resign, all training that you have undergone during the year prior to your resignation, you have to pay back. This is all good, as this is practice in a lot of companies. What happened was, a few months ago, a certain course was presented by an external company. We offered a room in our office as venue for free, and then we were allowed to send some employees on the training for free. He was one of them. Should he pay back the training costs (which was quite expensive)? Has anyone come across a similar situation? Or does someone have policy regarding this? Thanks! * * * **UPDATE** Just to clarify a few things. The training was _kind of_ optional (the senior developer chose who to send, but I'm sure he could have said no). It **was** however very much work related. It was training regarding a technology that we use every day. Also, it was not internal training, it was done by an external company. It was however done on our premises. That was the deal, they use our venue for free, and we send people on the training for free.


How do I explain a ruby method with a real-world analogy?

I am looking for a good analogy to help the concept of a method in ruby stick in my head. When I truly understand a concept, an image flashes in my mind that relates something physical to the abstract concepts I am trying to learn. For example, someone explained the concept of a variable to me in the following way: > A variable is like a box you can put things in. The name of the variable is > like taking a sharpie and writing a word, like "forks" on the side of the > box. Picking a good name is important. You can stick anything in the box, > but if you write 'forks' on the side of the box, you would expect forks to > be in the box. You can put anything in the box, then carry it around to > various people, and tell them "there are forks in this box." When they need > a fork, they go to the fork box and get out a fork. That's the sort of physical, image-based, concrete analogy I am looking for for a ruby method. Right now most definitions I have found are useless to me. For example, at turtorialspoint, the first result for the google search 'what is a ruby method,' has the folowing definition. > Ruby methods are very similar to functions in any other programming > language. Ruby methods are used to bundle one or more repeatable statements > into a single unit. Let me give you an example of why this definitions is useless to me. I'm going to replace every word and concept in this definition that I don't understand with the word 'blah.' > Ruby blah are very similar to blah in any other programming language. Ruby > blah are used to blah one or more blah blah into a single blah. In summary, can I get a good, physical analogy for the concept of a method in ruby?


Match buyers and sellers based on date ranges and quantity of shares

_NOTE: This is in reference to the question Iasked on Stack Overflow but was told to post this here_ I'm building a trading application that matches buyers/sellers that own subscription. Subscriptions have a certain quantity amount for a certain duration of time. There are 8 order types which are:   * Buy/sell subscription (can either be partially filled in regards to quantity or time)   * Buy/sell all quantity subscription (can only be partially filled in regards to time)   * Buy/sell all time subscription (can only be partially filled in regards to quantity)   * Buy/sell all quantity and time subscription (cannot be partially filled, all or nothing) Each user that fills the * * * # Example 1 Assuming all orders in this example can be partially filled in regards to quantity and time lets say User A places a buy order asking for 100 shares between 1/2/2014 - 1/3/2014 (dd/mm/yyyy). There are 4 sell orders currently in the order book   * User B is selling 25 shares between 1/1/2014 - 5/1/2014    * User C is selling 50 shares between 1/1/2014 - 15/2/2014    * User D is selling 70 shares between 10/2/2014 - 1/7/2014    * User E is selling 5 shares between 15/2/2014 - 25/2/2014 Which would look like               User A                 |--------------100-----------|     User B    |----------------------------25-----------------------|     User C    |-------------------50---|     User D                       |--------------70------------------|     User E                             |--5--|      After the matching is done each users orders in the order book would look like               User A                 |-25--|           |----5-----|     User B    |------25----|                            |----25-----|     User C    |------50----|     User D                                              |----70-----|     User E has no open orders      After all said and done the order book would look like:   * User A is buying 25 shares between 1/2/2014 - 10/2/2014   * User A is buying 5 shares between 15/2/2014 - 1/3/2014   * User B is selling 25 shares between 1/1/2014 - 1/2/2014   * User B is selling 25 shares between 1/3/2014 - 5/1/2014   * User C is selling 50 shares between 1/1/2014 - 1/2/2014   * User D is selling 70 shares between 1/3/2014 - 1/7/2014   * User E isn't selling anything # Example 2 This example is exactly the same except User B is of sell all quantity and time subscription type. In other words User B wants to sell his/her's entire position. After the matching is done each users orders in the order book would look like               User A                 |-50--|     |--25-|----30----|     User B    |----------------------------25-----------------------|     User C    |------50----|     User D                       |-20--|                |----70-----|     User E has no open orders      After all said and done the order book would look like:   * User A is buying 50 shares between 1/2/2014 - 10/2/2014   * User A is buying 25 shares between 15/2/2014 - 25/3/2014   * User A is buying 30 shares between 25/2/2014 - 1/3/2014   * User B is selling 25 shares between 1/1/2014 - 5/1/2014 (doesn't even match because this order doesn't allow partial filling)   * User C is selling 50 shares between 1/1/2014 - 1/2/2014   * User D is selling 70 shares between 15/2/2014 - 25/2/2014   * User D is selling 70 shares between 1/3/2014 - 1/7/2014   * User E isn't selling anything * * * # Process Another requirement is I need to be able to keep track of how the orders are filled in the database. When User A's buy order comes in it will first match to User B's which would result in:               User A                 |--------------75------------|     User B    |------25----|                            |----25-----|      Both of those states would need to be saved to the database. Once that is complete then User C's order is matched up, which would look like:               User A                 |-----25----|------75--------|     User B    |------25----|                            |----25-----|     User C    |------50----|      Keep going:               User A                 |--25-|     |-------5--------|     User B    |------25----|                            |----25-----|     User C    |------50----|     User D                                              |----70-----|      * * * # Question Is there any existing algorithm to do what I'm asking? **EDIT** : After some searching it sort of seems like I'm after an interval tree or a segment tree where I can sum up what's in the tree for a given time range. However I need to be able to store the modifications to the tree in a database with the start and dates. Are there any implementations out there of this done with LINQ or SQL? **EDIT 2:** In my first edit I thought it was an interval tree but now it looks more like bin packing algorithm


Hoes dows the productivity incidence of Lisp and OCaml compare?

I am about to start a new project and I cannot decide if I should pick OCaml or Lisp for the project. My main concern is about the difference of productivity — if any. I program OCaml since 1998 and, while I neither tried to measure this precisely nor to even define precisely what the productivity I would like to measure is, I am pretty confident that I am more productive with OCaml than I am with more classical languages I know, as C or Python. I think so, because the compiler is so good at catching my errors, that only the smart bugs make it to the final program—but these are usually easy to find, like some logic piece being semi-obviously wrong or system resources inappropriately manipulated. I never invested in learning the debugger of OCaml — which by the way can go backwards in the time—because I had never felt I needed using it. The language has a module system allowing generalisation of structures by means of _functors_ and a preprocessor `camlp4` which can be used to extend the language, like implementing automatic serialisation of values. This is of course something that Lisp has not—but I tried Slime in Emacs, and it looks to include an all-mighty debugger and code explorer. But Lisp has macros. Unfortunately, my knowledge in Lisp is almost zero—I toyed around with it about one afternoon—and I am therefore unable to compare macros with `camlp4`. To me, it seems that:   * Lisp macros are much easier to write than `camlp4` extensions.   * Lisp macros are much easier to use as modules or `camlp4` extensions. Functors, when used to implement a functionality similar to _traits_ are quite clumsy, verbose, and require odd-looking idiosyncratic invocations: on the other side, Lisp macros just look like anything else in Lisp (S-expressions).   * Lisp macros do not raise an engineering problem, they belong to a package, dot. Functors do raise engineering problems because type names receive aliases, which is puzzling. (As a side note, it looks to me that Lisp is easier to get started with than OCaml is, at least for the bunch of quantum physicists wanting to join the project.) Can anyone compare the incidence on productivity of OCaml and Lisp (pick the one you want)?


Brainstorming software

Does anyone have any experience with brain storming software for early stage design work? If so, do you have any recommendations for particular software to use? Or to avoid? To pre-empt certain possible answers: I'm aware a blank bit of paper serves well but I'm interested in using software in this instance.   1. So I can refine the results easier than copying it out into paper.   2. Easily move the results between locations/store in dropbox. Some further information: Brainstorming is perhaps a misnomer in this case, more of a brain shower. The software would be used by 1 person only (me) for my personal projects. Of course anything that can also deal with a more corporate setting would also be good as if I use it and like it I may try to introduce it to my team. Further further info: After asking this question I found Xmind, and I've been playing with it for half an hour or so. My first impressions are that it is pretty good.


Why is software OS specific?

I'm trying to determine the technical details of why software produced using programming languages for certain operating systems only work with them. It is my understanding that binaries are specific to certain processors due to the processor specific machine language they understand and the differing instruction sets between different processors. But where does the operating system specificity come from? I used to assume it was APIs provided by the OS but then I saw this diagram in a book: ![Diagram](http://i.stack.imgur.com/BmED2.png) _Operating Systems - Internals and Design Principles 7th ed - W. Stallings (Pearson, 2012)_ As you can see, APIs are not indicated as a part of the operating system. If for example I build a simple program in C using the following code:               #include<stdio.h>          main()     {         printf("Hello World");          }      Is the compiler doing anything OS specific when compiling this?


What is an Activation object in Javascript?

In a given execution context, the Variable object is the Activation object of that execution context. From my research online, I am able to find the previous sentence rephrased in different ways but no one is able to tell what it is. What is an Activation object?


Notify players every x seconds in a multiplayer game

I'm working on a realtime multiplayer game using Django and gevent-socketio, I'm facing some issues: I need to send an update of the game state to connected players every X seconds (~4 seconds), so basically I need to execute a function every x seconds which does some calculations and sends the connected players the new game state. What is the easiest way to achieve this? is using cron a good choice here or should I look for other tools like celery or ...? Also, the function needs to operate on some data. querying the database every time the function is executed does not seems to be a good idea, where can I store the game data (which is updated frequently during the game)?


Acceptable placement of the composition root using dependency injection and inversion of control containers

I've read in several sources including Mark Seemann's 'Ploeh' blog about how the appropriate placement of the composition root of an IoC container is as close as possible to the entry point of an application. In the .NET world, these applications seem to be commonly thought of as Web projects, WPF projects, console applications, things with a typical UI (read: not library projects). Is it really going against this sage advice to place the composition root at the entry point of a library project, when it represents the logical entry point of a group of library projects, and the client of a project group such as this is someone else's work, whose author can't or won't add the composition root to their project (a UI project or yet another library project, even)? I'm familiar with Ninject as an IoC container implementation, but I imagine many others work the same way in that they can scan for a module containing all the necessary binding configurations. This means I could put a binding module in its own library project to compile with my main library project's output, and if the client wanted to change the configuration (an unlikely scenario in my case), they could drop in a replacement dll to replace the library with the binding module. This seems to avoid the most common clients having to deal with dependency injection and composition roots at all, and would make for the cleanest API for the library project group. Yet this seems to fly in the face of conventional wisdom on the issue. Is it just that most of the advice out there makes the assumption that the developer has some coordination with the development of the UI project(s) as well, rather than my case, in which I'm just developing libraries for others to use?


Distributing a data access solution across multiple solutions

I have 3 solutions, one of them is a dataccess solution with all the repositories etc. At the moment when a change is made to it, the others have to go get the latest nuget version locally, we have a nuget server on the LAN. Its a pain to debug though. Would a git submodule work here to enable debugging and not worry about updating nuget packages?


Examples of designing a database that handles point tracking?

I'm attempting to expand my knowledge of how database designs and concepts work. I'm working on a hobby web/mobile app for practice that will challenge me. However, I am running into an issue. What my novel concept is that there are two buttons 'yes' and 'no'. The buttons can only be clicked once a day. If 'yes' is clicked then a counter keeps tracks of how many clicks (days) it has been pushed. Example "You've tied your shoes 95 days in a row!" If 'no' is clicked then the counter "resets" for example "It has been 0 days since you've tied your shoe." I've done some reading but I haven't been able to find too many examples that are like this. I've read several posts here (a sample of them below) ( implementing dynamic query handler on historical data Storing stop/start points in a database In an online questionnaire, what is a best way to design a database for keeping track of users all attempts? ) but I'm still pretty confused on how to move forward. My initial idea was to have a user table (id | user | password) points table (id | point | date) If a person clicks on yes then it adds an entry into the points table. If they don't click anything then no entry occurs. If they click no it's a -1. However, I'm not certain this is a solid way to build out the database especially if I want to track it. My questions are:   1. Given the few tasks above, how to setup the database?   2. How would I be able to display a counter that once someone hits no it 'resets'? For example the database tracks that the individual has tied their shoes for the last 9 days in a row but once they say no they didn't tie their shoes the counter resets to 0.    3. How to proceed with analytics side, to show how many times they've clicked no, yes, so on but that's down the road.


REST API internal directory structure and RewriteEngine

I'm building a REST API. I don't want to have _real_ folders in my directory structure, but I'm not quite sure what to use else. My REST API uses paths like this:               api.server.com/<object>/<action>[/]      Here, `<object>` is the object the action `<action>` should be performed on. For example, a URL `api.server.com/user/create` would create a new user. For now, I've come up with this:   * The objects all have their own file, like `user.php` for the object `/user/`. In the GET variable `action` a string determining the action is stored.   * I'm using a .htaccess rewrite script to rewrite the fake directories to these internal paths:              RewriteEngine On     RewriteRule ^(.*?)/(.*?)/?$ $1.php?action=$2 [NC,L]      However, I'm not sure if this is the best way of setting up a REST API. Would there be any obvious problems I'm missing here? How does the internal file tree of a REST API usually look, or can't that be reasonably said? What are the pros and cons of different approaches?


Is it possible to get a programming job with a bad credit history

I'm studying/practicing to be a software developer but I'm worried that my bad credit history will prevent me from getting a job as a developer. I was laid off a few years ago and went through a period where everything went wrong. I was able to bounce back with a couple part time jobs and now I have a dead-end 40k a year job. Currently my credit history shows 2 foreclosures and credit card debt. I'm gradually paying off the credit card debt but my credit history will look horrible for a few years. BTW, an adviser told me to file for bankruptcy but that sounds like it will only makes things worse. I already feel as if I'm too old (34 years old) to enter this competitive career but I don't have much of a choice because software development is my only interest. I currently code .NET desktop apps for personal use and I've been getting into web development lately. I believe I can convince a potential employer to look past my age but I just feel as if no software development company would hire me over a 23 year with a clean slate. From what I've read, "job hopping" seems to be normal for software developers so even if I get my first programming job, when that job ends, I would have to go through the same process of fear again. Does anybody have any advice for someone in my situation?


Suggestions on how can I implement a generic matching system for users?

I need help with coding something. I'm trying to design a system that will allow users to setup rules for the system to process (similar to email processing rules, in a way). When I receive a chunk of data (in this case, it is a object that has properties with values related to the client system's hostname, OS version, etc.) I want the user to be able to create a criteria like "when the hostname equals 'somehost' or the OS version is greater than 6, etc. The table I have so far has a record ID, a column for holding the name of the value I'm checking (like the property name, e.g. object.Hostname stores as "Hostname"), a two character code for the operator (EQ, NE, GT, etc), the value to compare against and a foreign key value. I don't have a warm fuzzy about it, though. Am I going down the right path? I wanted the matching to be flexible. I'm visualizing putting the class properties in a dropdown so that the user can select the property, type in a search value and select the criteria. Thoughts? Thanks!


Parallel Programing in C#

I have a code where I have to read some Binary files in database. I wrote a For loop that iterate over my file path array, then it call a READ function that read that file into database. I run this code with traditional for loop everything goes smooth, but then I change the for to Parallel.For and it doesn't go smooth, I adjust my code as I found lot of gray area and shared resource are creating problem in loop logic. So, I make everything Isolated to 1 Loop iteration. Now the parallel method make my code run fast with twice the speed with one exception. The Exception is   1. We have 600 files to read, out of 600 we have only 5-6 core big files.   2. Out of these core big files, one or two file didn't get into the database, and no exception is generated. When I simply change Parallel.For to For they all get read, so code within it's scope is fine. Can you suggest a method or alternative to Parallel.For, as I feel like one of core thread just die for no reason, seems impossible stuff, but this is what is happening as I am creating log at each step and different iteration shows thread stop at some other point. Also, though I have 4Core processor it execute as many as 30 -40 files at time. I was expecting it to be like 3-4 thread at most per documentations. Any idea.


Converting a huge decision tree into a decision list for fuzzy matching

I'm trying to build an intelligent action bar _similar_ to the command palette of Sublime Text: ![Sublime Text Command Palette](http://i.stack.imgur.com/yuWSi.png) The Sublime Text command palette allows fuzzy matching of commands in the list (e.g. "ancd vin" will match "Anaconda: Vagrant Init"). That way, it is very easy and very quick to find the wanted action. I'm trying to achieve something similar for the web, the difference is that I have a nested tree of actions available (and some other options), like so (yaml):               new:       name: "New"       choices:         document:           name: "Document"           show_editing_menu: True         template:           name: "Template"           choices:             letter:               name: "Letter"               schema: "template-letter"             spreadsheet:               name: "Spreadsheet"     open:       name: "Open"       choices:         explore:           name: "Explore"         recent:           name: "Recent"      As you can see, I have nested actions available but the final list should look like this for the intelligent-action-bar form to work (this is what I am doing for the moment):               item001:       name: "New"       path: "new"     item002:       name: "New - Document"       show_editing_menu: True       path: "new/document"     item003:       name: "New - Template"       path: "new/template"     item004:       name: "New - Template - Letter"       schema: "template-letter"       path: "new/template/letter"     item005:       name: "New - Template - Spreadsheet"       path: "new/template/spreadsheet"     item006:       name: "Open"       path: "open"     item007:       name: "Open - Explore"       path: "open/explore"     item008       name: "Open - Recent"       path: "open/recent"      For the moment, I'm able to generate a flat list from the original tree but the names are not concatenated:               item001:       name: "New"       path: "new"     item002:       name: "Document"       show_editing_menu: True       path: "new/document"     item003:       name: "Template"       path: "new/template"     item004:       name: "Letter"       schema: "template-letter"       path: "new/template/letter"     item005:       name: "Spreadsheet"       path: "new/template/spreadsheet"     item006:       name: "Open"       path: "open"     item007:       name: "Explore"       path: "open/explore"     item008       name: "Recent"       path: "open/recent"      I will probably manage to concatenate the names into the wanted format in a few more hours. But before fixing this design, I would like to have some external opinions. Having the actions in a tree-like format is very useful for further programming decision making (suggestions depending on parent node, different interface depending on which action/node is selected, settings available inside the decision tree etc.). But is this design maintainable/practical for what I want to achieve ? Do you have other suggestions to have the advantages of the "decision tree" structure and have an easy way to flatten it ? It's my first try at something like this so design suggestions are very welcome. I'm not asking for a library or off-site resource but for design advice. If you have any additional questions, I'll be happy to provide. Thank you very much ! **UPDATE-1** : I've read about action tables but I find it harder to extract the "decision tree" and to maintain. Then, maybe it's best for what I want to achieve but I'm not sure.


How do I bootstrap a P2P service so that users can locate each other?

My P2P app needs to locate peers, but I don't want to hard-code a DNS address... One example I've seen is bootstrapping via IRC, but I'd like to do this over HTTP/s if possible. What are my options and techniques for bootstrapping a P2P app?


Disadvantages to using "associative arrays" in JavaScript

I'm working with some people are are used to making "associative arrays" in JavaScript like this:               var arr = new Array();     arr.prop_1 = "asdf";      or               arr['prop 2'] = "1234";      It works just like an object because it is. `for...in` loops can be used and accessing the properties is fine using a dot or a square brace. the lack of native array methods seems not to be lamented. I find it sort of semantically irritating however. Maybe I'm being picky, but I want a good argument for arresting the use of this syntax, but I can't understand how to start. Any suggestions?


best practice to inter widget communication in javascript

I have quit a lot of javascript widget and I would like to have a good decoupled way to communicate between them. Something like signals and slots in QT probably? Most of my widgets are written in JQuery using widget factory. What is the correct way to achieve that, without ending with a spaghetti code?


C# Linq to <blank> which type is most used and which are most hated/unneeded

I have read and used many good Linq to . I have also read that some of the Linq to ___ _ are not worth learning as there are better techniques. I was just wondering which of the bunch should I concentrate on and which have more suitable alternatives. Thanks


shadow simulation from buildings

is it possible to calculate shadow areas of buildings or simulate shadows of buildings in a city, using the heights of these buildings and the sun angle and azimuth? the basic light tracing concept using trigonometry is known. But the Problem is how to find away to come up with simulated shadow of group of buildings in one place.


How do I tell a senior programmer that I disagree with him

I am a new programmer at my office. I just entered this workplace for about 2 months. I've been working with another senior programmer which is essentially my "mentor" during the introductory period. I've been studying a lot for the past 2 months and I believe I have a good grasp of the system already. And I feel that one of the design decision that this senior programmer made is not very good and I have a better solution. So how do I go about telling him this? I'm not a junior programmer by any means I've been programming for some time. But they are using a custom 4thGL. So I can't say that "I have 5 years experience in .net and this is bad in my experience" or something like that. And we are working on different parts of the system and his part doesn't actually falls under my "jurisdiction" really... But I will eventually end up diving some parts of it sooner or later, and it is a major part of the system and I feel that a lot can be improved by doing things my way. But I don't want to be the snobbish little kid that just joined the company, and I do want an ongoing good relationship with my colleague especially since he helped me so much during the first week or 2 when i was there. But i feel strongly about this. So what is your opinion?