title: Creating a layer of abstraction over the ORM layer

text: I believe that if you have your repositories use an ORM that it's already enough abstracted from the database. However, where I am working now, someone believe that we should have a layer that abstract the ORM in case that we would like to change the ORM later. Is it really necessary or it's simply a lot of over head to create a layer that will work on many ORM? ### Edit Just to give more detail:   1. We have POCO class and Entity Class that are mapped with AutoMapper. Entity class are used by the Repository layer. The repository layer then use the additional layer of abstraction to communicate with Entity Framework.   2. The business layer has in no way a direct access to Entity Framework. Even without the additional layer of abstraction over the ORM, this one need to use the service layer that user the repository layer. In both case, the business layer is totally separated from the ORM.   3. The main argument is to be able to change ORM in the future. Since it's really localized inside the Repository layer, to me, it's already well separated and I do not see why an additional layer of abstraction is required to have a "quality" code.


title: what's proper class name for manager/browser/editor

text: I've read somewhere that it's a bad idea to name classes after verbs (manager/browser/editor) but what's the proper name for manager/browser/editor? EDIT: the problem is that system could turn in a big ball of "services" - tiny objects which does something specific and does not contain any data - which is bad (at least because it just queries other objects) but I also need to be able add new "managers" easily (right now app needs to manage users, ftp accounts, mail accounts, etc.)


title: How to implement a safe password history

text: Passwords shouldn't be stored in plain text for obvious security reasons: you have to store hashes, and you should also generate the hash carefully to avoid rainbow table attacks. However, usually you have the requirement to store the last _n_ passwords and to enforce minimal complexity and minimal change between the different passwords (to prevent the user from using a sequence like Password_1, Password_2, ..., Password_ _n_ ). This would be trivial with plain text passwords, but how can you do that by storing only hashes? In other words: how it is possible to implement a safe password history mechanism?


title: What are the advantages of Maven when it comes to single man, educational projects

text: I've spend a few hours playing around with Maven + reading some stuff on the apache official site and also a few random googled articles. By this I mean that I really tried to find the answers myself - both by reading and by doing things on my own. Also maybe worth to mention that I installed the `m2e plugin` so most of the time I've tried things out from `Eclipse` and not using the command line too much. However aside from the generated project that for example prevent me from using the default package I didn't see that much of a difference with the standard way I've created my projects before try Maven. In fact I've almost decided to skip Maven for now and move on to the other technology I wanted to learn more in-depth - `Hibernate`, but when I start with opening the official page the first thing I've read was the recommendation to use Hibernate with Maven. That get me confused and made me taking a step back and trying once more to find what I'm obviously missing right now. As it's said in the `maven.apache..` site, the true strength of Maven is shown when you work on large projects with other people, but I lack the option to see how Maven is really used in this scenario, still i think that there are maybe advantages even when it comes to working with small projects alone, but I really have difficulties to point them out. So what do you think are the advantages of Maven when it's used for small projects writing from a single person. What are the things that I should be aware of and try to exploit (I mean features offered by Maven) that can come in handy in this situations?


title: What metadada to save and whether to include it inside the binary file?

text: I'm wondering if there are any general guidelines or best practices regarding when to split data into a metadata format, as oppose to directly embedding it within the data. (Specific example below). My understanding of metadata is that it describes data (without the need to actually look at the data), allowing for data to be quickly search/filtered for easy access. Let's take for example a simple 3D model format. The actual data file is itself a binary file containing vertices and colors. Things like creation date, modified data and author name would be things that describe the binary data, so I would say these belong as metadata (outside of the binary file). But the following questions arise:   * What if the application had no need to search or filter by these fields?    * Would it be acceptable to embed these fields directly into the binary data itself?   * Could they be duplicated in both the binary data and the meta data, or would this be considered bad practice?    * What about more ambiguous fields such as the model name, which could be considered part of the data itself, but also as data describing the binary data?   * How do you decide which data to embed in the actual binary file, as opposed to separating into a more flexible metadata format? Thanks!


title: Coordinating between developers on common resources

text: In our organization some of the resources (such as QA machines etc) are shared. Different folks get done at different times and some tests have to be run (during dev and QA) on these machines. Right now, we just skype a message to the team stating "I am going to run some destructive tests on such and such machines - let me know if anyone has an issue". This approach obviously has many issues (what happens if someone missed the message etc.) Apart from maintaining a shared google doc that needs to be constantly updated - is there an easier way that folks use for such coordination?


title: Java best practice Interface - subclasses and constants

text: In the case where a couple of classes implements an interface, and those classes have a couple of constants in common (but no functions), were should I put this constant ? I've had this problem a couple of times. I have this interface : DataFromSensors that I use to hide the implementations of several sub classes like DataFromHeartRateMonitor DataFromGps etc... For some reason, those classes uses the same constants. And there's nowere else in the code were it is used. My question is, were should I put those constants ? Not in the interface, because it has nothing to do with my API Not in a static Constants class, because I'm trying to avoid those Not in a common abstract class, that would stand between the interface and the subclasses, because I have no functions in common, only a couple of constants (TIMEOUT_DURATION, UUID, those kind of things) I've read best practice for constants and interface to define constants but they don't really answer my question. Thanks !


title: Why does the boolean type in C++ support `++` but not `--`?

text: Why does the operator `--` not exist for bool whereas it does for operator `++`? I tried in C++, and I do not know if my question apply to another language. I will glad to know also. I know, I can use the operator `++` with a bool. It makes any bool equal to true.               bool b = false;     b++;     // Now b == true.      Why can't we use the operator `--` in an opposite way?               bool b = true;     b--;     // Now b == false;      It is not very useful, but I am curious.


title: Doesn’t active record violate SRP and OCP?

text: I have watched the active record classes in our project grow into large, do- it-all classes. When you need anything about a user, for example, you should go to the `Person` class. While this makes perfect sense when you consider the domain, in reality, the `Person` class is a mishmash of lots and lots of functionality, which do get modified sometimes as the domain becomes clearer, which means both SRP and OCP are violated. Is this one of the things that comes with the Active Record pattern, or are we doing it wrong?


title: Validating Objects With XSDs: Is Re-Serializing Redundant or Negligible?

text: **Context:** I've got a web service that deals with request / response objects. There are strict, externally-defined schemas constraining both the structure and the content of both requests and responses. I need to validate all requests as they are received and all responses before they are sent back (on the web service end of the wire). I don't want to replicate the validation rules in code, so I'll be validating serialized request / response objects (XML), probably using XmlReader as a starting point (for speed). It'll be 1-way object --> XML validation method that screams if validation fails, otherwise the original object will be used for the actual work. I'm using WCF, but with XMLSerializer as the schemas are complex and I need the additional XSD support. **Question:** 1) Is there a way to avoid re-serializing the objects as they hit my end of the wire? _Ideally_ I'd like to get at the XML before it's de-serialized on the way in, and after it's serialized, just before it goes, on the way out. I'm aware of [OnSerializing] and [OnSerialized] annotations, but they won't work with XMLSerializer. I don't think I should be writing ReadXml() and WriteXml() using IXmlSerializable either - the schemas are complex and subject to change. 2) Given the XML documents are quite small (122kb seems to be the top end in the sample data set I have) am I right in asserting that the performance hit of re-serializing will be negligible? 3) Any better ideas?


title: Cleaning Up Generated Code: Refactor or Map?

text: **Context:** I recently had to deal with a class file generated by XSD.exe. It was 3500 lines long with ridiculously-verbose class / variable names (think `someRidiculouslyLongPrefixThenMaybeOneThingUniqueAtTheEnd` \- difficult to compare at a glance with `someRidiculouslyLongPrefixThenMaybeOneOtherThingChanged`) and annotations all over the place. Bottom line is it took me ages to work out what the heck was going on. I read it and thought I would never put my name next to something so... Un-clean. **Question:** 1) Is it bad practice to mess with generated code (i.e. clean it). 2) Would it be better practice to write a mapper to map the generated classes to my own nice, clean classes (which I could then get to work with, quite happily)? **EDIT:** Thanks for all the comments. If I was actually going to do anything interesting with it (i.e. if there were domain objects which were anything but transport objects) then I think I'd map them to 'cleaner' classes, which I'd have to do anyway to get any kind of functionality out of them. In this case the classes are effectively DTOs so perhaps it makes sense that the naming matches the corresponding elements. As stated, I don't need to touch it - just to call accessors / mutators before passing the data down to another layer for processing. For now, I think I'll leave them well alone.


title: When changing a class/method and you already have passing unit tests, should you change then test or write a test then change?

text: Say I have a class with a single constructor that accepts 2 parameters and initialises itself using those parameters. I have written tests for this and they are all passing. I later realise I need to make an addition to the constructor to accept three parameters. Should I a) Add in the new parameter, watch my tests break and try and fix it b) Rewrite existing tests to test for the new expected behavior, watch them initially fail and then add to the class (this to me seems a more TDD way) From a TDD point of view, I think that option 'b' makes more sense. However, option 'a' (to me) seems like a more natural approach. Is there any standard way that most people do this?


title: Software architecture which allows for growth, real life situation

