Storing simple / flexible pricing logic in the database

I am working on a pricing algorithm where I want to generalize the calculation of certain components/charges. There are 3 components to the charges. > 1 - a basic/core charge, 2- a handling charge (may have many number of > these), 3- tax components (may have many varieties of these as well). I am wondering if I can store an algorithm like below in a database and use this for calculating the charges every time.. Or is there a better way of handling such pricing in a flexible way? >   * **Step 1:** _Step1Result_ = Sum(value of component1, value of > component2, value of component4) (Let us say the freight charges are the sum > of a few core charges) >   * **Step 2** : _Step2Result_ = Step1Result * .01 (let us say some handling > charge is about 1 percent on the step 1 result) >   * **Step 3** : _Step3Result_ = Step1Result * .103 (let us say some tax on > step 1 result is 10.3 percent) >   * **Step 4** : _Step4Result_ = Step3Result * .0203 (let us say some > special tax surcharge as 2.03 percent) >   * **Total** : _TotalResult_ = step1result + step2result + step3result + > step4result > [Edit] Adding a sample of a logistics freight service which is what we are working on now.   * A Parcel booked may get transported from location A to Location E via C,D and E.   * So the base freight charge is calculated as the cost of transportation between A to B, B to C, C to E.    * The parcel may be unloaded from one vehicle at location D and loaded to another vehicle for which loading/unloading charges may have to be added. This may be a percentage of the transportation charge or an absolute value. There may be additional charges which may be added in the future as well   * Then we may have some other premium facility charges   * We have taxes which will have to be computed not on the entire cost but one tax may go to basic freight charge and the other may go to the other charges and another set will be on the total cost. Now I need a flexible logic so that the calculation is configurable pricing logic for the user. If someone has worked on such a generic algorithm, pls give an idea. Please note that I have searched for such stuff in SO as well as google and unable to come up with a concrete one yet. If I missed something, please feel free to point out. Basically I would like to store the formula and workout the price with it. This logic is going to be implemented in C# and Sql Server.


A good guide on choosing the point scale to use with Agile/SCRUM?

We're using Pivotal Tracker for our project, which lets us choose from these three point scales:               0,1,2,3     0,2,4,8     0,1,3,5,8      And I'm looking for a resource to help guide our decision. (After using 0,1,2,3 for two iterations, we can see where one of the others would be a lot more useful or meaningful.)


How to encourage a non-programmer to learn programming?

Learning programming for the first time may be boring, especially reading a book with boring examples. **Is there other way to learn non-programmers programming?** For example involve them in a simple game project that is fun.


Management wants an API in purchased software

My company wants to purchase new software for our General Ledger. We want to be able to interface it with various other sytems, all purchased. Nothing is custom built. The software our Accountants like does not have any APIs. However it does allow for imports and exports through various file formats. The imports (which are most import to us) can be triggered by an import file being placed in a folder. A "steering committee" that is involved in this purchasing decision is made up of people who are not either IT people or programmers. They're lawyers, a chief executives, a compliance officer and a few others in similar roles. They are fixated on this software having an API, or APIs, I don't which is more proper. It seems to me that with the import and export functionality we can do what we need to do. Since we don't write our own software we couldn't code to an API. But, I don't have enough experience to really know what an API might offer that the software in question couldn't deliver. I chair the steering committee and would like us not to get side tracked by something that I suspect is irrelevant. Can anyone help me to understand what I might be missing, or rather how an API would be advantageous?


How to name a clamp function that only clamps from one side?

Clamp() is a function that ensures that provided variable is in provided range. You can find such function in .NET, in Unity, and probably anywhere. While it is useful, I often need to clamp my value from one side only. For example, to ensure that float is always non-negative or always positive (like radius value from inspector). I used names ClampFromAbove() and ClampFromBelow(), but I wonder if such names is good or even grammatically valid in programming-English. Also, it probably make sense to distinguish non-negative case too. How'd you name such function? Something like EnsureNonNegative()? My intention is creating pair of extension methods and use them like this:               var normalizedRadius = originalRadius.ClampFromBelow(0.0001);     var distance = someVector.Magnitude.ClampFromAbove(maxDistance);


What are the set of skills that every programmer graduating from college should have?

We had a guest lecturer at our school he went on a tangent regarding those graduating and not being upto the skill level he expects ie. knowledge of one big-time compiled languague like Java, C++ or C#, one scripting language like Python or Ruby, one web framework. What are some other skills that you guys think should be absolutely critical to graduating student?


How are multiplayer games designed?