text: I know of Interfaces, Abstract classes that serve as Base class, I've been reading up on loose coupling, ... But I can't come up with a decent solution when a property of a class changes, and the new type needs to be implemented in other classes using this updated class. **Example** Below is a simplified representation of a real life situation. Invoice contains a Contact object which has an Address property.               Abstract Class Contact{         string Name{get;set;}         string Address{get;set;}     }                    Class Customer:Contact{         string CustomerNumber{get;set;}     }                    Class Invoice{         string DocumentNumber{get;set;}         Customer Customer{get;set;}     }      Next, we decide to upgrade the Contact class to contain multiple Addresses. Of which the Invoice will need one.               Class Address{         string Street{get;set;}     }                    Abstract class Contact{         string Name{get;set;}         List<Address> Addresses{get;set;}     }      Logically, the Invoice class needs to be changed to something like               Class Invoice{         string DocumentNumber{get;set;}         Customer Customer{get;set;}         Address InvoiceAddress{get;set;}     }      **Problem** You immediately see that _everywhere_ I used the **string** property `Address` before, I will now have to change it to an occurence of the type **Address** As stated before, this is just a simplified example. The real life problem would be much, much bigger as contacts will be used throughout the entire software. **Conclusion** I want to develop the software with a principle that will keep my software light for new versions of certain modules. So that if I decide to create a new Contact module, the impact to the other modules is close to non-existing. So, the added functionality can be implemented gradually. I want to know how I can tackle such versioning problems. This project is currently still in the architectural design stage, and I want this sorted out before we continue.


title: Bitwise-OR vs Adding Flags

text: I've seen others use Bitwise-OR to combine flags before:               #define RUN 0x01     #define JUMP 0x02     #define SHOOT 0x04          const byte madPerson = RUN | JUMP | SHOOT;      That's also the way I do it. But I've also seen some (not as many) combine flags using addition:               #define RUN 0x01     #define JUMP 0x02     #define SHOOT 0x04          const byte madPerson = RUN + JUMP + SHOOT;      Which one is more "readable"? (Which one do you think more people will recognize?) What is the "standard" way to do it? Which one do you prefer?


title: Automatic programming: write code that writes code

text: After reading the book The Pragmatic Programmer, one of the arguments I found most interesting was "write code that writes code". I tried searching over the net for some more explanations or articles about it, and while I found some good articles on the subject, I still haven't found any specific code implementation or good examples. I feel it's still not a so common argument, something that lacks documentation or it's not embraced by so many people, and I would like to know more about it. What do you think about the subject? Is it something that will really increase your productivity? What are some good resources on the subject, among books, blogs, slideshows, etc? * * * Some code examples would be greatly appreciated to allow me to better understand its implementation. * * * Here's the wiki page on the subject with various relevant programming techniques, like Meta Programming, Generative Programming and Code Generation.


title: What are the 'must know' Emacs commands?

text: I'm a fairly new convert to Emacs and I really love it as an editor, primarily because I keep finding new and super-useful commands. Are there any other programmer 'must known' commands missing from my list?               M-x replace-string     - Find and replace a given string.     M-x goto-line          - Goto a specific line     M-x column-number-mode - Show the current column number in text bar


title: How do you evaluate a small piece of code?

text: I'm creating a website based on users' code, a place where they can share code in a social way and one of the features I'm currently developing is Code Review. This feature will allow users to evaluate code in certain aspects, from the top of my head I came out with things like:   * Legibility,    * Performace and    * Modularity. What are the general characteristics that you evaluate when reviewing code?


title: For email interviews, is it bad to research some answers?

text: So I got an email "interview" with questions to be answered. I'm not too sure only about one of them, so I wanted to google the answer. Of course in a real interview I can't do this, so should I say "I don't know", or research it? I mean, if I were on the job, I'd research it, so it can't be frowned upon? Right?


title: Intelligence as a vector quantity

text: I am reading this wonderful book called _"Coders at Work: Reflections on the Craft of Programming"_ by Peter Seibel and I am at part wherein the conversation is with Joshua Bloch and I found this answer which is an important point for a programmer. The paragraph, goes something like this. > There's this problem, which is, programming is so much of an intellectual > meritocracy and often these people are the smartest people in the > organization; therefore they figure they should be allowed to make all the > decisions. But merely the fact they are the smartest people in the > organization does not mean that they should be making all the decisions, > because intelligence is not a scalar quantity; it's a vector quantity. Here at the last sentence, I fail to get the insight which is he trying to share. **Can someone explain it in a little further as what he means by a vector quantity, possibly trying to present the same insight.** Further down, I get the point that he is not taking about having an organization where non-technical people (sometimes clueless) can be managers of the technical people for some reason that they can spend more time to write emails well, because the very next statement following the above paragraph was. > And if you lack empathy or emotional intelligence, then you shouldn't be > designing APIs or GUIs or languages. I understand that he is saying that in Software engineering, programmers should know how the users will see their product and design for them. I felt the above paragraph was very interesting.


title: How could you reconcile declarative database development and non-trivial data 'motions'?

text: Coming back to SQL Server after several years away, I find the Visual Studio Database projects (and now SSDT) very exciting, as they are aiming to offer a way to develop databases declaratively, rather than having to mess around with change scripts. However, the elephant in the room is the 'data motions' (I'm not too sure whether that's an official term): it's not too hard to automatically script a simple change in one table, but if you're normalising/denormalising, things get hairy very quickly. Gert Drapers said as much in this TechEd video, and that they're trying to work out a way of working with these complex data migrations too. **The question:** This got me thinking. How could you do this? Is there a way - even in theory - to define these data migrations declaratively? Or even a non-declarative way which could be combined elegantly with the declarative bits? Does anything like this already exist in other frameworks (I've vaguely heard something about Ruby/Rails?) _(I wondered whether to post this ondba, but I'm not sure whether they like 'good subjective questions (if this is one), feel free to migrate if necessary)_


title: Making a configurable Java formatter?

text: AFAIK there's just `java.util.Formatter` and `java.text.Format` and AFAIK none of them is extensible. I mean not subclassing, but the possibility to specify how to handle objects by class, e.g., saying > please format `char[]` as string and > format `byte[]` in hex It's no big deal to do it manually, but it's verbose and then the `Formatter` (or `String.format`) make little sense if I have to do half the work manually (`java.text.Format` is a different story as it's meant for i18n). Also things like               String.format("%1$tY-%1$tm-%1$te", new Date())      aren't exactly appealing. So I'm asking for ideas how to create such a thing, e.g., how to structure it and possibly what else should it do.


title: CRM in the context of C++ programming

text: I was asked by an employer about CRM in the context of C++ software development. The position I was applying for was C++ Software Engineer. I told them: As far as I know, CRM is an acronym that stands for Customer Relationship Management. It also refers to software tools that track the responses and actions of customers and employees that are involved in some business relationship. But they seemed disappointed that I didn't know how to code or implement a CRM framework in C++ and I couldn't seem to find much on the Net either. Does anyone know what an employer is looking for at this stage - before they hire you and train you up? I would appreciate some pointers to get started.


title: Is Java free software?

text: Free software as defined by FSF. Are its standard libraries free/open source? Is its implementation free/open source? Which parts of it are not free/open source? Any other relevant information.


title: MQTT, GWT, ActiveMQ stack to bring jms to the browser

text: I am in the preliminary stages of architecting a legacy replacement project. They already have sub half second performance on their green screens and they want the same on their web app. We have a 390 mainframe that can handle anything we throw at it but they don't have a good jvm for it, so we have two tiers of websphere servers between the mainframe and the browser, The ui server, and the bl server. For the ui, I'm leaning towards GWT. But one thing that I think would seal the deal is to add messaging capabilities to the browser. The idea is say you click on a link that displays a second panel of information, instead of the classic GWT where it triggers a GWT-RPC call to the ui server, the ui server routs it to the bl server, the bl sends it to the mainframe and back out, it drops an MQTT message directly to the bl server or directly to the mainframe. Say writes go to the bl, reads go to the mainframe. This is an easy enough thing in classic jms because you can issue a message that has an expected response. Then have your callback ready to get the resonse. But from what I'm reading so far. It looks like mqtt doesn't have that. It looks like it's strictly fire and forget, which would make it really tough to come up with a way to get a response back to the workstation that called it. Am I right here? Has anyone tried this stack before with gwt.


title: Avoiding "Smart Guy" Syndrome on Team Projects

text: A lot of bad practices were being committed at the beginning of a project, and I recognized them and fought against all of them. Since I didn't pick and choose my battles, my boss now assumes anything out of my mouth is an over complicated response, and spends a lot of time defending himself personally, instead of looking out for the best interest of the project. How do I push the team in the right direction, without waiting four months for everyone to come to the consensus I was trying to get in place all along, or scarring my reputation on the team as a difficult know-it-all?


title: Explanation needed, for “Ask, don't tell” approach?

text: I'm taking a course on design patterns in software engineering and here I'm trying to understand the good and the bad way of design relating to "coupling" and "cohesion". I could not understand the concept described in the following image. ![enter image description here](http://i.stack.imgur.com/Tft7E.jpg) The example of code shown in the image is ambiguous to me, so I can't quite clearly get what exactly "Ask, don't tell!" approach mean. Could you please explain?


title: Creating New Scripts Dynamically in Lua

text: Right now this is just a crazy idea that I had, but I was able to implement the code and get it working properly. I am not entirely sure of what the use cases would be just yet. What this code does is create a new Lua script file in the project directory. The ScriptWriter takes as arguments the file name, a table containing any arguments that the script should take when created, and a table containing any instance variables to create by default. My plan is to extend this code to create new functions based on inputs sent in during its creation as well. What makes this cool is that the new file is both generated and loaded dynamically on the fly. Theoretically you could get this code to generate and load any script imaginable. One use case I can think of is an AI that creates scripts to map out it's functions, and creates new scripts for new situations or environments. At this point, this is all theoretical, though. Here is the test code that is creating the new script and then immediately loading it and calling functions from it:               function Card:doScriptWriterThing()         local scriptName = "ScriptIAmMaking"              local scripter = scriptWriter:new(scriptName, {"argumentName"}, {name = "'test'", one = 1})         scripter:makeFileForLoadedSettings()              local loadedScript = require (scriptName)         local scriptInstance = loadedScript:new("sayThis")         print(scriptInstance:get_name()) --will print test         print(scriptInstance:get_one()) -- will print 1         scriptInstance:set_one(10000)         print(scriptInstance:get_one()) -- will print 10000         print(scriptInstance:get_argumentName()) -- will print sayThis         scriptInstance:set_argumentName("saySomethingElse")         print(scriptInstance:get_argumentName()) --will print saySomethingElse     end      Here is **ScriptWriter.lua**               local ScriptWriter = {}          local twoSpaceIndent = "  "     local equalsWithSpaces = " = "     local newLine = "\n"          --scriptNameToCreate must be a string     --argumentsForNew and instanceVariablesToCreate must be tables and not nil     function ScriptWriter:new(scriptNameToCreate, argumentsForNew, instanceVariablesToCreate)              local instance = setmetatable({}, { __index = self })              instance.name = scriptNameToCreate         instance.newArguments = argumentsForNew         instance.instanceVariables = instanceVariablesToCreate         instance.stringList = {}              return instance     end     function ScriptWriter:makeFileForLoadedSettings()         self:buildInstanceMetatable()         self:buildInstanceCreationMethod()         self:buildSettersAndGetters()         self:buildReturn()         self:writeStringsToFile()     end          --very first line of any script that will have instances     function ScriptWriter:buildInstanceMetatable()         table.insert(self.stringList, "local " .. self.name .. " = {}" .. newLine)         table.insert(self.stringList, newLine)     end          --every script made this way needs a new method to create its instances     function ScriptWriter:buildInstanceCreationMethod()         --new() function declaration         table.insert(self.stringList, ("function " .. self.name .. ":new("))         self:buildNewArguments()         table.insert(self.stringList, ")" .. newLine)              --first line inside :new() function         table.insert(self.stringList, twoSpaceIndent .. "local instance = setmetatable({}, { __index = self })" .. newLine)              --add designated arguments inside :new()         self:buildNewArgumentVariables()              --create the instance variables with the loaded values         for key,value in pairs(self.instanceVariables) do           table.insert(self.stringList, twoSpaceIndent .. "instance." .. key .. equalsWithSpaces .. value .. newLine)         end              --close the :new() function         table.insert(self.stringList, twoSpaceIndent .. "return instance" .. newLine)         table.insert(self.stringList, "end" .. newLine)         table.insert(self.stringList, newLine)     end     function ScriptWriter:buildNewArguments()          --if there are arguments for :new(), add them         for key,value in ipairs(self.newArguments) do           table.insert(self.stringList, value)           table.insert(self.stringList, ", ")          end         if next(self.newArguments) ~= nil then --makes sure the table is not empty first           table.remove(self.stringList) --remove the very last element, which will be the extra ", "         end     end     function ScriptWriter:buildNewArgumentVariables()         --add the designated arguments to :new()         for key, value in ipairs(self.newArguments) do           table.insert(self.stringList, twoSpaceIndent .. "instance." .. value .. equalsWithSpaces .. value .. newLine)         end     end          --the instance variables need separate code because their names have to be the key and not the argument name     function ScriptWriter:buildSettersAndGetters()         for key,value in ipairs(self.newArguments) do             self:buildArgumentSetter(value)             self:buildArgumentGetter(value)             table.insert(self.stringList, newLine)         end         for key,value in pairs(self.instanceVariables) do             self:buildInstanceVariableSetter(key, value)             self:buildInstanceVariableGetter(key, value)             table.insert(self.stringList, newLine)         end     end     --code for arguments passed in     function ScriptWriter:buildArgumentSetter(variable)         table.insert(self.stringList, "function " .. self.name .. ":set_" .. variable .. "(newValue)" .. newLine)         table.insert(self.stringList, twoSpaceIndent .. "self." .. variable .. equalsWithSpaces ..  "newValue" .. newLine)         table.insert(self.stringList, "end" .. newLine)     end     function ScriptWriter:buildArgumentGetter(variable)         table.insert(self.stringList, "function " .. self.name .. ":get_" .. variable .. "()" .. newLine)         table.insert(self.stringList, twoSpaceIndent .. "return " .. "self." .. variable .. newLine)         table.insert(self.stringList, "end" .. newLine)     end     --code for instance variable values passed in     function ScriptWriter:buildInstanceVariableSetter(key, variable)         table.insert(self.stringList, "function " .. self.name .. ":set_" .. key .. "(newValue)" .. newLine)         table.insert(self.stringList, twoSpaceIndent .. "self." .. key .. equalsWithSpaces .. "newValue" .. newLine)         table.insert(self.stringList, "end" .. newLine)     end     function ScriptWriter:buildInstanceVariableGetter(key, variable)         table.insert(self.stringList, "function " .. self.name .. ":get_" .. key .. "()" .. newLine)         table.insert(self.stringList, twoSpaceIndent .. "return " .. "self." .. key .. newLine)         table.insert(self.stringList, "end" .. newLine)     end          --last line of any script that will have instances     function ScriptWriter:buildReturn()         table.insert(self.stringList, "return " .. self.name)     end          function ScriptWriter:writeStringsToFile()         local fileName = (self.name .. ".lua")         file = io.open(fileName, 'w')         for key,value in ipairs(self.stringList) do           file:write(value)         end         file:close()     end          return ScriptWriter      And here is what the code provided will generate:               local ScriptIAmMaking = {}          function ScriptIAmMaking:new(argumentName)         local instance = setmetatable({}, { __index = self })         instance.argumentName = argumentName         instance.name = 'test'         instance.one = 1         return instance     end          function ScriptIAmMaking:set_argumentName(newValue)         self.argumentName = newValue     end     function ScriptIAmMaking:get_argumentName()         return self.argumentName     end          function ScriptIAmMaking:set_name(newValue)         self.name = newValue     end     function ScriptIAmMaking:get_name()         return self.name     end          function ScriptIAmMaking:set_one(newValue)         self.one = newValue     end     function ScriptIAmMaking:get_one()         return self.one     end          return ScriptIAmMaking      All of this is generated with these calls:               local scripter = scriptWriter:new(scriptName, {"argumentName"}, {name = "'test'", one = 1})     scripter:makeFileForLoadedSettings()      I am not sure if I am correct that this could be useful in certain situations. What I am looking for is feedback on the readability of the code, and following Lua best practices. I would also love to hear whether this approach is a valid one, and whether the way that I have done things will be extensible.


title: The clock problem - to if or not to if?

text: Let's say, we have a simple digital clock. To "power" it, we use a routine executed every second. We update seconds part in it. But, what about minutes and hours part? What is better / more professional / offers better performance:   1. Ignore all checking and update hour, minute and seconds part each time, every second.   2. Use `if` \+ a variable for checking, if 60 (or 3600) seconds passed and update minute / hour part only at that precise moments. This leads us to a question, what is better -- unnecessary drawings (first approach) or extra `if`s? I've just spotted a Javascript digital clock, one of millions similar on one of billions pages. And I noticed that all three parts (hours, minutes and seconds) are updated every second, though first changes its value only once per 3600 seconds and second once per 60 seconds. I'm not to experienced developer, so I might me wrong. But everything, what I've learnt up until now, tells me, that `if` are far better then executing drawing / refreshing sequences only to draw the same content.


title: Successful Common Code Libraries

text: Are there any processes, guidelines or best practices that can be followed for the successful implementation of a common code libraries. Currently we are discussing the implementation of common code libraries within our dev team. In our instance, our common code libraries would compliment mainstream .net software packages we develop against. In particular, im interested in details and opinions on:   * Organic vs design first approach   * Version management    * Success stories (when the do work)    * Horror stories (when they dont work) Many Thanks


title: Do unit tests sometimes break encapsulation?

text: I very often hear the following: "If you want to test private methods, you'd better put that in another class and expose it." While sometimes that's the case and we have a hiding concept inside our class, other times you end up with classes that have the same attributes (or, worst, every attribute of one class become a argument on a method in the other class) and exposes functionality that is, in fact, implementation detail. Specially on TDD, when you **refactor** a class with public methods out of a previous tested class, that class is now part of your interface, but has no tests to it (since you refactored it, and is a implementation detail). Now, I may be not finding an obvious better answer, but if my answer is the "correct", that means that sometimes writting unit tests can break encapsulation, and divide the same responsibility into different classes. A simple example would be testing a setter method when a getter is not actually needed for anything in the real code. Please when aswering don't provide simple answers to specific cases I may have written. Rather, try to explain more of the generic case and theoretical approach. And this is neither language specific. Thanks in advance. **EDIT:** The answer given by Matthew Flynn was really insightful, but didn't quite answer the question. Altough he made the fair point that you either don't test private methods or extract them because they really are other concern and responsibility (or at least that was what I could understand from his answer), I think there are situations where unit testing private methods is useful. My primary example is when you have a class that has one responsibility but the output (or input) that it gives (takes) is just to complex. For example, a hashing function. There's no good way to break a hashing function apart and mantain cohesion and encapsulation. However, testing a hashing function can be really tough, since you would need to calculate by hand (you can't use code calculation to test code calculation!) the hashing, and test multiple cases where the hash changes. In that way (and this may be a question worth of its own topic) I think private method testing is the best way to handle it. Now, I'm not sure if I should ask another question, or ask it here, but are there any better way to test such complex output (input)? OBS: Please, if you think I should ask another question on that topic, leave a comment. :) **EDIT2:** I accepted a answer as my correct because it made me think and decide my course of action, altough it didn't answered my queston completely. But for those who face the same problem as I do (one cohesive class that will change together, but is still too hard to test by itsfelf), I'll tell what I did and why. I decided that the output of that class is simply too hard to a computer to test correctly, so I didn't test it. I could have used a framework to test it's private methods (which would be the best idea, I think), but I didn't want to get to that point. If you are wondering what it is that is cohesive and respects SRP, and still is too hard to a computer to test, I'll give some examples: heightmap generation, hashing functions, procedural music generation (you can test some units, but the highest level unit is simply too subjective).