If each player has their own avatar, that can move, jump, and do actions to entities in the world (let's say, boxes). How is it handled? Is clients sending commands to the server and getting the current state of the world in response a viable design?


Designing the perfect range literal

I've been thinking on how I would go about designing the "perfect" range literal if I were to do design a language. For you that don't know know a range literal in a statement that represents a range of values, like 1-4. They're most commonly used in for/foreach loops There seems to a couple of issues one should take into account   * Support for inclusive and exclusive ranges, tacking on +1 or -1 to endpoints seems a bit fugly and errorprone.   * Support for stepping, so you can make a range of even or odd numbers for instance   * Readability, it should be readily apparent what the range literal describes   * Unambiguity, it should be perfectly unambigious what the range literal describes   * The default should probably be from inclusive to exclusive since that's what's used in most cases for looping over arrays etc. Anyways, one example of range literal I've seen is Ruby which is in the form of 1..3 for an exclusive (on the end) range and 1...3 for inclusive (on the end). You can also do 1..10.step(5). After careful consideration I found however a couple of things I didn't like about that approach (from my limited knowledge of ruby)   1. You can only describe inclusive and exclusive for the end. While describing most scenarios it does seem a little inconsistent.    2. Varying by just an additional . seems like a recipe for making it hard to see whether a range is inclusive or exclusive. I don't know about you but dot's tend to become something of a blur :)   3. Adding method like notation for ranges seems to mix the notion of a literal with that of a class which seems a bit inconsistent (even if ranges get compiled to a class) Anyways, after pondering different alternatives. I came up with this   * **[5..1]** 5,4,3,2,1   * **[1..5[** 1,2,3,4   * **]1..5]** 2,3,4,5    * [ **0..5..20]** 0,5,10,15,20 and so forth. I like it because [ normally denonates a set and this kinda fits into that, even though this in contrast to a set would be ordered. One thing I'm a bit torn about though is making the exclusive/inclusive indicators mandatory or not, ie if you write just 1..5 the default would be 1,2,3,4 since it's the most common case with arrays etc. It's easier and more readable, but less specific and if you had to write [1..5[ you learn early about how they work. So what do you think, did I cover most bases, overlook something? would you make the [] mandatory? Would you design range literals differently in your programming language? **Candidates**   * bracket style: **[0..10[** , with step: **[0..5..20[**   * interval notation: **[0..10)** with step: **[0..5..20)**   * exclamation for exlusive. 0..!10, with step: **0..5..!20**     * with different step. 0..!20, 5     * however, that would make the default * _0..10'_ inclusive-inclusive   * wordy: [0 to !20 by 5] I must say that my favorite aestically so far is **0..!10** and **0..5..!20** , I just wish the default **0..10** to inclusive-exclusive would be more logical


Naming library which generates a JSON-req to a REST-API?

How would you call a library which generates a JSON-req to a REST-API so that you just work on object-level for creating a request? Many company wants to define it as an SDK, but is it a suitable definition for this simple task?


How Does The Maybe Monad Relate To The Option Type?

I was doing a presentation on F# and was discussing the Option type when someone in the audience asked me if the Option type is F#'s implementation of the maybe monad. I know that's not the case but I did want to ask how the two concepts are related. I mean it seems to me that an option type might be the result of the operation of a maybe monad but I'm not even sure of that. Would someone elucidate the relationship between the maybe monad and the option type in those functional languages which support it?


Instantiate proper class based on some input

I'm attempting to understand how "switch as a code smell" applies when the proper code path is determined by some observable piece of data. My Webapp object sets an internal "host" object based on the hostname of the current request. Each Host subclass corresponds to one possible hostname and application configuration: WwwHost, ApiHost, etc. What is an OOP way for a host subclass to accept responsibility for a specific hostname, and for Webapp to get an instance of the appropriate subclass? Currently, the hostname check and Host instantiation exists within the Webapp object. I could move the test into a static method within the Host subclasses, but I would still need to explicitly list those subclasses in Webapp unless I restructure further. It seems like any solution will require new subclasses to be added to some centralized list.


Why not have a High Level Language based OS? Are Low Level Languages more efficient?

Without being presumptuous, I would like you to consider the possibility of this. Most OS today are based on pretty low level languages (mainly C/C++) Even the new ones such as Android uses JNI & underlying implementation is in C In fact, (this is a personal observation) many programs written in C run a lot faster than their high level counterparts (eg: Transmission (a bittorrent client on Ubuntu) is a whole lot faster than Vuze(Java) or Deluge(Python)). Even python compilers are written in C, although PyPy is an exception. So is there a particular reason for this? Why is it that all our so called "High Level Languages" with the great "OOP" concepts can't be used in making a solid OS? So I have 2 questions basically.   1. Why are applications written in low level languages more efficient than their HLL counterparts? Do low level languages perform better for the simple reason that they are low level and are translated to machine code easier?   2. Why do we not have a full fledged OS based entirely on a High Level Language?


.Net C# Remote Method Invocation (RMI) (Client/Server communication)

What exactly is **C#** version of **Java RMI**? I want to invoke the methods of client from the server, ping the client from server etc. How the server and client communication is done with c#?


Internal Mutation of Persistent Data Structures

To clarify, when I mean use the terms _persistent_ and _immutable_ on a data structure, I mean that:   1. The state of the data structure remains unchanged for its lifetime. It always holds the same data, and the same operations always produce the same results.   2. The data structure allows `Add`, `Remove`, and similar methods that return new objects of its kind, modified as instructed, that may or may not share some of the data of the original object. However, while a data structure may seem to the user as persistent, it may do other things under the hood. To be sure, all data structures are, internally, at least somewhere, based on mutable storage. If I were to base a persistent vector on an array, and copy it whenever `Add` is invoked, it would still be persistent, as long as I modify only locally created arrays. However, sometimes, you can greatly increase performance by mutating a data structure under the hood. In more, say, insidious, dangerous, and destructive ways. Ways that might leave the abstraction untouched, not letting the user know anything has changed about the data structure, but being critical in the implementation level. For example, let's say that we have a class called `ArrayVector` implemented using an array. Whenever you invoke `Add`, you get a `ArrayVector` build on top of a newly allocated array that has an additional item. A sequence of such updates will involve `n` array copies and allocations. Here is an illustration: ![enter image description here](http://i.stack.imgur.com/ywLvk.png) However, let's say we implement a lazy mechanism that stores all sorts of updates -- such as `Add`, `Set`, and others in a queue. In this case, each update requires constant time (adding an item to a queue), and no array allocation is involved. When a user tries to get an item in the array, all the queued modifications are applied under the hood, requiring a single array allocation and copy (since we know exactly what data the final array will hold, and how big it will be). Future get operations will be performed on an empty cache, so they will take a single operation. But in order to implement this, we need to 'switch' or mutate the internal array to the new one, and empty the cache -- a very dangerous action. However, considering that in many circumstances (most updates are going to occur in sequence, after all), this can save a lot of time and memory, it might be worth it -- you will need to ensure exclusive access to the internal state, of course. This isn't a question about the efficacy of such a data structure. It's a more general question. Is it ever acceptable to mutate the internal state of a supposedly _persistent_ or _immutable_ object in destructive and dangerous ways? Does performance justify it? Would you still be able to call it immutable? Oh, and could you implement this sort of laziness _without_ mutating the data structure in the specified fashion?


How do I do TDD when expected behaviour is to be changed?

I've been doing TDD with a project I'm working on, and I have quite a large number of tests. I have quite a few automated tests around restrictions enforced in code, making sure things that shouldn't be allowed aren't allowed. Now I've been told that due to changes in our licensing model, some of those restrictions need to be removed. Since I've done the entire project using TDD, I'm not sure how to make a change like this also using the TDD mindset. **So, my question is:** Do I make the back end changes and see what tests break, or do I try to find the tests that enforce the behaviour, and change those first? My concern is that if there are operations A, B, C and D where a check is done to disallow the behaviour, and I have equivalent tests TestA, TestB, TestC, and TestD (possibly in different places) no matter which half I change first, I may miss one or two spots and end up with incorrect behaviour, but still have all the tests pass (e.g. what if I miss TestD?)


Block elements vs inline elements in HTML: why the distinction?

The distinction between block and inline elements always seemed strange to me. The whole difference is that a block element takes up the entire width thus forcing a line break before and after the element, and an inline element only takes up as much as the content. Why not just have one type of element- an inline element where you can also apply custom height/width, and use that? You want line breaks? Insert a `<br />`, or maybe add a special tag in the CSS for that behavior. The way it's now, I don't see it solving any problem, and instead it only forces a property that in my opinion should be decided by a designer. So why the two types?


Team workload algorithm

**TL;DR** This questions is about which algorithm(s) can be used for a certain use-case explained below. * * * Imagine this situation in a project management system (Agile-based):               Developers     - John     - Suzy          Testers     - John     - Katy      So John is in both teams. Let's say there are also two simultaneous projects:               Project 1     - Task 1 (2 hours) - Testers     - Another task (4 hours) - Developers     - Last task (2 hours) - Suzy          Project 2     - Some task (4 hours) - John     - Another task (2 hours) - Testers     - Also a task (4 hours) - Katy      Let's say available hours are defined for each person:               John: 8 hours     Katy: 4 hours     Suzy: 10 hours      Now I want to calculate the optimal workload for each person / team. This is being complicated by the fact that persons can be in more than one team and the fact that tasks can be assigned to both teams and individuals. A useful outcome of this could be the following example stats:               John: 150% workload     Katy: 150% workload     Suzy: 60% workload      This can be used for fine-tuning the amount of tasks within one sprint to fit a certain time period. * * * Does anyone know an algorithm that is made for this kind of problem?


Mulitple processes aware of each other

Hope you can help me with this, I've searched a lot and I got really confused of what to do here. I'm building a program in C and I need to run it multiple time as I need. So it's going to be like below, process 1 handle all rows on DB table test where process_flag=1   process 2 handle all rows on DB table test where process_flag=2   process 3 handle all rows on DB table test where process_flag=3   and so on How can I make the processes aware of each other, so if process 3 goes down then processes 2 & 3 start working on process_flag=3?


VB.NET - Serial Key Generating (Encryption, Hashing, Encoding?) Algorithm

I am trying to create a basic licensing system where I take a unique ID from the client computer, and I get this Hexadecimal string (hyphens removed e.g. "84-18-CE-...."): > > "8418CFEE73FA22E6AB0760C73A496497C6C347DA88A9F63B95FE1E1D6A350AA1D7D3A9EE870795AECC3C109AA8B4A78C" It's only encoded into this format to make the ID longer. Basically what I've been trying to do (without success), is to create some routine that can transform this string into a 25-character long (minus the dashes) string like the one below: **`"H8G02-J8293-L02O9-S920Q-F8D9X"`** _(An alpha-numeric key with numbers or letters in no particular pattern, preferably letter,number, letter or vice versa)_ I just can't figure out how I could then validate this key, so that I could extract the untransformed Hex string we began with.   * Note that the original Hex string will not always be the same length. Also, a routine that will convert ANY string into such a format (alpha-numeric, caps-only) will be acceptable.   * I just realized that perhaps this isn't possible (to shorten the string down to 25 characters, and still retain the information (silly, I know). I will now accept anything that will allow me to create a 25-character OR LONGER string, from which I can select 25 characters.


Scala string interpolator: ad-hoc feature of general construct?

In Scala 2.10 a new **string interpolator** feature has been added (see here). For example               val name = "James"     println(s"Hello, $name") // Hello, James      What is not clear to me is whether this feature is an ad-hoc addition or whether it is syntactic sugar for some other, more general construct. The only thing I can think of is that the compiler turns a string literal like               s"Hello, $name"      into an expression like               "Hello, " + name      but still, this seems to me a very special treatment of string literals (see also the related question on XML literals). Or is this a particular application of some more general Scala construct? **EDIT** Thanks for the feedback. I had read the whole article but probably my summary was not accurate enough, making the point of my question unclear. Thanks to Jörg for the good summary. What puzzles me is that the compiler expands a special string literal into an expression that contains names defined **inside** the string itself. The resulting expression must be re-compiled to check that the names of the arguments used to call the `StringContext` instance are defined in the current lexical scope. This looks like some kind of pre-processing to me (first pass: expand special literals, second pass: compile) because the value of the token `s"Hello, $name"` is preprocessed and expanded into a whole sub-tree of the syntax tree. This expansion is built-in into the compiler: as far as I know it cannot be defined in terms of the language itself by means of more primitive features taking the string literal **as it is** as input because the names defined inside the string must be extracted and interpreted as variables from the lexical scope. For example, (as far as I understand) no Scala method can be called with the string "Hello, $name" and find out that there is a variable `name` in the lexical scope of the expression where the method has been called. Therefore, it is the compiler that has to write out               StringContext("Hello ").s(name)      and then re-compile the result, check that the variable `name` exists, and generate a proper method call. Summarizing, I find this reference to a variable in the lexical scope from within a string literal very strange, it seems something is happening on a different level of the language. I do not know how to explain this in a better way.


Status of stack based languages

I have recently become curious about Factor, which, as far as I understand, is the most practical stack-based language around. Forth seems not to be used much these days - I think it is because it was meant to be used on its own, instead of inside an operating system, although ports of course exist. It is also pretty low level. Joy is essentially dead, as the author stated that it does not make sense to mantain it in spite of adopting Factor. The fact is that Factor itself does not seem much developed today. The GitHub repository does not seem very active, and a lot of stuff languishes in `unmantained`. So, are there any other languages of this type that are more actively mantained? Are any in production use?


Why does DrRacket IDE considers some identifiers as "symbols" and some as "keywords"? What is the difference?

Why does DrRacket (kind of Scheme) IDE highlights some of the identifiers as "keywords" (for example `define`, `lambda`, `send*`), and the others as "symbols" (user defined identifiers, `+`, `-`, `abs`, `send`, `send+`, etc.)? I am particularly confused by the difference between `send*` and `send+`. For reference, here are the beginnings of their definitions:               (define-syntax (send* stx) ...          (define-syntax (send+ stx) ...      (It is possible that I do not use the terms "identifier", "symbol", and "keyword" completely correctly, but this is how some of them seem to be used in DrRacket preferences.) Unless this is a bug, it must be explained by the language "semantics", so I decided to ask here.


When to store values in constants/finals

This might seem like an odd question, but I'm worried that I'm putting too many things as constants/finals at the top of my java class. I've started to put every value that is in my program into a constant (At least the ones that influence it's overall effect). The reason I'm doing it is because then it's easy to find the values and change them latter, even if they are only used once, it's easier to find them at the top. Is this a bad or good practice, I really have no idea. Here's an example:               private static final Color COLOR_SELECTED = Color.BLUE;     private static final Color COLOR_ALTERNATE_ONE = Color.WHITE;     private static final Color COLOR_ALTERNATE_TWO = new Color(240, 240 , 240);     private static final Color TEXT_COLOR = Color.black;


Should the variable be named Id or ID?

This is a bit pedantic, but I've seen some people use `Id` as in:               private int userId;     public int getUserId();      and others use:               private int userID;     public int getUserID();      Is one of these a better name than the other? Why? I've seen this done very inconsistently in large projects. If I were to set a standard which would most people be familiar with? Which is the conventional standard?


Java web application folder structure

As a beginner to J2EE, I have recently started developing my own project from scratch using the Core of J2EE : Servlets & Jsps. I could not evaluate whether my project folder structure is right or not. Here is my project folder structure. ![enter image description here](http://i.stack.imgur.com/pmpU9.png) Before asking question, I admit that I could not answer or neither justify if somebody asks me, why this type of folder structure. The question: Is it a good sign to put my jsps outside of web-inf. If not, why is it so? If yes why? Is there any standard folder structure convention for a J2EE web application, I know maven has brought up some standards but still, we can customize as per the requirement I believe. I have done a bit of googling and found the two references 1 2 where in the answers are not on the same page, from which I couldn't draw any conclusion. What are the points to be considered while laying out the folder structure for a J2EE web application, importantly where should the Jsps, static content should go into & why?


Sorting with continous input

I'm designing (not writing, yet) a task scheduler system for a complex video game. The rest of the program passes it objects containing a function and some metadata including an estimation of how much time is left before the data is needed (which can change, of course). The scheduler is responsible for prioritizing these tasks and calling the function. The algorithm I've designed for this problem is pretty simple; it just sorts its list of task objects, pops one off the top, calls it, and repeats. Of course it's actually more complex than that (has to handle situations where things just can't get done on time, telling other parts of the code that their task just got bumped down the list...), but that's the gist of it. I'd like some advice on the subject of how I'm going to sort that list. This loop will, obviously, be running constantly while the program is running. I'm thinking I'll use a slight modification of a bubble sort algorithm, running one pass on each iteration. The list won't be properly sorted for the first few cycles, but since the list will likely be very small when the program is started I expect it will be able to reliably get things into position as fast as they come in. Has anyone done this before, and how did it work? Are there better ways I could do this?


When not to move a "C style" code to "C++ or Object Oriented" code?

**Context** I am (part of team A) developing a piece of functionality which depends on new APIs provided by team B. Old APIs (also provided by Team B) are there and this is how they are being used in our code...               int someFunction() {      //-- lots of code here      oldAPI.func1();      //-- lots of code again      if (something)          oldAPI.func2();      else oldAPI.func3();      //lots of code      // ans so on      }      We needed to complete it quickly,So I just modify the existing flow to use newAPI and tested it with some placeholder calls. Soon after I completed... Team B informed us that they will take more time. Now I have two options... _Option 1_ : Wait for Team B to complete; push your code along/after them _Option 2_ : Make your code support both old and new; based on a configuration. if we choose option 2; there are two approaches... _Approach 1_ : Modularize your code; and use polymorphism in your code.                class API_BASE {virtual funct1(),func2(),func3()};      class API_OLD : API_BASE {funct1(),func2(),func3()};      class API_NEW : API_BASE {funct1(),func2(),func3()};      _Approach 2_ : use plain conditional logic               if (newAvailable)         useNew();     else          useOld();      **Questions**   1. If possibilities of supporting multiple flow in future is very less(say 15%); but u need to support them for some time (say few months), would you modify a code written in procedural way to support OOPs? I see benefit of maintainability, readability and easy to extend code. But what is the smart way?   2. In legacy lode base... what is the ideal time to refactor code? You touch one file once in a year and move to other. Provide I have time... should I refactor an stable/running code, or should I do it when there is a real need to refactoring (how to define that I dont know)   3. In big software companies... team works in there own boundaries. If team A completes his job, it wants to push to production sooner and announce to world (mgmt, team b) etc that we are done. Until we have everything ready (i.e. A's part and B's Part), for end user (QA/Customer) there is no change is functionality. Is this a good way of thinking? should I concentrate more on my part, and let mgmt worry about bigger picture?


Why are private variables described in the publicly accessible header file?

OK, so hopefully this is a subjective enough question for Programmers, but here goes. I am continuously broadening my knowledge of languages and software engineering practices... and I've run into something that just makes no sense to me whatsoever. In C++, class declarations include `private:` methods and parameters in the header file, which, theoretically, is what you pass to the user to include if you make them a lib. In Objective-C, `@interface`s do pretty much the same thing, forcing you to list your private members (at least, there's a way to get private methods in the implementation file). From what I can tell, Java and C# allow you to provide an interface/protocol which can declare all the publicly accessible properties/methods and gives the coder the ability to hide _all_ implementation details in the implementation file. Why? Encapsulation is one of the main principles of OOP, why do C++ and Obj-C lack this basic ability? Is there some kind of best-practices work-around for Obj-C or C++ that hides _all_ implementation? Thanks,


How to create an auto-grader in and for Python

I'm trying to create an auto-grader for one of my beginning programming courses for python. From my online search, I've come to know that it is effectively a unit test framework that tests the student's code rather than production code but I'm not really sure how to structure the flow of the program. Can anyone please provide a strategy for submission of code by students and automating the whole process of marking? For instance, how would the student code be submitted and then stored/structured on disk, how would the grades be stored/reported? I'm only looking for a broad strategy and will try on my own to fill in the blanks. (I asked this on stockoverflow.com initially but it's considered as off-topic and I was suggested to ask here.)


Can one truly develop a programming style?

I started teaching myself programming half a year ago, and I've noticed I keep using a few basic techniques over and over again, is this the onset of a style or just ignorance of variation?


Is an assocative array ordered?

An associative array has many common similar names, hash, keymap, map, table, index. It's a map of keys and values but I cannot find a reputable definition of the phrase which tells me whether a map has to have order to be an associative array.   * What is a reputable definition of the term "Associative array"?   * Is an associative array ordereded? Personally I've always believed they have to be ordered because in JavaScript we claim Objects are not associative arrays because Objects are un-ordered maps of keys and values. However I may have been quoting that without a reference or a source.


Can I make more money freelancing in Android, or Web development?

**Is freelancing in Android development or Web development the better choice to achieve a ~300$ income\month?** It is too hard for me to do both. I'm currently studying CS in college and this is my second year. Financially, I'm 100% depending on my parents and this is really uncomfortable for me. My goal is to make at least 300$ a month with freelancing in programming. The problem is, I don't know where to start. I have a solid background in Java and have a basic knowledge of C, PHP, Javascript, Ruby, Prolog, CSS, HTML. I think my options are to go do Web development or Android development. I've already tried both of them (made a basic app for Android and a simple blog). It's kinda hard for me to do the both at the same time. Ultimately my question is, which one should I continue to work with to achieve the desired income\month? I really love doing both of them so I'm asking you guys to give me some helpful advice. Thank you for your time. EDIT: Sorry for being off topic but I didn't knew where to ask. There are many experts on this site so it seemed logical to ask it here. Feel free to delete this post and sorry for braking the rules.


What is the senior web developer's role in the team?

With a team of 3 other web developers i have the title as lead web developer for a year now. This is my first job as a lead. I'm pretty set on what my roles are from management. I'm curious what other senior level developers do. I primarily curious as to what others people responsibilities are as the lead/senior developer in other organizations; as I've only encountered working in a small/medium company. (a) What would one expect out of a senior / lead web developer of an organization (regardless of size)? (b) Is there a difference between web development leader and senior web developer? I reviewed some threads and there was just one that discussed when you should call yourself a senior developer but doesn't comprehensively discuss the roles of what a senior developer should do with his/her team.


In this slow job market, I have no choice to take a job that uses VB.NET and is going to use C#. Advice?

I really don't want to do VB.NET, but I need a job and I need a job fast. The two positions I am looking at both have existing apps in VB.NET, but are looking to convert them to C# and do new development in C#, but as well all know, sometimes this doesn't happen for a while and you get stuck with the main language. My background is in C# and after looking at VB.NET, my head is hurting. Any advice as I tackle a job like this. As I said, I preferably want stick with C#, but today, one may have no choice, so I have to just take what I get. I am looking for advice on this for those who have experienced it, are experiencing it, and those who have not.


Easy to customize .NET CMS with ecommerce facility

I have tried DNN and nopCommerce. After going through their source-code, I realized they are not that easy to customize and need a fair amount of time to their documentation before any changes can be made. Also, they are pretty huge, as they cover up every single aspect of a CMS, from Page to Catalogue to Menu to SEO and so on. My requirements are pretty simple; i just need the backend to add products and categories along with store handling functions. Other things like pages and menu's need not come under CMS. _**So, Is there any simple .NET CMS that can help me speed up the development process, or should I develop my own or use one of the two mentioned above ??_**


Unwritten rules of rewriting another team member's code

We are practicing collective code ownership. To my understanding this means that any developer can change any line of code to add functionality, to refactor, fix bugs or improve designs. But what about a complete rewriting of code from a developer who is still in the team? Should I ask him first? What is the best practice?


PHP Aspect Oriented Design

This is a continuation of this Code Review question. What was taken away from that post, and other aspect oriented design is it is hard to debug. To counter that, I implemented the ability to turn tracing of the design patterns on. Turning trace on works like:               //This can be added anywhere in the code     Run::setAdapterTrace(true);     Run::setFilterTrace(true);     Run::setObserverTrace(true);          //Execute the functon     echo Run::goForARun(8);      In the actual log with the trace turned on, it outputs like so:                   adapter 2012-02-12 21:46:19 {"type":"closure","object":"static","call_class":"\/public_html\/examples\/design\/ClosureDesigns.php","class":"Run","method":"goForARun","call_method":"goForARun","trace":"Run::goForARun","start_line":68,"end_line":70}          filter 2012-02-12 22:05:15 {"type":"closure","event":"return","object":"static","class":"run_filter","method":"\/home\/prodigyview\/public_html\/examples\/design\/ClosureDesigns.php","trace":"Run::goForARun","start_line":51,"end_line":58}          observer 2012-02-12 22:05:15 {"type":"closure","object":"static","class":"run_observer","method":"\/home\/prodigyview\/public_html\/public\/examples\/design\/ClosureDesigns.php","trace":"Run::goForARun","start_line":61,"end_line":63}      When the information is broken down, the data translates to:   * Called by an adapter or filter or observer   * The function called was a closure    * The location of the closure   * Class:method the adapter was implemented on   * The Trace of where the method was called from    * Start Line and End Line The code has been proven to work in production environments and features various examples of to implement, so the proof of concept is there. It is not DI and accomplishes things that DI cannot. I wouldn't call the code boilerplate but I would call it bloated. In summary, the weaknesses are bloated code and a learning curve in exchange for aspect oriented functionality. Beyond the normal fear of something new and different, what are other weakness in this implementation of aspect oriented design, if any? PS: More examples of AOP here: https://github.com/ProdigyView/ProdigyView/tree/master/examples/design


Versioning Within a Platform

I work with a few different web platforms, and my actual projects are typically quite small, and live within those platforms. The project files are scattered throughout the platform tree, which makes versioning a little awkward. I've been keeping one repository per platform, which gets out of hand quite fast... The biggest problem I've had is with Eclipse + SVN, and the size of the project keeps growing, despite working with a fairly static platform/library, and only a handful of files for the given project at a time. In order for the project to work, I need them within the platform tree. I'm wanting to move entirely to Git soon, so I'm just figuring out how I can keep the projects separate, yet keep the development environment working efficiently. I've been looking into some sort of file sync (rsync, but real time?), since the solution makes sense in my head. I'll keep projects out of the tree, and use a file sync to ensure they are copied in real time. This keeps the projects we work on very small and quick, and keeps the actual platform working properly. However, I've been having troubles finding the correct software to make this work properly. Any suggestions in this area would also be appreciated... Am I looking at this the wrong way? What are some other possible solutions? It seems like a common problem, yet I can't find much information on how to solve it. Thanks!


Available options for classifying words in text?

I am researching ways to classify words in text and I'm wondering what options there are and which are best suited to this job. I'm mostly interested in keywords which are most often nouns. So far I know I could use a Bayes classifier, blacklist, or whitelist. However, I haven't had the best of luck with each of these so far. I started with a whitelist using the words provided by wordnet and moby to attempt to spot each noun. However, many words were missed as not existing in the database, or not being nouns. Next I tried building a blacklist to match everything except known stop-words, verbs, and such. However, It would take a long investment of time to build a list large enough to handle the 200,000 known English (let alone other languages) words. In addition, keeping that many words in memory for comparison is not practical for performance on commodity hardware. Using I have had luck with a bayes classifier matching spam and sentiment, but I'm not sure how to use it to tell nouns (or keywords) from other words since there are so many similarities between all the groups of words. Last, I tried using regex to spot keywords based on proper nouns and names since they are always capitalized in English. The problem is that many keywords are not capitalized resulting in lacking results. **What other options exist for classifying keywords? What other design patterns could I use with the options above for better results?**


How can I design an application so that it works well with a database selected by the customer?

I want to write an ASP.NET 4.0 application with IBM DB2 Express-C as its back- end. One thing that worries me, is hosting this application on a remote server. I don't know any hosting provider who provides ASP.NET DB2 hosting in the same price range as of SQL Server. I also want to allow the customer to select the database of their choice from this list:   1. SQL Sever   2. Oracle   3. DB2   4. PostgreSQL   5. Firebird There are the same hosting worries with Oracle and Firebird. Hosting issues aside, I want to know how to design an application so it is agnostic to the kind of RDBMS used and will work with any of the above mentioned ones. Are there any such applications around?


Best option for PDF viewer embedded in web app

I have a web app that needs to be able to display a PDF. It needs to allow the user to page through the PDF, and my application needs to be able to know which page is currently being viewed, because other aspects of the web app will change based on the current page. Ideally it would not be dependent on the client having Adobe Reader but I could probably support that dependency. What are my best options for this? My application stack consists of ASP.NET 4 along with optionally Silverlight 5. Also, I could use something that is client-side based as well using JavaScript / HTML if such a thing exists. I found ComponentOne's offering for this and that seems like the leading candidate at this point, but I want to know if there are other options I should consider. Edit: Per Fosco's comment, converting the PDF to another format (such as HTML) might be an option, as long as I could tie back parts of the converted document to the original PDF page #s. Another note: this has to run entirely on our servers. It would not be acceptable to use a third-party service to view the PDFs.


Appropriate programming language to design music software

I want to design a software for my musical instrument which is a rhythmic one (there is no melody). All I want these software to do is :   1. make the user able to compose music    2. play what user has composed  for that purpose I need to record diffrent sounds of that instrument and match each sign with the appropriate sound . Which programming language is adequate for this purpose ?


Is absence of generic OrderedDictionary class in .NET framework really a design flaw?

I was absolutly sure that I need one (and some SO users too), but it turns out that my case was easily refactored with simple `List<object>`, and more I think about it I am no so sure anymore that one is needed and generics classes for collection managment are sufficient, I am just curious :) btw. there is a similar question, but that question assumes that such class is needed, and only one comment suggest that maybe is not needed. [EDIT] oh f*, I was ment to write OrderedDictionary not SortedDictionary, sorry folks, edited my post


Creating Deal for Percentage of App Sales

I have a business partner who wants to do a deal where I will get a percentage of the profits from app sales. I like the deal and want to do it. In our business agreement I want to put some language that defines what happens as the project moves forward - for example, what if he wants app updates that I don't think are necessary? What if he wants to work with a different developer in the future, but wants to use the code that I developed?


Should OO design, or database design, drive the coding of my @Entity classes?

I have two classes that I want related to each other in an JEE application using JPA2. In an OO world, I would say that a Chatroom has an attribute List messages. In the relational world composition doesn't exist like this. If I weren't involving a database at all, I would definitely code these two things as a composition the messages inside of the Chatroom. But since I'm using ORM with the JPA2 spec I've decided to try to create the @Entity objects as written below with the fact that they'll be mapped to the database in mind. My question is: Should I be doing this? Is it appropriate to break out the @Entity classes to support what feels like the more relational approach? Or should I just design from an OO perspective, and try to ignore the fact that there's an ORM driving it from below? Right now I'm driving my design from the database side, but should I be doing it the other way? Are there implications I'm missing about doing it this way?               package org.janp.castlerock;          import javax.persistence.Entity;     import javax.persistence.Id;          @Entity     public class Chatroom {         private String name;              @Id         public String getName() {             return name;         }              public void setName(String name) {             this.name = name;         }     }                    package org.janp.castlerock;          import java.util.Date;          import javax.persistence.Entity;     import javax.persistence.GeneratedValue;     import javax.persistence.GenerationType;     import javax.persistence.Id;     import javax.persistence.JoinColumn;     import javax.persistence.ManyToOne;     import javax.persistence.Temporal;     import javax.persistence.TemporalType;          @Entity     public class Message {         private int id;         private Chatroom chatroom;         private Date timestamp;         private String text;              @Id         @GeneratedValue(strategy=GenerationType.AUTO)         public int getId() {             return id;         }         public void setId(int id) {             this.id = id;         }              @Temporal(TemporalType.TIMESTAMP)         public Date getTimestamp() {             return timestamp;         }         public void setTimestamp(Date timestamp) {             this.timestamp = timestamp;         }              public String getText() {             return text;         }         public void setText(String text) {             this.text = text;         }              @ManyToOne         @JoinColumn(name="name")         public Chatroom getChatroom() {             return chatroom;         }         public void setChatroom(Chatroom chatroom) {             this.chatroom = chatroom;         }     }


Does Lisp still have any special feature which has NOT been adopted by other programming languages? By Lisp, I mean all the Lisp programming languages as a whole. I've been told how amazing Lisp is and know that many languages have been inspired by Lisp. But does Lisp still have any exclusive design feature that just cannot be done in any other language? The reason I asked the question is that recently, being an amateur programmer myself, I began to learn Clojure just for fun, and the result is that I found lots of Lisp-related posts and comments, saying but one thing: "Lisp is unique", but other modern programming languages have already adopted and stolen lots of ideas from Lisp, like conditionals, recursion, and the function as a first-class citizen. And even metaprogramming can be done by many languages. Did I miss out something and is "Lisp still different"? Or I'm lucky because other modern languages have stolen all the good parts from Lisp so that it's not necessary to dig into the parentheses Lisp world, and "Lisp was different".


What can I put in my software development blog to make it a good showcase of me?

I have been itching to write a software development blog for some time now. The best advice I've received about blog writing is "Write the blog you would have want to read". Its good advice but its only half the story, Once you write a blog it becomes your showcase on the Internet, it is bound to come up on any search conducted by a future colleague or employer. It can be a good thing or it can do some serious damage. So if there are any hiring managers out there, can you give me a few pointers on what it is in a blog that give you a good impression about candidate and/or the kind of stuff that causes you to throw the candidate's resume to the nearest bean? Does a blog have to come up with a clever piece of code every week? (Don’t think I can manage it) Is it OK to blog more then not about development methods to improved quality and productivity (have a lot of ideas about that). Can I blog about stuff I did not try first hand but seems noteworthy?


In reality, a developer also administers DBMS and system?

I really don't know where else to ask. So here it goes.   I'm working at a very tiny company that makes ERP software and websites.   1 developer with + 10 years experience.   2 developers with + 3years experience.   3 developers with + 1 year experience.      That's it.   No team, no DBA, no system admin.   There is no one around here who has expertise in web development, so I happened to be in charge of web development. But I've only got 3 years experience ! as a developer !.      I know in a small company, you are asked to do lots of different things but is it too much, if I have to do sysadmin, database architecture, software design and development ? Oh plus I'm asked to do all that across different platforms.   I am currently working with JSP, ASP, MSSQL, MySQL, Oracle, Windows Server, and Linux.   In database, I do from writing queries to backup & recovery.   Server setup, system crash recovery, DB & Server migration also.   Plush HTML, Javascript and CSS :)   Number of projects that I'm in charge of : 5   I'm not an expert at all of them !   I have to search the Internet, read tutorials and ask questions in StackOverflow to get all that done !      So I ask you, is this normal ?   Is this a normal practice ?   Will I face the same situation whichever small company I go ?   I'm working in South Korea.   How is it in your country ?      **P.S** Thank you all for your opinion. I was going to upvote all of you because all of you helped me see it in a different way, but apparently you need 15 reputation to upvote :(


Encapsulation: Separate functions for separate variables, or return a table? [PHP]

I have been making a website with PHP and I have a few classes, so far none of them really follow encapsulation rules of OOP. Lets say I have a user class like so:               class User{         public $username;         public $uid;         public $date;         public $location;         public $bio;         public $avatar;             public function __construct($user, $uidOr){             $this->username = $user;             $this->uidOr = $uidOr;         } .              public function getUser(){             if($this->uidOr){                 $which = "uid";             } else { $which = "username"; }      // /\ I know the above is bad             $getUserInfoQuery = new Database();             $getUserInfoQuery->fetchAll("users", array($which, $this->username));                  foreach ($getUserInfoQuery->result as $value) {                 $this->username = $value['username'];                 $this->uid = $value['uid'];                 $this->date = $value['date'];                 $this->location = $value['location'];                 $this->bio = $value['bio'];                 $this->avatar = $value['avatarurl'];             }         }     }      That obviously is terrible practise of OOP, right? Should I be adding functions like getUserUsername(); which return the username of the user object or should I make a function which returns a table of information. What would be best? Thanks! PS: sorry for my bad code, im new to OOP.


Is it considered bad practice to access a returned array by a key straight away?

I couldn't think of a good way to word the title, sorry. But what I mean is, is it considered bad practice to do:               print get_array()[2]      over:               output=get_array()     print output[2]      (where get_array() is a function that returns an array, if that wasn't clear). Which method is better? Why?


Is rewriting some Java code to C++ using JNI to improve performance a good idea?

I've tried rewriting some Java functions in C++ and called them using JNI. I observed that it takes longer time to execute the native C++ functions as compared to Java functions, due to the JNI overhead. As it is widely believed that C++ has certain advantages over Java, I wanted to know whether rewriting some Java code to C++, with a view to improve overall performance of the Java application, a good idea? If yes, then what parts of the application should be rewritten and how can a Java application use it?


Is there a way to become a remote T-SQL developer?

I have noticed that most SQL job vacancies are not adapted for remote (telecommute) work as Java or .NET jobs are. I'd like to know if there is a way to work in remote mode in T-SQL programming direction? And if that is impossible, why is that?


Should I use a CMS for a new large application with a lot of common features (login, profile edit, blog etc)?

I'm currently planning a new ASP.NET MVC3 project which will be quite bespoke. However, there will be a lot of common features (login, profile edit, blog etc). Initially I was planning on building this all from scratch, however I'm tempted by CMS so that I'm not reinventing the wheel, and don't waste time building standard features which will need a lot of testing. I've been looking into using Orchard Project CMS, and installed this the other night so that I could have a play around. The CMS seems great, however it seems restrictive in terms of wanting to add new sections. I was hoping that the CMS would basically be an ASP.NET MVC3 solution, with login features etc, which I can then build on. However I feel bound to having to write "widgets" for my application. I understand CMS's are great for simple blog sites etc, but would it seems too restrictive to be able to build a social network for example. Is there such a thing as an open-source MVC3 solution with pre-built login functionality etc, which isn't bound by an interface? Or if I'm planning to build a large application, are CMS's the wrong path to take?


Why isn't html, css and js used for desktop apps

html, css and js can be used to build beautiful(and useful) ui's (specially with html5 and css3) and lots of people already know them. Though its still way beyond my reach, but how difficult can it be to bring the whole web app thing to desktop apps (we already develop apps on our local servers before hosting them). According to me, its a nice simple idea which will bring a boom in desktop apps, plus given that these apps will already be sharing so much code with web apps, they might be able to offer better connectivity. Why isn't it being done?


Design for multiple type return

I am working in C++ and I have this problem.               class Container {        Container(int which_type_to_use_a_b_or_c);             A & getData(A & prototype);        B & getData(B & prototype);        C & getData(C & prototype);          private:        A a;        B b;        C c;        int type_used;          }      Only one of the A,B or C datatypes is actually used in a class Container instantiation. The constructor flag decides which one to use. When it's time to get a reference to the internal object, I need a getData routine which returns the reference of the different type. In order to disambiguate, I pass a "prototype" A() B() or C(). I don't really like this pattern, but I am unable to find anything better due to my limited palette in c++. Do you have any other approach available? please note that templating Container over A, B or C is not an option due to other constraints.


Spring - Confusion over configuration?

Somewhere I read Spring offers convenience over configuration. But Spring folks are bringing in so much changes over the configuration , that I am now really getting confused to use the xml configuration or the annotation. I would like anyone to suggest a surefire methodology or rule of thumb in using xml and annotations. * * * Examples at SO to show that many beginners like me are getting confused over the configuration.   * link-1 > I don't seem to grasp the functionality behind `<context:annotation-config>` > and `<context:component-scan>`. > > From what I've read they seem to handle different annotations (@Required, > @Autowired etc vs @Component, @Repository, @Service etc) but also from what > I've read they register the same bean post processor classes. > > To confuse me even more, there is an `annotation-config` attribute on > `<context:component-scan>`...   * link 2 > I still have the component scan tag: >   >     >     <context:component-scan base- > package="com.mycompany.maventestwebapp" /> >   > > but I have also another tag (that look like have similar task), this one: >   >     >     <annotation-driven /> >   > > What is the difference between these two tags? An other "strange" thing is > that the previous example (that don't use the annotation-driven tag) is very > similar to the project create by STS using the Spring MVC Template project > but if I delete the annotation-driven tag from its configuration file the > project don't run and give me the following error: **HTTP Status 404 -**... Spring 3.2 no longer need cglib for proxying , but lower versions uses cglib. A quote from the springsource blog > In order to generate such proxies, Spring uses a third party library called > cglib. Unfortunately, this project is not active anymore. In Spring 3.2, it > is very likely that Spring will be using Javassist instead by default. Are these enough to suggest that Spring is Confusion over configuration ?


Need licensing recommendations for in-house written software

Currently I do a lot of development on my free time to improve my productivity at work. I've got around 50 man hours of unpaid work into a few pieces of software, but I'd rather not have them end up on work computers until they're licensed to prevent redistribution without my permission. Of course, I'm not charging them or anything. I just want to make sure I'm protected legally in the event they decide to try and package it and sell it as their own. I made sure before starting that I didn't sign any agreement that they own everything I work on for the remainder of the time I spend at this company. I would like an in-house licensing solution. IANAL, so writing a license wouldn't be the best thing I could do. Are there any free, copy-pastable, licensing solutions (copy-pastable in the way the GPL is copy-pastable) that explicitly prevent redistribution without my permission?


UberSVN vs VisualSVN Server - Any experiences?

I'm looking at UberSVN as a possible replacement to our existing source control package, VisualSVN Server. There are a lot of UI benefits for the decision, including having the integrated web UI, administration portal and collaboration features. The concern I have is what difficulties I'll face in migrating from VisualSVN to UberSVN and whether there could be any impact to our repositories. Any experience or recommendations would be greatly appreciated.


Returning a boolean when success or failure is the sole concern

I often find myself returning a boolean from a method, that's used in multiple locations, in order to contain all the logic around that method in a single place. All the (internal) calling method needs to know is whether the operation was successful, or not. I'm using Python but the question isn't necessarily specific to that language. There are only two options I can think of   1. Raise an exception, though the circumstances are not exceptional, and remember to catch that exception in every place the function is called   2. Return a boolean as I'm doing. This is a _really_ simple example that demonstrates what I'm talking about.               import os          class DoSomething(object):              def remove_file(self, filename):                  try:                 os.remove(filename)             except OSError:                 return False                  return True              def process_file(self, filename):                  do_something()                  if remove_file(filename):                 do_something_else()      Although it's functional, I really dislike this manner of doing something, it "smells", and can sometimes result in a lot of nested ifs. But, I can't think of a simpler way. I could turn to a more LBYL philosophy and use `os.path.exists(filename)` prior to attempting deletion but there's no guarantees the file won't have been locked in the meantime (it's unlikely but possible) and I still have to determine whether the deletion has been successful or not. Is this an "acceptable" design and if not what would be a better way of designing this?


Java and JVM license

Does Java license allow other companies to create their own versions of Java language or just implement it accurately? Same question about JVM. I heard about Sun suing Microsoft for changing their .NET version of Java implementation and Java for Google Android, but I just can't grasp the whole concept as a totality.


How to modularize and package a client-side Javascript library today?

I've been catching up with the modern client-side JS ecosystem and reading up on CommonJS and AMD (incl. associated tools - browserify, requirejs, onejs, jam, dozens of others). If I'm writing a Javascript library, how do I modularize/package it such that it can be most broadly accessible (ideally by users who swear by CommonJS, AMD, and especially neither)? Popular libraries like jQuery seem to just use old-school file concatenation for building itself and dynamically detect whether it should write to an `exports` or the global context. I'm currently doing the same thing, but the main downside is that if I (unlike jQuery) depend on a few libraries, it's nice to not have to ask users to manually pre-include the transitive set. (Though I currently just have two dependencies.) And of course global namespace pollution. Or perhaps it's cleanest to generate multiple versions of my library, for each context? I'm also wondering about packaging and publishing. There are several systems, but I believe the major one is bower, which is easy to deal with since all it does is fetch. However, I'm wondering if I should also be targeting other package systems like component (which requires CommonJS). Are there other relevant aspects I should be aware of? Are there any good example projects to follow for all of this?


Find the count of each word in a string

I am in a search of a better performant algorithm to implement a program, to find the count of each word in a sentence i.e.., a String in the programming sense. I know my algorithm is too basic and Noob. Here's my algorithm.   1. Read the String.    2. Tokenize the String with the delimiter, put each token in a list(ArrayList).    3. Iterate the generated list, in each iteration compare the current string with every other string of the list, if it matches increase the count of this string.   4. For each iteration, put the String and its count in a map.   5. Iterate the map and display, with key as string and value as its count. What is the best approach than this?


How do searches fit into a RESTful interface?

When designing a RESTful interface, the semantics of the request types are deemed vital to the design.   * **GET** \- List collection or retrieve element   * **PUT** \- Replace collection or element   * **POST** \- Create collection or element   * **DELETE** \- Well, erm, delete collection or element However, this doesn't seem to cover the concept of "search". E.g. in designing a suite of web services that support a Job Search site you might have the following requirements:   * Get individual Job Advert      * **GET** to `domain/Job/{id}/`   * Create Job Advert      * **POST** to `domain/Job/`   * Update Job Advert      * **PUT** to `domain/Job/`   * Delete Job Advert      * **DELETE** to `domain/Job/` "Get All Jobs" is also simple:   * **GET** to `domain/Jobs/` However, how does the job "search" fall into this structure? You _could_ claim it's a variation of "list collection" and implement as:   * **GET** to `domain/Jobs/` However, searches _can_ be complex and it's entirely possible to produce a search that generates a long GET string. That is, referencing a SO question here, there are issues using GET strings longer than about 2000 characters. An example might be in a faceted search - continuing the "job" example. I may allow for searching on facets - "Technology", "Job Title", "Discipline" as well as free-text keywords, age of job, location and salary. With a fluid user interface and a large number of technologies and job titles, it is feasible that a search could encompass a large number of facet choices. Tweak this example to CVs, rather than jobs, bring in even more facets, and you can very easily imagine a search with a hundred facets selected, or even just 40 facets each of which are 50 characters long (e.g. Job Titles, University Names, Employer Names). In that situation it might be desirable to move a PUT or POST in order to ensure that the search data will get correctly sent. E.g.:   * **POST** to `domain/Jobs/` But semantically that's an instruction to create a collection. You _could_ also say you'll express this as the creation of a search:   * **POST** to `domain/Jobs/Search/` or (as suggested by burninggramma below)   * **POST** to `domain/JobSearch/` Semantically it may seem to make sense, but you're not actually creating anything, you're making a request for data. So, semantically it's a **GET** , but **GET** isn't guaranteed to support what you need. So, the question is - Trying to keep as true to RESTful design as possible, whilst ensuring that I'm keeping within the limitations of HTTP, what is the most appropriate design for a search?


How to become an excellent applications programmer, coming from low-level background?

Most of my career has been working on numerical algorithms, image processing, calibrating science data, making LEDs blink... very little at the level of whole apps and sophisticated GUIs. Though I have written some apps, by today's (or 10 years ago') standards, these were toys, simple demo wrappers around the number-crunching black boxes I'm good at making. Looking around, I see little demand for low-level numbers/pixels skills, interfacing directly with hardware and such; it's all desktop machine apps, smart phone apps, web apps. I'm interested mostly in desktop apps to be used by technically intelligent people - scientists, engineers, doctors etc - since I've already spent plenty time in such environments. So maybe it's time to become expert at this type of software development. Besides reading, reading and more reading (of course) and dabbling in hobby pet projects, what are the most effective ways for an experience non-apps developer to begin developing this particular kind of expertise? Which books, sites, and blogs are especially informative for learning whole-apps level design?


Factory Method vs. Factory Method design pattern

I am currently studying design patterns from the book (which, although I didn't try anything else, I find excellent) Head First Design Patterns. I'm confused about two concepts: The **Factory Method** , and the **Factory Method Design Pattern**. I was trying to understand what each one means, and I came to some conclusion. I'd like to know if my definitions are exact. * * * **The Factory Method** is a method that is meant to do one thing: Create an object of a specific supertype and return it. It may or may not take a parameter, and may or may not 'decide' using `if` statements what kind of concrete object to create. For example, this is a factory method:               public Hat createHat(String hatColor){              Hat hat;              if (hatColor.equals("red")) hat = new RedHat();         else if (hatColor.equals("blue")) hat = new BlueHat();         else if (hatColor.equals("green")) hat = new GreenHat();         else hat = new DefaultHat();              return hat;          }      * * * **The Factory Method _Design Pattern_** is **named after** the Factory Method. This pattern provides a specific way to encapsulate object creation from the client. It works like so: The pattern is a system of two classes, the **Creator** and the **ConcreteCreator**. The Creator is an `abstract` class, and the ConcreteCreator is a subclass of that class. **The job of the ConcreteCreator** \- create an object and return it **using a factory method**. It only has to contain this one method. **The job of the Creator** \- manipulate and use the object received from it's subclass, the ConcreteCreator, and usually return it to the client. It is done like so: The Creator contains an `abstract` method, it's signature something like `SupertypeObject createObject()`. Whenever it needs an object of type `SupertypeObject`, it calls `createObject()`. Thing is, `createObject()` is as I said `abstract`. It's the ConcreteCreator's job to implement this method. This way, the implementation of `createObject()` is hidden from the Creator. It doesn't know what **concrete** object it gets, but it knows for sure that it's of type `SypertypeObject`. This way, a client can use the `Creator` object to create objects of some supertype, but the concrete objects created will depend on the subclass. Thus declaring `ShoeFactory factory = new CaliforniaStyleShoesFactory()`, will make the `factory` produce california style shoes, while `ShoeFactory factory = new NYStyleShoesFactory()` will make the `factory` produce NY style shoes. Since the implementation of creating the concrete objects depends on the ConcreteCreator. Code to demonstrate:               Class Client(){              public static void main(String[] args){                  ShoeFactory factory;             Shoe shoe;                  factory = new NYStyleShoeFactory();             shoe = factory.makeShoe();             System.out.println(shoe.getDescription()); // "A NY style shoe".                  // ShoeFactory's makeShoe() invokes createShoe() in the subclass, receives a Shoe             // (doesn't know the concrete type of the Shoe. Depends on the subclass) and             // does manipulations on it.             // Returns the Shoe to the client.                  factory = new CaliforniaStyleShoeFactory():             shoe = factory.makeShoe();             System.out.println(shoe.getDescription()); // "A California style shoe".          }          }      * * * Is my understanding of the two concepts accurate? Thanks


PMP certificate. How did you achieve it? How was the preparation?

Getting a Project Management Professional (PMP) certification can be rigorous. Did you attempt it? How was your preparation process? Was there any hiccups filling out PMP project experience details? Currently, I am going thru PMbok guide. Looks like full of theory to me!! And I have read it at least twice !!


Is LINQ to SQL dead?

Is there any reason to keep using Linq to SQL, or is it better to move to ORM techniques like EF, NHibernate etc. We are using Linq to SQL in a new large enterprise application that will exist for a long time. The motivation for this new enterprise application is that the application was ordinary written in Visual Basic and since Microsoft stopped the support we where forced to rewrite the application. It’s seems that we are already there but this time with our DAL (Data Access Layer). I have already read this article, but it only compare to EF's weakness.


Application / Code reviews for lone programmers?

Are there any services that 'for a reasonable price' will give and provide good and technical advice on applications. On a lot of projects, I'm usually the only developer, and sometimes, I think some of my work needs to be improved for efficiency, better MVC interactions, etc. It would be great if there was a professional service that actually can and will do such reviews


What does "(say)" mean in this Java method in Hadoop The Definitive Guide?

What does "(say)" mean in this Java method? > Since `Mapper` and `Reducer` are separate classes, the type parameters have > different scopes, and the actual type argument of `KEYIN` (say) in the > `Mapper` may be different from the type of the type parameter of the same > name (`KEYIN`) in the `Reducer`. For instance, in the maximum temperature > example from earlier chapters, `KEYIN` in replaced by `longWritaeble` for > the `Mapper` and by `Text` for the `Reducer`. From Hadoop The Definitive Guide, by Tom White, page 224 (scanned version of the page at 223 and 224).


BlazeDS: Server DTO method naming convention

I have the following field in Flex:               [Bindable] public var zIndex:uint;      And I was trying to create the methods to process the calls in Java and I ran into a problem.               1. public int getZIndex(); // Does not work.     2. public int getzIndex(); // Works.      I thought that the letter following the `get`/`set` was supposed to be capitalized? Is there a reason for this? I couldn't find any documentation. I found an answer on StackOverflow that states that the first one is the correct way to name an accessor/mutator.


Pros and cons for open or close sourcing niche type products

One of the products I developed, is really a niche type application (2 or 3 other competitors in the market). Although for the most part, I'm the lone user of these applications, I'm thinking of selling the app right now. My question is:   * Because of the small market share and that it's a niche project would you advise I open or close my application?


Teaching "web design/development" to high-school home-school group. Good sources?

I may soon begin teaching a "web design and development" class for a home- school co-op group. **Any suggestions for "course" material?** My first thought was to work through the Opera Web Standards Curriculum, but am interested in hearing about possible alternatives or suggestions that better cover the "very basics" of getting started with designing and developing web pages. Not necessarily looking for topics, so much as existing resources. Thanks so much for your input!


Can Software Engineers become certified Professional Engineers (PE)?

Does anyone know if a Software Engineer can become a certified Professional Engineer or PE for short? I know that my buddies who are Mechanical, Electrical, or Civil Engineers were able to become PEs by taking an exam. Does such an exam exist in Software Engineering?


Should developers be involved in testing phases?

we are using a classical V-shaped development process. We then have requirements, architecture, design, implementation, integration tests, system tests and acceptance.   Testers are preparing test cases during the first phases of the project. The issue is that, due to resources issues (*), test phases are too long and are often shortened due to time constraints (you know project managers... ;)). Developers are doing their unit-tests as they should. So my question is simple: should developers be involved in the tests phases and isn't it too 'dangerous'. I'm afraid it will give the project managers a false feeling of better quality as the work has been done but would the added man.days be of any value? I'm not really confident of developers doing tests (no offense here but we all know it's quite hard to break in a few clicks what you have made in severals days). Thanks for sharing your thoughts. (*) For obscure reasons, increasing the number of testers is not an option as of today. (Just upfront, it's not a duplicate of Should programmers help testers in designing tests? which talks about test preparation and not test execution, where we avoid the implication of developers)


How can I best implement 'cache until further notice' with memcache in multiple tiers?

**the term "client" used here is not referring to client's browser, but client server** **Before cache workflow**               1. client make a HTTP request -->     2. server process -->     3. store parsed results into memcache for next use (cache indefinitely) -->     4. return results to client -->     5. client get the result, store into client's local memcache with TTL      **After cache workflow**               1. another client make a HTTP request -->     2. memcache found return memcache results to client -->     3. client get the result, store into client's local memcache with TTL      _TTL = time to live_ Is possible for me to know when the data was updated,   and to expire relevant memcache(s) accordingly. However, the pitfalls on client site cache TTL   1. Any data update before the TTL is not pick-up by client memcache.   2. In reverse manner, where there is no update, client memcache still expire after the TTL   3. First request (or concurrent requests) after cache TTL will get throttle as it need to repeat the _"Before cache workflow"_ In the event where client require several HTTP requests on a single web page,   it could be very bad in performance. Ideal solution should be client to cache indefinitely until **further notice**. Here are the three proposals about **futher notice** **Proposal 1 :** Make use on HTTP header (current implementation)               1. client sent HTTP request last modified time header     2. server check if last data modified time=last cache time return status 304     3. client based on header to decide further processing          GOOD?     ----     - save some parsing for client     - lesser data transfer          BAD?     ----     - fire a HTTP request is still slow     - server end still need to process lots of requests      **Proposal 2 :** Consistently issue a HTTP request to check all data group last modified time               1. client fire a HTTP request     2. server to return last modified time for all data group     3. client compare local last cache time with the result     4. if data group last cache time < server last modified time         then request again for that data group only          GOOD?     ----     - only fetch what is no up-to-date     - less requests for server          BAD?     ----     - every web page require a HTTP request      **Proposal 3 :** Tell client when new data is available (Push)                1. when server end notice there is a change on a data group      2. notify clients on the changes      3. help clients to fetch again data      4. then reset client local memcache after data is parsed          GOOD?     ----     - let the cache act/behave like a true cache          BAD?     ----     - encourage race condition      My preference is on proposal 3,   and something like Gearman could be ideal   Where there is a change, Gearman server to sent the task to multiple clients (workers). Am I crazy?   (I know my first question is a bit crazy)


Should a developer know the inner workings of the computers' hardware?

I'm not talking just how memory is assigned and memory management (things that you can learn from C for example) but rather the hardware aspect and how each component of the computer hardware works internally and how they communicate with each other. How many of you know all of this?


How do you write tests for code that depends on concrete external implementations that can't be mocked?

Background: I am thinking of trying to introduce the concept of unit tests to my co-workers by creating some for a module I have been working on; the requirements of it recently changed and require some more abstractions/interactions so it seems like a good way to develop a suite of tests that will "prove" it works without having to manually poke around the application. The issue, however, is that the module relies on unmockable external factors namely PDFs and XSL. Basically I read XML from the database and apply an XSL transformation to it, then convert it to a PDF using a library called ABCPDF. This PDF is then merged with another PDF based on a static template. I know that I can test the XML and make sure the values are correct, but many of the potential bugs and issues are related to the actual display of the finished document - e.g. minutiae like how long text strings are wrapped, where certain HTML areas are located in relation to the document, etc. Is it even possible to test these things (I realize these are probably integration tests or.. the third kind of test whose name I forget [not Acceptance tests, the other kind], and not **unit** tests) since I can't, to my knowledge, mock out a PDF easily short of creating it then reading it back or creating an HTML string (i.e. transformed XML) and parsing it by hand to check for the presence of certain table cells in relation to other table cells. In a situation like this should I just focus on unit tests to make sure the information is correct and that I can _create_ the PDF, or merge them, or whatever and resort to manual testing for the actual display issues?


Is it better to spend resources on a skilled team or good process practice?

Which one of these is of more importance? Skilled team or good process practice? When I say skilled, I mean logical, creative members with good coding and testing skills. Good process would be the development methodology, like agile, scrum, etc


How to detect if an app was already installed before

How do software applications keep track of whether the user already installed the application before in it's Windows system? Say you install app X, trial version, remove it, then re install it, and when you run it again it detects you had already installed it before. If you uninstall and clean all registry information it shouldn't know you had already installed it before... Disclaimer: I'm not trying to "hack" any application, just thinking about how this is implemented.


Why could citing bug IDs in patch notes be considered a bad practice?

Based on a comment and subsequent upvotes from Bug reopen vs. new: > Citing bug IDs in patch notes is just.. very unfriendly. – Krelp It appears at least some people feel that referencing bug IDs in patch notes is not a good idea. I'm a fairly inexperienced developer, so I'm wondering why that's the case.


How can I improve quality on SQL reports?

I've recently ran into some issues where some reports were not generating the proper results. We already have a QA department that reviews the reports and then our business owners review them as well; this hasn't prevented the issue. I'm trying to figure out a decent way to have a test harness to ensure reports are giving me the desired result. So far, I've thought about having a static snapshot of the database (point-in- time), I would then   1. run the report sprocs (stored procedures) against my data with defined parameters   2. save off the output   3. write testing sprocs that call the reporting sprocs with my define parameters   4. Verify the results matched using the EXCEPT keyword. Can you please offer some suggestions and alternatives?


NDA's in interviews

I have interviews scheduled for two, large, respectable, somewhat competing, American companies. One of them (the one for which the interview takes place first) has asked that I bring a signed NDA to the interview. I'm not a specialist - more of a general Java server kind of guy with years of experience - but I don't have any conflict of interest between my previous employers and either of these two and have not been in a similar situation before. However, I am worried that signing the NDA for the first employer might pose a problem should things go well with the second and I decide to go there. Is this a reasonable fear? If so, what can I do?


graph data structure in Java (or Python)

**does Java have graphs as an intergrated data structure**? How about Python? I was assigned to write a program, that solves the TSP (travelling salesman problem) via the GRASP (greedy randomized adaptive search procedure). I'm just familiarizing myself with GRASP, and I would like to have a good working data structure for graphs, that includes **plotting the graph** and the option to assign special colour to edges (so I can colour the final solution: cheapest hamiltonian path). I'm gonna have a presentation, explaining my final solution, whence the need for plotting the graph. Also, it would be desirable to have the option to **generate a random graph on n vertices** , so I have some easily accessible examples. I was really hoping this has been done by someone before, so I don't start from scratch. I'm a mathematician (or atleast trying to be), so please, no fancy programmer slang. thank you


Can a common interface be defined for Cartesian and Polar coordinate data?

I'm rewriting a set of file readers that a former-colleague of mine created that read raw-point data of XYZ (Cartesian) coordinates or RTZ (Polar) coordinates. Currently the data is stored directly in the reader, making everything rely on the state of those objects. I'd like to separate the reader from the collected data it reads by creating some data objects. Each of the coordinate systems is nearly identical from a purely data-driven point of view.               Cartesian Coordinates       X (List of doubles)        Y (List of doubles)        Z (Multidimensional array of doubles at [X,Y])          Polar Coordinates       R (List of doubles)       T (List of doubles)       Z (Multidimensional array of doubles at [R,T])      I'm trying to determine if I can, in good conscience, define a common interface for both of these. The data is the same, even though what it represents is subtly different. Each has two opposing axes of a 3D coordinate system, and a table of Z values at various combinations of those axes. But an X coordinate doesn't necessarily map to R. And I'm not sure what I would call the properties on a common interface - `Axis1`, `Axis2`, and `Z`? Or am I trying to consolidate something here that really needs to remain separate? Should there be a separate (albeit similar) interface for each data object representing coordinates from each system?


How to test a function that updates the password in database?

I have a test database with few user accounts. I don't want to break any tests. If I am writing a function that updates password for user in db and one that reads the password. Should I ideally reset the password to the previous one, once I am done testing update function ? I have never written unit tests before, so I am little confused.


What is Declarative UI?

I keep seeing this term being thrown around in blogs about frameworks. While I understand the difference between declarative and imperative programming, how does this apply specifically to UI? Why does there appear to be a special term for it? Are these different 'things'? If so, what is the alternative to Declarative UI and why would I want to use it?


How to check or assess debugging skills of a person?

What kind of skills determine a person that is capable of debugging code with ease? Some time ago my friend carried out an interview with a relatively good programmer. The programmer got hired. He could write good code, understood the frameworks and design patterns. The thing he was missing was - debugging skills. He could not debug at all and finding problems with his or someone else's code was huge pain for him. Since then we are thinking about how we can assess or estimate a person's debugging skills. So the first question is: what skills determine if a person can effectively debug software? And the second: how to test those skills during the interview?


Is there a design pattern to solve this problem?

I've been struggling with a design so I figured I'd ask here and see if anyone's able to help :) **High level overview** I'm designing an app to gamify exercise by creating mini competitions (ex. Who can lose the most weight in 3 months or bike the most miles in a month). Users can create competitions (calling them races for now) and they need to be able to specify constraints - participants have to be in a certain age range, over a certain weight, maximum number of participants in a race, etc. **My Objects** RaceParticipant - for brevity, the only pertinent property is int Age. Race:               public class Race     {         public virtual int RaceId { get; set; }         public virtual string RaceName { get; set; }         public virtual int RaceTypeId { get; set; }         public virtual TrainingType RaceType { get; set; }         public virtual IEnumerable<RaceParticipant> RaceParticipants { get; set; }         public virtual IEnumerable<RaceConstraint> RaceConstraints { get; set; }     }      RaceConstraint abstract class:               public abstract class RaceConstraint     {         public string DisplayText { get; set; }         public string ValidationText { get; set; }         public virtual bool PassesConstraint(Race race, RaceParticipant participant);      }      RaceConstraint implementation MaxNumberOfParticipants:               public class MaxNumberOfParticipants : RaceConstraint     {         public int MaximumNumberOfParticipants { get; set; }              public MaxNumberOfParticipants()         {             DisplayText = "Maximum number of racers";             ValidationText = "This race has reached the maximum number of racers.";         }              public override bool PassesConstraint(Race race, RaceParticipant participant)          {             bool result = false;             if (race.RaceParticipants.Count() <= MaximumNumberOfParticipants)             {                 result = true;             }             return result;         }     }      RaceConstraint implementation AgeRange:               public class AgeRange : RaceConstraint     {         public int MinimumAge { get; set; }         public int MaximumAge { get; set; }              public AgeRange()         {             DisplayText = "Age range of racers";             ValidationText = string.Format("Racers must be between the ages of {0} and {1}.", MinimumAge, MaximumAge);         }              public override bool PassesConstraint(Race race, RaceParticipant participant)         {             bool result = false;             if (MinimumAge <= participant.Age && participant.Age <= MaximumAge)             {                 result = true;             }             return result;         }     }      **The question** My question is where to store MinimumAge, MaximumAge, and MaximumNumberOfParticipants. I'm using Entity Framework code-first so I know I don't need to worry about the schema directly, but I do need to think about which properties to add to EF and which object they'll be connected to. Currently EF would make a separate table for each implementation of RaceConstraint which seems like overkill and I definitely don't want DisplayText and ValidationText stored in the db for each instance. I thought about moving MinimumAge, MaximumAge, and MaximumNumberOfParticipants to properties of Race because each race will have values for these, but that feels like Race and RaceConstraint would be too coupled. I'd like to be able to add a RaceConstraint in the future as requirements change without having to add a property to Race and therefor add a column to the Race db table. I think I'm going to have to make a container object for RaceConstraint that holds a collection of all possible RaceConstraints. Would it make sense to put these properties in that object and then remove IEnumerable RaceConstraints from Race and instead add a property for the RaceConstraintContainer? Or maybe I'm way over thinking this and there's a design pattern I can follow. I'm sure I'm not the first person to come across this scenario! Thanks in advance. **UPDATE** After mulling this over for a few days and trying out each of the answers, I think @maple_shaft really nailed the problem of EF getting in the way of OO design. I think I found a compromise somewhere in the middle. I added properties like MinimumAge, MaximumAge, and MaximumNumberOfParticipants to the Race object because from a database perspective, these are all very related and each race will have entries for each of these. I changed the abstract class RaceConstraint to an interface that just requires bool PassesConstraint(). I made better use of DisplayText by making it a data annotation of the properties in race (ex. [Display(Name = "Maximum number of racers")]) since I really only wanted it for labels in the UI. I moved the text from ValidationText to an exception message if a PassesConstraint() fails. Finally, I made a RaceManager class to hold a List of RaceConstraints and handle adding users by checking each RaceConstraint. This class will also handle removing users, determining winners, etc. I think this will work well from an MVC standpoint too because I'm not passing models to the view that have methods. The Race class will really just be there to hold EF data and will make for a clean model to use for adding or updating races from a view. Thanks for the help everyone!


How to handle notifications to several partial views of the same model?

I am working on refactoring an old simulation of a Turing machine. The application uses a class that contains the state and the logic of program execution, and several panels to display the tape representation and show the state, messages, and the GUI controls (start, stop, program listing, ...). I would like to refactor it using the MVC architecture that was not used originaly: the Frame is the only way to get access to the different panels and there is also a strong coupling between the "engine" class and the GUI updates in the way of `frame.displayPanel.state.setText("halted");` or `frame.outputPanel.messages.append("some thing");` It looks to me that I should put the state related code into an observable model class and make the different panels observers. My problem is that the java Observable class only provides a global notification to the Observers, while I would prefer not to refresh every Observers everytime, but only when the part that specificaly observe has changed.   * I am thinking of implementing myself several vectors of listeners (for the state / position, for the output messages, ...) but I feel like reinventing the wheel.   * I though also about adding some flags that the observers could check like `isNewMessageAvailable()`, `hasTapeMoved()`, etc but it sounds also approximative design. BTW, is it ok to keep the fetch / execute loop into the model or should I move it in another place? We can think in a theorical ideal way as I am completely revamping this small application.


What are the data structures behind a spreadsheet?

I would like to understand how a spreadsheet (a group of named or otherwise identified cells containing values or formulas referencing other cells) is solved. I have tried looking at existing projects, but there was so much going on with the GUI, serialization, events, etc. that I couldn't find the spreadsheet. At its simplest how does it work?


Grouping classes by subject or dependencies?

Our project consists of user application and server application. The server application prepares data files that the user application consumes. Because the data is huge, it is stored in custom format. So the project includes many classes related to reading and writing the data. The user application does not need the writing side, so we don't want to have the code there both because it might run on resource-limited devices and because it prolongs compilation (C++ is not known for having fast compilers). So say I have two classes (I have tens of such pairs):   * `DataReader`   * `DataWriter` These classes both operate on the same thing, the serialized data. But the first is only needed in the user application and the second is only needed in the server application. Would you suggest keeping such classes   * Together; in say      * `common/data/DataReader`     * `common/data/DataWriter`   * Separate like      * `userapp/data/DataReader`     * `serverapp/data/DataWriter` With this goes the compilation. The common stuff lives in `common` and is compiled into a library linked to both. So the first option further splits into two:   * Together in `common/data` and linked to `common.a` or   * Together in `common/data` directory, but each linked to the target that needs it. Now each has it's advantages and disadvantages:   * They are closely related, so it makes sense to keep them together. But      * having both in one library makes that library larger and compile longer     * compiling each separately means directory layout does not correspond to project layout, which is rather confusing and complicates the build scripts   * Keeping them separate makes the build structure more logical and avoids unnecessary work for the compiler, but when updating them, components far apart need to be modified (both applications are maintained by the same team, so it's not like someone wouldn't be aware of the other part) We currently have mixture between the approaches (some classes are separate, others not and the common library contains a lot of stuff that should be in the individual projects), which I would like to clean up. Is there any usual recommendation for such situation? Or some useful experience with similar cases?