title: Any Code Review tool with direct connection to CVS?

text: I've found many Code Review tools:   * Phabricator (by Facebook) - http://phabricator.org/   * Rietveld (by Google) - http://code.google.com/appengine/articles/rietveld.html   * GitHub - https://github.com/   * Crucible - http://www.atlassian.com/software/crucible/overview   * GitLab - http://gitlabhq.com/demo.html   * SmartBear - http://smartbear.com/products/software-development/code-review   * etc. But didn't found any, which would be directly connected with the versioning system. As I want the code review proccess to be required, so nobody can push any single line of unreviewed code to master, I need my versioning system to **deny all pushes of revisions which were not reviewed yet**. Is there any tool which does that? Or is there any easy way how to do that?


title: How to manage a winforms application installed in many PCs connected to a single sql database?

text: I have a winforms application that connects to a single sql server 2012 database and is executed in many PCs of a company. I'm having several problems with some transactions inside the application, deadlocks and timeouts so the refactor idea comes to my head. Actually the app is using DbConnection object (the app starts with Framework 2.0 and recently was updated to Framework 3.5 but the data access layer was not changed) to perform the sql calls to the database and in the Program.cs the connection is opened and until the user doesn't close the app the connection maintains opened. What are my options to refactor this app?   * Entity Framework? => With this I must to say that the SQL database has not Foreign Keys   * Refactor the Data Access Layer to use a more efficient connection? Maybe using TransactionScope?   * Is the always connected app efficient?


title: Designing a plug-in system

text: I'm working on a Java project and I would like to add a plug-in system. More precisely, I would like to let the user design his own module, pack it into a jar, leave it in a "plugins/" subfolder of my application and be done with it. I've managed to get a child classloader to instantiate objects of classes located in external jars, but now I'm facing a design dilemma: Say Joe makes a plug-in and he packs it in joeplugin.jar. I would really like Joe to have a class named "instantiation.Factory" and I would also like everyone to have this class with this exact location and name. (This factory class obviously implements a interface that I provide and through it I get what I want from the plug-in.) If Joe wouldn't be restricted in this way I would have to look into his entire jar for some class that implements my factory interface and I don't want to imagine how complicated things get. So my question is: should I enforce a strict naming convention for this single class? I have no idea how plug-in systems work.


title: Benefits of Java in education?

text: I hope this isn't too off-topic and/or opinion based. I'm looking for examples and reasons why Java is an acceptable language for education purposes. Here's why: I learned programming on my own in C at the age of about 15. In school we used Pascal (which I think is quite OK, especially in educational context). In University, Java was used and I was disgusted. Examples: Verbosity:               RenderingHints rh = new RenderingHints(          RenderingHints.KEY_ANTIALIASING,          RenderingHints.VALUE_ANTIALIAS_ON);     g2.setRenderingHints(rh);      * * * Listener classes instead of functions. * * * No overloading (resulting in ugly `.equals()` and `.get()` instead of `==` and `[]`). * * * When I was able to pick a programming language on my own again, I chose Python and everything "felt just right". Now the problem is that I'm going to become a teacher for computer science in german secondary schools (grade 5-13), where I will be forced to teach Java. So I'm looking for the _pretty parts_ of Java. What is especially easy/readable/... to implement in Java? Preferably in an educational context, but also from a professional programmer's point of view.


title: Why doesn't Haskell have a 'format' function for string interpolation?

text: I'm trying to use Shake and I stumbled upon the following problem: there's no easy and convenient way to interpolate a string. I know about `Text.Printf` — it's not what I'm looking for. The interpolation syntax I'm talking about is like this: (Make)               HEADERS_DIR := /some/path/to/dir          CFLAGS := "-g -I$(HEADERS_DIR) -O2"      (Python)               headers_dir = "/some/path/to/dir"          cflags = "-g -I{headers_dir} -O2".format(**locals())      And now compare this to possible Haskell's solution. Firstly:               $ cabal install interpolatedstring-perl6     $ ghci -XExtendedDefaultRules -XQuasiQuotes      And then:               > import Text.InterpolatedString.Perl6 (qq)     > let headers_dir = "/path/to/some/dir"     > [qq| -g -I$headers_dir -O2 |] :: String      While I think Make goes maybe a step too far in its eagerness to interpolate even when not asked, I wonder why Haskell doesn't have a `format` function like Python does. It could parse the supplied string and pull the value with same name as referenced in pattern:               let headers_dir = "/path/to/some/dir"     format "-g -I$headers_dir -O2"      Is there a specific reason why it's not implemented, or everyone is just happy with `Text.Printf`'s verbosity and/or lengthy setup of interpolation libraries? **Update** : A lot of people misinterpret the question as asking about general string formatting, with possibility of precision specification in case of integers, etc. The examples provided demonstrate one specific case of interpolation, which is just "substitute the result of `show a` at the place of name". It does allow for simpler syntax, and it does not use a variadic function per se.


title: Development of algorithmical concept for scheduling and allocation problem

text: I have to solve a problem in the field of _operations research_. I want to gather some general approaches to evaluate them to pick the most promising to design a problem-related program. * * * **Problem definition** Company ACME that sells customized collages and has a production that adheres to mass customization principles. **Production**   * A _desk_ **D** where the _collages_ are created (maybe there will be more desks in future, but not for now)   * A _collage_ **C** is composed of...   * Diverse _square pictures_ **P** We can consider the collage as created, when the last needed square picture is created.   * _Marker_ **M** of _color_ **T** and capacity **c_m** A _picture_ is drawn with one or more _marker(s)_ of same _color_. Each _picture_ consumes a certain amount of _marker capacity_. It is possible that a pictures can _consume_ more than one marker. Empty _markers_ can be refilled but that takes a fixed amount of time. The drawer is an android that works 24/7 (since androids have no human rights yet) and can hold _mutliple markers_ (there is a limit, we can assume 2 for now), if one _marker_ is empty, he can switch to the next and doesn't loose time because of refilling. Changing the _marker_ because another _color_ is needed, also takes time. The _markers_ are **not** at the android's desk, only the one he currently uses. They get there at the time they're scheduled. The problem now is to schedule the specific _square picture assignments_ , the according _marker assignments_ , _marker refills_ and _color switches_ so that every single step of the collage production is planned considering a high output rate (that includes the minimaziton of color switches). * * * **Question** I need help finding algorithms and ideas for solving the problem. Maybe there are some best practices or problem instances to map I haven't thought of. E. g. _TSP_ , where I'm not sure how to apply it in this special case. * * * **My Solutions/Ideas so far**   * Simulated Annealing The square Pictures assignments, marker assignments, etc. are consindered as events. Find a permutation of events that minimizes global cost function.   * Auction class algorithms Every square picture assignment gets a balance of money according to the return value of a per-assignment cost function. The assignments can _buy_ the needed resources in an auction house. Upon a valid buy, the resource and the assignment are scheduled.   * Map to _graph instance_ (Don't know exactly how to do that yet) and find path with minimum weight. * * * **Additional info** There is a meta tier with a superior **ERP** (Enterprise resource planning) system, that already does some rough planing. The task here is the detailed planing as a **MES** (Manufacturing Execution System) would do it. But I don't know the number of collages I have to plan in a given time frame. I just know that it is an ongoing problem, and that there is no need to use an online algorithm. The program I'll intend to develop gets called on demand to schedule the production for some days. I found a way to map the problem to simulated annealing and another approach following the auction class algorithms. I need help with evaluating these approaches, or even collecting new ideas, best practises to solve this problem, since I never dealt with a problem instance like this before. E. g. an answer like take a look at algorithm xyz would help me out, or first approaches to a graph mapping.


title: How to test software that burns CDs without wasting CDs?

text: I want to write an application that can be used to burn CDs (music). I know I should test it with real CDs anyway, but I don't want to do this every time I make a small change. But I do want to know and test if the right data will be burnt, so you don't get corrupted CDs. I am using a library which only exposes APIs to directly burn to a physical drive; it doesn't allow you to write to a disk image (which would be much easier to test). How could I test this without wasting CDs and time for every change/few changes I make?


title: Looking for a better Factory pattern (Java)

text: After doing a rough sketch of a high level object model, I am doing iterative TDD, and letting the other objects emerge as a refactoring of the code (as it increases in complexity). (That whole approach may be a discussion/argument for another day.) In any case, I am at the point where I am looking to refactor code blocks currently in an if-else blocks into separate objects. This is because there is another another value combination which creates new set of logical sub- branches. To be more specific, this is a trading system feature, where buy orders have different behavior than sell orders. Responses to the orders have a numeric indicator field which describes some event that occurred (e.g. fill, cancel). The combination of this numeric indicator field plus whether it is a buy or sell, require different processing buy the code. Creating a family of objects to separate the code for the unique handling each of the combinations of the 2 fields seems like a good choice at this point. The way I would normally do this, is to create some Factory object which when called with the 2 relevant parameters (indicator, buysell), would return the correct subclass of the object. Some times I do this pattern with a map, which allows to look up a live instance (or constructor to use via reflection), and sometimes I just hard code the cases in the Factory class. So - for some reason this feels like not good design (e.g. one object which knows all the subclasses of an interface or parent object), and a bit clumsy. Is there a better pattern for solving this kind of problem? And if this factory method approach makes sense, can anyone suggest a nicer design?


title: Design pattern for method to accept one of several static items in C#?

text: I want to illustrated my question by way of a (hopefully) representative example. Lets say I have a situation where I am developing a class library in C# to be used in some simulations. I want to define the planets (Earth, Mars, Saturn, etc.) and have each of them have some properties and methods that are common in interface (name, signature, etc.) but unique in implementation per-each. I.e. Earth.Mass is not equal to Mars.Mass. So far no big deal. I want to have some other classes/methods/algorithm that accept as an argument a planet and use its defined properties and method:               double MyApparentWeight(Planet someplanet, double MassInKG)     double DistanceFromInKM(Planet someplanet, Planet originplanet)      Planets could be used all over the place by someone using this library. All "Earth"s should be identical and all "Saturn"s should be identical. Obviously the "Earth"s are distinct from the "Saturn"s. I also want a user of the library to be able to easily create a new planet (e.g. Vulcan, Endor, Tralfamadore, Persephone, Rupert, etc.). It should be forced to supply the properties and methods of the existing ones and hence be useable by the MyApparentWeight and DistanceFromInKM methods. So the base level approach is that there is a Planet class and then the specific ones (Earth, Vulcan, etc.) simply inherit from that. In this case though a user needs to either create an instance of Earth and carry it around or create a new one every time it is needed. That could be unnecessarily clunky (especially in light of the expected users) and possibly a performance hit since some Planets could have initialization steps of reading date from files, etc. The next idea was the above but with a singleton paradigm. That's basically what I've done so far. This seems to be dictating internal implementation to any new Planets that are created (and again some what of a concern given the potential level of some users). This project is how I've been cutting my C#/.NET teeth. My initial naive approach was to try to do static classes with interfaces or inheritance. Obviously I learned quickly the folly of that path. At a high level that is the kind of paradigm I would have wanted though. Is there some other design pattern that I'm missing that could cover this type of situation? Appreciate any suggestions. # Updates I may not have made it clear that this `Planet` example was only meant to be illustrative structurally and not directly representative of the actual computations. Some people seemed to get a little wrapped up in the implementations of what data is being represented within them and other peripheral aspects. The suggestions of the individual planets (like Earth) merely being instances of the `Planet` class didn't catch my points about potentially significant different implementations for their internal mechanics supporting their methods and properties. I'm also at a loss as to how it helps with not wanting to manage carrying around those instances potentially anywhere you may want to use them or having to create new instances. Glenn's extension of Stephen's suggestion I think actually works the best in the context of what I need here. I can couple that with rsbarro's suggestion of having static properties for the built in `Planet` children. (Actually more like `interface IPlanet` implementers). That provides the easiest access for the users for the most commonly used items and offers a slight performance improvement of not having to retrieve from the dictionary by name each time. It still offers the ability for the users to dynamically add more types of Planets. I don't yet have the rep to up-vote all of the answers I mentioned above or I would. Thank you all for your suggestions and feedback.


title: What do you do if you find a rewrite is taking too long?

text: I know Joel says that rewrites are always bad, m'kay, but that is assuming the person who wrote the code in the first place had some idea what they were doing. I've got a medium sized (for a single developer anyway, ~18k LoC) C++ project, which I started when I did not truly know C++. Therefore, there are several things that are just... wrong. Wrong is the only way to describe it. It needs to be rewritten, plain and simple. However -- I've spent a long freaking time doing the rewrite -- bugs in the original aren't getting fixed. However, some of the bugs themselves are problems with the architecture of the original tool -- and some of that is what I need to fix would require touching almost every line of code anyway. On one hand, I feel fixing the bugs in the old program is going to be a massive wasted effort, because those bugs aren't even possible with the new design I've been working on. On the other hand, I've felt that I've neglected users of my original program because it's not been updated in so long. What should I do?


title: What are the worst things that inexperienced developers forget to think about?

text: As a young developer, I would find it useful to get some advice regarding things to think about in order to develop a high-quality application. In my college courses, most teachers emphasized input validation and some talked about security concerns, but no one covered the importance of certain other things, like logging for example. What are some mistakes that inexperienced developers tend to make which could lead to frustration for more experienced developers?


title: Make shareware program free in some countries

text: **Idea.** To make my shareware program free in less-developed countries. Or release a free edition for these countries. **Purpose.** More users, bug reports, extensions, active forum, etc. Anyway, 90% sales are in ~30 richest countries. Why not make it free in China, India, Russia... **Question.** What are possible problems? I can't find info on this topic. It seems that almost nobody does it (I know only Windows 7 Home Basic). **Algorithm.** How would you implement it? I know it's possible to detect country using IP. It's OK if would fail to detect in 20% cases. When country is detected, the user would get license key for free. Country detection and license key generation can be implemented in web server. EDIT: Country detection can be performed when user wants (clicks button 'Register for free'). Then program connects to my website, which detects country and generates a license key from user's hardware ID. Then the free key can be used on that PC like a purchased key, and no internet connection required. On other PC/hardware the user can simply repeat the procedure, as long as he/she is in one of these countries. EDIT: Country detection is easy and fast, i tested it with this php script+database. It worked with all IPs of my website visitors of this month. However some of them may actually live in other countries (see jwenting answer).


title: Do logged in users need to browse a site over https?

text: I've never thought it was necessary, but a client has requested that all webpages served to logged in users be delivered over HTTPS. Aside from the implementation standpoint, which I don't think I'm going to pursue is there any real reason for this request ? For clarity, the login / logout process, account settings, registration preferences and all user related scripts are served over https. but I can't see the point in my news articles, press releases, events etc... being served in this manner? Am I missing something ?


title: Has anyone used a Stub in production code?

text: I have a situation where some procedure returns an object (kind of like a DTO) with a certain interface:               interface ISomeInterface     {         string StringReadOnlyProperty { get; }         int IntReadWriteProperty { get; set; }     }      (In the real implementation, there are more properties). There are two different places where these objects are handled - one process that generates new instances, and another process that manipulates existing instances. Internally, these two implementations are very different. The "new" instance is just a stub, and the "existing" instance has lots of tracking logic. So I need to have this "Stub" implementation kicking around all the time. I was thinking about how nicely Rhino Mocks can stub up implementations of an interface without having to generate a concrete class. Has anyone ever used a "stubbing" mechanism like Rhino Mocks, but in their production code rather than in their unit tests? It just seems like a bad practice, because of the dependency to a testing framework.


title: Java stored procedures in Oracle, a good idea?

text: I'm considering using a Java stored procedure as a very small shim to allow UDP communication from a PL/SQL package. Oracle does not provide a UTL_UDP to match its UTL_TCP. There is a 3rd party XUTL_UDP that uses Java, but it's closed source (meaning I can't see how it's implemented, not that I don't want to use closed source). An important distinction between PL/SQL and Java stored procedures with regards to networking: PL/SQL sockets are closed when dbms_session.reset_package is called, but Java sockets are not. So if you want to keep a socket open to avoid the tear-down/reconnect costs, you can't do it in sessions that are using reset_package (like mod_plsql or mod_owa HTTP requests). I haven't used Java stored procedures in a production capacity in Oracle before. This is a very large, heavily-used database, and this particular shim would be heavily used as well (it serves as a UDP bridge between a PL/SQL RFC 5424 syslog client and the local rsyslog daemon). Am I opening myself up for woe and horror, or are Java stored procedures stable and robust enough for usage in 10g? I'm wondering about issues with the embedded JVM, the jit, garbage collection, or other things that might impact a heavily used database.


title: Is there a standard for when you include libraries or not?

text: I often come across a class which has a single reference to another library and was wondering if its better to include the library or to reference the object by it's full name. Is one better then the other? Is one more of a standard then another? For example using System.Windows.Messagebox: Option A:               using System.Windows;          public class MyClass     {         SomeMethod()         {             MessageBox.Show("Something");         }     }      Option B:               public class MyClass     {         SomeMethod()         {             System.Windows.MessageBox.Show("Something");         }     }      If B, how many references do you need before you decide to add the entire library?


title: What are my options? - Separating out the UI

text: I'm working on a project where the everything is driven from the a .dll on the server. The UI and the business rules are all on this .dll This makes it pretty difficult to debug. My question is, I would like to present alternatives to allowing the users to the ability to still create customized screens without the UI and the rules being so tightly intertwined. Can anyone offer suggestions or references to ways of splitting out the UI but still allowing ultimate customization abilities? Let me know if I need to add further information.


title: Compute if a function is pure

text: As per Wikipedia: > In computer programming, a function may be described as pure if both these > statements about the function hold: The function always evaluates the same > result value given the same argument value(s). The function result value > cannot depend on any hidden information or state that may change as program > execution proceeds or between different executions of the program, nor can > it depend on any external input from I/O devices. Evaluation of the result > does not cause any semantically observable side effect or output, such as > mutation of mutable objects or output to I/O devices. I am wondering if it is possible to write a function that compute if a function is pure or not. Example code in Javascript:               function sum(a,b) {         return a+b;     }          function say(x){         console.log(x);     }          isPure(sum) // True     isPure(say) // False


title: Design pattern for syncing data in android

text: I have been seeing two implementations for syncing data between the server and the client on majority of the apps. This assumes no GCM is set up:-   1. Running an intent service periodically which downloads the data from the network and stores in the database.   2. Implementing a Sync Adapter which runs periodically. Which of the above would you recommend to have in your app and why?


title: Is it time to deprecate synchronized, wait and notify?

text: Is there a single scenario (other than compatibility with ancient JVMs) where using `synchronized` is preferable to using a `Lock`? Can anyone justify using `wait` or `notify` over the newer systems? Is there any algorithm that **must** use one of them in its implementation? I see a previous questions that touched on this matter but I would like to take this a little further and actually `deprecate` them. There are far too many traps and pitfalls and caveats with them that have been ironed out with the new facilities. I just feel it may soon be time to mark them obsolete.


title: Would a "downcast if block" be a reasonable language feature?

text: Consider the following "if cast":               class A     { public void f1() { ... } }     class B : A { public void f2() { ... } }          A a = foo(); // might return A or B          if ( a is B ) {         //  Inside block, implicitly "redeclare" a as type B         //  It's B, go for it         a.f2();         //  Wouldn't compile.         a = new A();     }      We don't enter the block unless `a` is a `B`, therefore within the block, the compiler treats `a` exactly as if it had been declared as type `B`. You could assign null to it in the block if it's a reference type, but it would be a compile-time error to assign `new A()` to it, for example (thanks @ThomasEding for bringing up that question). Anything that could break that assumption that `a` is `B`, could just as easily break the following legal C# as well:               if ( a is B ) {         B b = a as B;              b.f2();     }      The former looks to me like syntactic sugar for the latter. Even if this feature makes sense, I'm sure Anders Hjelberg's lads have more useful features to implement. I'm just wondering if it's a worse idea than I think it is. **UPDATE** A serious objection would be that the feature as described adds semantics without adding syntax: From one version of the language to the next, the meaning of the above block would change significantly. It would be more tolerable with a new keyword. But then you'd be adding a new keyword.


title: Custom .NET apps and clustering

text: So for a clustered environment - how would this work with your apps? what about your own custom .NET apps? Would there be a special way to develop them? I know that you can say create a simple Hello world app, and cluster that but they wouldnt be something you could see interms of the UI or anything, so they would effectively need to be developed as a Windows Service perhaps or even as a standard Console app which runs and not wait for user input but you wouldnt see any output from it (unless you redirect output to somewhere else) What im getting at here is... for those who have experience or developed a cluster application in .NET, how did you do it and what are the things to be aware of? For example we have the cloud service - fundamentally its built on clustering - if there is an outage, another node takes place and service is resumed as normal but we dont really see much of that downtime.


title: "state" or "status"? When should a variable name contain the word "state", and when should a variable name instead contain the word "status"?

text: Reading code and discussions pertaining to code, I often see the words "state" and "status" used interchangeably, but the following tendencies seem to exist:   * When a variable holds a value intended to indicate that something is in a certain state, the name of that variable more often than not contains the word "state", or an abbreviation thereof.   * However, when the return value of a function serves to indicate some such state, we tend to call that value a "status code"; and when that value is stored in a variable, this variable is commonly named "status" or something similar. In isolation that's all fine I guess, but when the aforementioned variables are actually one and the same, a choice needs to be made involving the perverted intricacies of English language (or human language in general). What is the prevailing coding-standard or convention when it comes to disambiguating between the two? Or should one of those two always be avoided? This english.stackexchange question is also relevant, I suppose.


title: Dominant team members in a Scrum team

text: What would you do in a situation where a team member tries to take responsibilities are not initially assigned to him but to the Scrum Master?


title: Advise on loose coupling between user controls

text: I have 5 user controls on the page and each control implements it's own interface that contains properties and events. In order to enable communication between user controls, I am creating a property of target user control inside other user control. Through this property, it's state can be altered and be able to register its events. Below is the pseudo code of results user control. It subscribes to OnSearch event of Search user control.               public interface IResults     {          //other fields         ISearch SearchControl { get;}     }          public partial class Results : IResults     {      //other fields           public ISearch SearchControl      {              get{         this.Page.Parent.FindControl("UCSearch") as ISearch;}      }           protected override void Page_Load(object sender, EventArgs e)      {         this.SearchControl.OnSearch += new EventHandler(testMethod);      }     }      Is it ok to have the reference properties inside user controls to subscribe to the events and manipulating the state. Does it create any maintenance problem in future. Does FindControl and type casting degrade the performance of the application.


title: Why is verbosity bad for a programming language?

text: I have seen many people around complaining about verbosity in programming languages. I find that, within some bounds, the more verbose a programming language is, the better it is to understand. I think that verbosity also reinforces writing clearer APIs for that particular language. The only disadvantage I can think of is that it makes you type more, but I mean, most people use IDEs that do all that work for you. so, What are possible downsides to a verbose programming language?


title: Does parallel mergesort run differently on mesh vs linear array of processors?

text: I'm currently taking course on introduction to algorithm and I came across the parallel mergesort algorithm. My question is: Is there any differences in the algorithm plan if it runs on a 2d mesh instead of infinite linear proccessors ? Thank you,


title: Can Objective C categories serve the same purpose as Traits do in Scala?

text: The statement of the question seems little abstract to me, so please read the details below. Since the time when C++ was the first choice Object Oriented Language for almost anything, we had a big problem of Multiple inheritance in C++ when two different implementations of same function declared or defined in a (abstract or concrete)parent class of the two, come to a common child class and create ambiguity, popularly known as the Diamond problem. C++ gave a solution : the "virtual" keyword, to be used while specifying the parent class(es) so that only one copy goes to the final child class being decided at runtime instead of compile time based on certain rules. Java tried to solve this by providing single inheritance and avoiding multiple inheritance completely. But then it lacked a feature where a class behaviour could be influenced by a bit and that may change in future or more behaviour may be added to it and we needed a way to encapsulate behaviour, then came the construct "interface" which had nothing but method declarations which each implementing class had to implement in their own way. Protocols in Objective C are more or less the same thing. However this approach has a major drawback, and this is where my question comes into picture. The drawback is, if a class has many subclasses implementing the same interface in the same way. The same code has to be written everywhere in each class. If it was all the classes, then the implementation could have been there in the parent class which gives the implementation. At max what can be done is to introduce a class with the implementation of the common method in between the current parent class and make all those classes inherit from it. But this can lead to lot of bugs if not done properly in a complex project. Scala provides Traits which not only serve as interfaces but can add full blown implementations for few of them that can be mixed with some classes that require it and removed when not. I haven't seen the syntax but I have heard that Ruby solves the same problem using something called as mixins. In case of Objective C, we have protocols but they have the same limitations as Java interfaces. So my question is, If I create a category of a class and import it in any subclass of that class, Will the subclass get all those implementation methods? Also if I remove it, will it be synonymous to removing the trait inclusion declaration for a class? I might be wrong in any of my assumptions above, I am newbie when it comes to OOP design (and just got interested in FP). I would also appreciate any better solutions than this one.


title: Going through The C Programming Language K&R in Visual Studio

text: From what I have read, K&R seems to be a good place to start learning programming in general, and C programming specifically. However, I've just started the first chapter and I have a few questions. They may be extremely simple, and I apologize if that's the case (I am new, after all) -- but your helping me answer them would be very appreciated. 1) I understand the book is written to describe C languages in general. Does this mean the examples they give are just rough outlines, and that for me to attempt them myself I have to "translate" the general outline given into C++ or C# or whatever? For example, the textbook gives this program:               #include <stdio.h>      main()      {      printf("hello, world\n");      }      But I've found a program to print "Hello, world" in C#, for example is:               // A Hello World! program in C#.      using System;     namespace HelloWorld     {         class Hello          {             static void Main()              {                 Console.WriteLine("Hello World!");                      // Keep the console window open in debug mode.                 Console.WriteLine("Press any key to exit.");                 Console.ReadKey();             }         }     }      And the program in C++ looks different from both the above... So my question is: does the book expect me to be able to translate the first program (or outline, whatever it is) to a C# or C++ program -- I am using Visual Studio -- to be able to practice myself? 2) If the book does expect me to do this, do you all have any tips on how I can go about translating general C code to C# or C++. 3) This may be opinion, but which should I base my learning on (and practice coding in) -- C# or C++?


title: Credibility of Windows azure architect program from Sundblad & Sundblad

text: I am planning to attend the Windows Azure Architect Program from S&S. http://www.windowsazurearchitect.com/ Although the website says it is a Microsoft Training Program, not sure how much credibility & recognition it has. If someone attended the program, please share feedback about the program as well.


title: Is there any example or resource explaining/showing code from High-level to Low-level to deep down Machine code?

text: I have been searching for an example over the internet that shows any operation like saving a file or drawing anything in UI or any other sort that shows the implementation from High-leve language code to Low-level code to deep down machine level code. The basic idea is to explain the computer working in a nutshell. Like, in high-level laguage we write `int c= int a + int b` which is compiled into low- level code `IL_0001: ldarg.1 IL_0002: ldarg.2 IL_0003: add` and then to machine level code. Any example or code flowchart from high-leve language to deep down machine code will be helpful.


title: Can memristors change programming paradigms? In what way?

text: Think about persistent storage that can preserve pointers: among other things there is no need to serialize/deserialize data. For example, you typically build a tree structure and then serialize it into XML so that it can be stored permanently on disk. Now there is no need for that: the structure in memory can be left there as is, possibly given a name, so that it can be used by other programs. Thus the concepts of loading/saving may be transformed into something else, if not eliminated altogether. File systems can become something entirely different: e.g. just memory with symbolic labels. Serialization will still be used in network communication of course. Besides, considering process isolation, memory protection etc, the scenario above may be a bit more complicated than that. One thing is clear though: large persistent addressable storage can at least save a lot of time, and at most cause paradigm shifts in programming. It would be interesting to hear your insights on this.


title: What's the best way to deal with large compressed files over FTP?

text: In my application, I'm getting product information files from an FTP server. They are text files that have been ZIP-compressed. At first, I thought uncompressed the file on the server then reading the text over the web would work, but the uncompressed files are ~900 MB, making it slow and inefficient while causing out-of-memory exceptions. How should I handle this type of problem? Should I download the compressed files, uncompress and process them locally, then re-upload them? Or is there another, more efficient way to do this?


title: C#: Explicitly defining variable data types vs. using the keyword 'var'?

text: In C#, am I encouraged to use the all-purpose var keyword for every variable declaration? If yes, do I have to mention those special characters for literal values within the variable declaration like the M for decimal in the following statement:               var myDecimal = 14.5M;      If it makes a difference, I'm trying to do some web development with C#. Thanks for sharing.


title: Standard way of allowing general XML data

text: I'm writing a data gathering and reporting application that takes XML files as input, which will then be read, processed, and stored in a strongly-typed database. For example, an XML file for a "Job" might look like this:               <Data type="Job">         <ID>12345</ID>         <JobName>MyJob</JobName>         <StartDate>04/07/2012 10:45:00 AM</StartDate>         <Files>             <File name="a.jpeg" path="images\" />             <File name="b.mp3" path="music\mp3\" />         </Files>     </Data>      I'd like to use a schema to have a standard format for these input files (depending on what type of data is being used, for example "Job", "User", "View"), but I'd also like to not fail validation if there is extra data provided. For example, perhaps a Job has additional properties such as "IsAutomated", "Requester", "EndDate", and so on. I don't particularly care about these extra properties. If they are included in the XML, I'll simply ignore them when I'm processing the XML file, and I'd like validation to do the same, without having to include in the schema every single possible property that a customer might provide me with. Is there a standard way of providing such a schema, or of allowing such a general XML file that can still be validated without resorting to something as naïve (and potentially difficult to deal with) as the below?               <Data type="Job">         <Data name="ID">12345</Data>         . . .         <Data name="Files">             <Data name="File">                 <Data name="Filename">a.jpeg</Data>                 <Data name="path">images</Data>             . . .         </Data>     </Data>


title: How to choose the most suitable technologies for your project?

text: While architecting the system, often you have to choose the appropriate technologies to be used for every module. What are the different parameters to be considered while choosing the technologies/frameworks? How those parameters can affect the project quality, schedule, expense? Can anybody please explain in detail.


title: Building a complete program?

text: Reading books, watching videos, and reviewing tutorials is all very easy. Taking notes and actually learning the material may be slightly harder, but even then, anyone with a decent brain and a fair amount of interest, it's easy enough (not to mention, fun). The thing is, it doesn't really prepare you to write a full program or website. Let's say you're those teens (only in highschool, no true (college level) computer science or programming courses, and no real world experience), and you come out with Groupon. Or even Mark Zuckerburg, sure he was a genius, and he was a very capable programmer... but how? How do you recommend that people who are not necessarily new to programming, but new to programming real applications and real programmers go about developing it? What is the "development process" - especially for single programmers (or maybe 2-3 teens)? Also, as far as web development goes, what is the process? Was something like Facebook or Groupon written with a framework (like CodeIgniter or Zend for PHP)? Or do they develop their own frameworks? I'm not asking how to come up with a great idea, but how to implement great ideas in an effective way? Does anyone have advice? I've read a couple of books on both C and C++ (primarily the C Programming Language and the C++ Programming Language) and taken AP Computer Science (as well as read a few additional books on Java and OOP). I also have read a few tutorials on PHP (and CodeIgniter) and Python. But I'm still in highschool, and I'm technically not even old enough to work at an internship for a few more months.


title: How to organize code review process

text: I'm looking for a light-weight code review process. A couple of requirements, the reviewer must be able to do the review alone at the time of his/her choosing (not tied to check-ins), the reviewer must be able to easily find the target code, the review has to leave some document showing what was reviewed. I know there are tools available for code review but I work in a very ridig environment and introducing new tools is not an option. One idea I've been thinking about is to create a new Visual Studio Task List token called REVIEW, and use it to mark the code that needs reviewing. Something like,               // REVIEW doe_john: New method, not sure about the exception.      Then we would add a Review workitem in TFS (we're using the CMM template). Another possibility, which I would actually prefer, would be to have developers create a TFS Review workitem and add links to code to it, but I don't know if this is possible. Obviously you can add a link to a file, but I'd like to have a link to a particular method. PS. Posted originally to StackOverflow.


title: What is the common approach to component template databases?

text: **My Project:** I have employees who are required to go through a checklist when they encounter a duck, a cat, and a human. In our business, we have a set number of ducks, cats, and humans that come in and out of our doors. When they come in, we have to check that all of these features are present. **The features:** ![example](http://i.stack.imgur.com/rYyiV.png) **Here is our current database design:** ![enter image description here](http://i.stack.imgur.com/v4GP5.png) **Current Approach:**   1. When an animal enters our building, we get their ID.    2. Their ID gives us their animal record.   3. We create a new "check_in" record for the animal   4. Under the check_in record, we use the template given by the animal_type->feature_type relationship      * For example: Sam the duck will have a new check_in created with separate feathers, wings, beak, feet, and eyes check_in_feature entries.   5. We go through the process and set feature_is_present to true or false for each of the features   6. When done, we check them out and the check_in entry is complete **My Question:** In practice, this relational schema is very hard to work with. We've used it for years and are constantly slowed down when looking up information because of the weird joins this design tends to require. I have no doubt that this is a known problem with a more elegant solution than using this naive approach. Anyone know a better way to structure this, or better approach that will be easier and more efficient to work with? EDIT: Just realized there are artifacts from our actual system in the navigation properties sections, just ignore those. I don't want to recreate the images if I can avoid it


title: Which books are good resources for designing APIs

text: I am looking for a book on how to design a web-service API. I'm constrained to using RPC-style Web services. In particular, I'm looking for guidance on   * [balancing...] **granular** _vs_ **course services**   * **required parameters** _vs_ **optional parameters**   * **small chatty services** _vs_ **services with large payloads** I'm also looking to address strategies for making reference data and caching on the consumer side. Even things like how to establish a rational naming convention are helpful. Which books are good resources for designing a web API that addresses these questions?


title: Agile software development: How do you react *financially* to changing user requirements?

text: There's one thing I've always wondered when reading about all this "agile development" stuff here on SE and other sites: In "traditional" software engineering, you   1. collect the user's requirements,   2. write a specification based on these requirements,   3. give it to the customer and bill him for the work done so far,   4. do a (rough) technical design, so that you can estimate the cost of implementation,   5. give the user a price quote for the implementation,   6. wait for the customer to sign the specification and accept the offer,   7. design, implement, test,   8. bill. If, during the process, the requirements change, you send an offer (with a price) for the desired changes (or do it for free if the change is small, you like the customer and the customer doesn't do it too often). So, how does this work (financially) in an agile project, where frequent requirement changes are a part of the process?   * Do you write an offer for every design change? (Wouldn't this be quite a mess?)   * Or do you negotiate a fixed price and _hope_ that the customer does not change the requirements too often? (Could be risky, I know customers who would use this opportunity to request new features for years before accepting that the project is completed.)   * Or do you just bill the customer for the total time required? (Could be risky for the customer, who does not know the cost in advance.)


title: Object construction design

text: I recently started to use c# to interface with a database, and there was one part of the process that appeared odd to me. When creating a SqlCommand, the method I was lead to took the form:               SqlCommand myCommand = new SqlCommand("Command String", myConnection);      Coming from a Java background, I was expecting something more similar to               SqlCommand myCommand = myConnection.createCommand("Command String");      I am asking, in terms of design, what is the difference between the two? The phrase "single responsibility" has been used to suggest that a connection should not be responsible for creating SqlCommands, but I would also say that, in my mind, the difference between the two is partly a mental one of the difference between a connection executing a command and a command acting on a connection, the latter of which seems less like what I have been lead to believe OOP should be. There is also a part of me wondering if the two should be completely separate, and should only come together in some sort of `connection.execute(command)` method. Can anyone help clear up these differences? Are any of these methods "more correct" than the others from an OO point of view? (P.S. the fact that c# is used is completely irrelevant. It just highlighted to me that different approaches were used)


title: OO Software Architecture - base class that everything inherits from. Bad/good idea?

text: I am reviewing a proposed OO software architecture that looks like this:   * `Base`     * `Foo`       * `Something`     * `Bar`       * `SomethingElse` Where `Base` is a `static` class. My immediate thought was that every object in any class will inherit all the methods in `Base` which would create a _large_ object. Could this cause problems for a large system? The whole architecture is hierarchical.. the 'tree' is much bigger than this really. Does this sort of architecture have a name (hierarchical?!). What are the known pros and cons?


title: How to discriminate commented code and documentation comments

text: After using version control tools, it is no longer necessary to comment out old code. However, some team members still comment out old code. Therefore, I want to clean them up. I want to mark commented lines which are really comments / documentation, so that every time I do not need to re-read all commented regions. The unmarked lines left are new commented code. How do I achieve this? Any existing tools or need to write on my own? Similar concept: in git, we have 'partial commit' to select some lines to commit. However, the lines marked in 'partial commit' is valid once only.


title: Path to learning compiler design

text: I'm not sure if this is an acceptable question, but compiler-os-design-where- to-start was, so I figured that I'd take a shot at it. I have taken no formal Computer Science classes. I have programmed in Python and attempted C# without success. My technical vocabulary is expansive, yet scattered over a very wide range of computer science topics. I have a very long way to go before I can get to a level where I could reasonably read a book about compiler design/theory. **I am asking what steps I need to take before attempting compiler design.** I have some examples here already:   * Computer architecture   * Binary   * How booting/kernels/OSes work   * Imperative vs. Comparative language design   * "Grammars" At least these are some examples of what I've seen. Edit: I can't for the life of me see how this problem is unclear. I quite clearly bolded what I was asking. I was expecting it to be marked as biased, vague/broad, or too generalized, but certainly not unclear. Don't be afraid to say it's unconstructive (just make sure whatever it is classified under is accurate).


title: Real world implementation of functional programming?

text: I am trying to acquaint myself with different types of languages to understand the areas in which each one of them is extremely good at. So far, I have dabbled into C - a procedural language, C++ & java - static typed Object Oriented languages and groovy - a dynamic typed Object Oriented language. Every programming language has probably been started to answer a need. And I presume every language is extremely good at at least one thing because of which it becomes a standard in a specific area or field. Like C, C++ have become standard in areas like browser or game development. Python in the Linux world for its easy scripting ability, Java in the enterprise world, etc. Now I am interested to learn a functional programming language like Clojure or Lisp. So, where are functional programming languages used in real world scenarios? I don't think that one would use Clojure or Lisp for developing applications or UIs. So on what kind of projects should I indulge into after going through the basic tutorials and learning resources to get a brief understanding about the implementation of functional programming? And do you strongly recommend on One language in specific, like say clojure?


title: Is MVC now the only way to write PHP?

text: Hey... its XMAS Eve and something is bugging me... yes, I have work on my mind even when I am on holiday. The vast amount of frameworks available for PHP now use MVC. Even ASP.net has its own MVC module. I can see the attraction of MVC, I really can and I use it frequently. The only downside that I can see is that you have to fire up the whole system to execute a page request. Depending on your task this can be a little wasteful. So the question. In a professional environment is this the only way to use PHP nowadays or are their other design methods which have alternative benefits?


title: Avoiding null in a controller

text: I'm trying to work through how to write this code.               def get(params):         """ Fetch a user's details, or 404 """         user = User.fetch_by_id(params['id'])         if not user:             abort(404)         # Render some template for the user...      What's the best way to handle the case where the lookup fails? One principle says you should avoid returning null values from functions. These lead to mistakes and AttributeErrors etc. later on in the file. Another idea is to have `fetch_by_id` raise a ValueError or similar if no user exists with that id. However there's a general principle that you shouldn't use exceptions for control flow, either, which doesn't help much. What could be done better in this case?


DR-DOS, Plan, BSD, Sun Solaris, HP/UX, OpenServer.....and so on. Why high-tech OSs (like UNIX family) are mostly command based (rather than GUI based)?


title: For ASP.NET Programmers: Does the executable 'dcpromo' have any significance?

text: `Dcpromo.exe` is famous among MCSEs for being they only way to create a Windows Domain Controller (in other words an Active Directory Domain) ... which in turn is often used by the ASP.NET Membership system. I'm trying to determine if I should put content on "www.dcpromo.com" geared for developers or more towards sysadmins. To me, a logical extension of this "domain controller on the internet" is to use WIF for the ASP.NET Membership system. We'd then have a website that will serve the developer's interests in the SSO, SAML, user managment and identity areas we all struggle with. So my question is: **Q:** Do programmers see a connection between the utility `dcpromo.exe` and ASP.NET Membership? If so does it make sense to have a purpose of http://www.dcpromo.com help developers in the areas of membership and cloud computing?


title: How do programmers stay healthy?

text: Being a programmer is not a very healthy profession - long hours of sitting in front of a computer, with impending deadlines just over the cubicle. This takes a toll on the body and mind. So what tips do you have for programmers in order to stay healthy?


title: How to build configurable forms?

text: I'm working on two separate projects now that are essentially just CMSs -- a bunch of forms for recording various bits of information. Each project is built to serve many clients, and each client seems to want to record slightly different information. In one project we've handled this either by copying and pasting all the logic surrounding that form for each client so that we could make the changes without affecting the other clients, or we build a master form containing all possible inputs and then programmatically remove the inputs that the client doesn't want (our framework allows us to remove inputs (essentially from the 'controller') before the final template rendering). Neither solution is really clean and causes the forms to be riddled with "if" conditions based on which client we're serving. The other project I'm just starting, and I don't want to run into the same pitfalls again, but I'm having trouble coming up with a good way to solve this problem. I could list out all the input IDs for each form element in the database and then create a mapping between them and the clients, and then in my form template wrap each widget rendering with a check to see if the input is enabled for the current client. On the backend -- when the form is submitted -- I could save only the data that is submitted and forgo the conditionals for the most part. This creates a dependency on the IDs used in the template must match those recorded in the DB -- I don't want to create the entire form programatically as that wouldn't give me enough customizability. That's the best I can come up with. Has anyone dealt with this sort of problem before? How did you approach it? What worked, what didn't? * * * For comparison, you might consider sites like Freshbooks, or Trello, or a bug tracker, or Facebook -- if any of those apps let each user customize his or her page to add or remove inputs so that they could record only the stuff they care about -- how would they manage this complexity from an architectural point of view?


title: Rails vs. Drupal

text: I was querying indeed.com/salary to investigate general market trends. When comparing ruby on rails with drupal, you would observe a substantial difference between these two. I'm not sure if the data on indeed.com is reliable or not but I'd appreciate your comments if you have ever tried both rails and drupal. Actually I am a .net developer considering an alternative to my asp.net mvc skills and I like to learn some non-microsoft web programming skills as well.


title: How can I earn money on my software?

text: Over last several months I had written some good piece of numerical software in C# in .NET 4.0. Currently it has only versions for Windows XP/Vista/7/8/8.1 but thanks to Mono/Xamarin it wouldn't be too hard to port it to Linux, Mac OS and even to mobile devices. The software has some really nice features of programs like Mathematica, Matlab but it's easier and faster (and of course not that huge). But still it has: real and complex charts of any custom function, support for most of the special functions (bessel, gamma, mathieu etc), scripting language with easy matrix calculations, scientific calculator, numerical calculations etc. It has less bugs and more features every day because I really love to work on this. I was working on this software mainly as a hobby but few of my friend who are testing it told me that it is really good so I started to wonder how can I make money on it (or should I even try this). If I even try to publish it as a commercial product what should I do? I consider some options.   1. Make it free&open source, I would not make any money of it then but I would get a lot of users and popularity. It might be the best option for the development of my software. Still I feel like when it will be free and open source I would waste a lot of time on working for free.   2. Make it freeware on desktop but charge (or put ads in it) on mobile devices. It sounds reasonable but porting it on mobile devices would consume much time and I would need a lot of time to develop many different versions.   3. Make it commercial software. It could be nice if I will find people who will want to buy my application but it has many difficulties in it. I dont have any experience there, problems arrive: how should I charge for this, code obfuscation, key licensing etc. Any help would be appreciated here on how to do this.   4. Something else? I have some other questions too, e.g. what I need to do in the start. I guess I need to create support website and put some bug tracking software? Any components would you recommend for this (support website+ bug tracking software)?


title: Is there a purpose for using pull requests on my own repo if I am the only developer?

text: So I got started with a real project of mine on GitHub and things are going pretty well and ideas are flowing a lot faster than I initially thought. In order to keep things organized, I setup some branches so I can develop different features separately. Now when I push my branch to GitHub, I have that section where I have two buttons : `Pull Request` and `Compare` with the name of the branch I recently pushed to. I understand the purpose of the `Compare` button but I don't get why I would want to create a pull request on my own repo. Can someone explain me why I would do that? Is it useful to make pull request on my own repo if I am the only developer?