title: Term For Errors That Occur In Certain Environments

text: What is the term for an error or bug that exhibits itself on computers with certain environments/setups only? **Context:** We have produced our own anti-piracy software. We distribute applications that are locked using this anti-piracy software. The anti-piracy software is simply a windowless Windows OS executable. When it runs; it downloads an encrypted file (Client File) from our server, decrypts it, checks that the users serial number occurs in the Client File and writes the result (hashed) to a Result File. Each of our companies products 'consults'/accesses this executable to verify that the user is allowed to run and use our product. On some of our clients computers, our anti-piracy executable is being blocked from running or blocked from downloading the Client File (its unknown what the cause is yet). These clients are Civil Engineering firms that have their Windows OS's very controlled and 'sandboxed' for security reasons. _So to sum up, the anti-piracy software works and passes our tests on most of our clients computers and on all our in-house test nodes. The software fails on these few Civil Engineering clients computers._ **What would be the term (if any) for this kind of error or bug in software?**


title: Why do relational databases only accept SQL queries?

text: As far as I know, most relational databases do not offer any driver-level API for queries, except a `query` function which takes an SQL string as an argument. I'm thinking how easier it would be if one could do:               var result = mysql.select('article', {id: 3})      For joined tables, it would be slightly more complex, but still possible. For example:               var tables = mysql.join({tables: ['article', 'category'], on: 'categoryID'});     mysql.select(tables, {'article.id': 3}, ['article.title', 'article.body', 'category.categoryID'])      Cleaner code, no string parsing overhead, no injection problems, easier reuse of query elements... I can see a lot of advantages. Is there a specific reason why it was chosen to only provide access to queries through SQL?


I never did generic programming before, being more of a python guy, and generally using OOP. As I moved into generic programming, I faced some issues. I read the FAQ, but I am not satisfied. What I want to ask are the following questions (I am mostly interested in the first, but answering the others will be extremely welcome): Are generic programming and OOP mutually exclusive? Meaning, for example, are you supposed to have methods and functions accepting the template, instead of baseclass or abstract pure class? * * * Some other questions I've got, only to provide context to my lack of understanding are: How do traditional design patterns react to generic programming approach and concepts? How to prevent (or control) the genericity of each class/template to "bubble up" in the dependencies dictated by the program logic, in particular when two types are related and go always together (e.g. a RealNumberProducer class and double vs ComplexNumberProducer and std::complex)?


title: How is determined an impact of a requirement change on the existing code?

text: How companies working on large projects evaluate an impact of a single modification on an existing code? * * * Since my question is probably not very clear, here's an example: Let's take a sample business application which deals with tasks. In the database, each task has a state, 0 being "Pending", ... 5 - "Finished". A new requirement adds a new state, between 2nd and 3rd one. It means that:   * A constraint on the values 1 - 5 in the database must be changed,   * Business layer and code contracts must be changed to add a new state,   * Data access layer must be changed to take in account that, for example the state `StateReady` is now 6 instead of 5, etc.   * The application must implement a new state visually, add new controls for it, new localized strings for tool-tips, etc. When an application is written recently by one developer, it's more or less easy to predict every change to do. On the other hand, when an application was written for years by many people, no single person can anticipate every change immediately, without any investigation. So since this situation (such changes in requirements) is very frequent, I imagine there are already some clever techniques and ways to predict the impact. Is there any? Do you know any books which deal about this subject? * * * Note: my question is not related to How do you deal with changing requirements? question. In fact, I'm not interested in evaluating the cost of a change, but rather the way to predict the parts of an application which will be concerned by the change. _What_ will be those changes and _how difficult_ they are really doesn't matter in my question.


title: What are the benefits of not including other header files in a header file?

text: Sometimes, a header file uses objects that are in declared in other header files. The user of this header file would have to include the dependency anyway and get the order correct too.


title: Overview of computer science, programming

text: Where I can find overview of computer science, programming etc.? I graduated in physics and want to begin programming or similar and I'm not even sure of what's out there or where to begin. What I'm looking for is some broad overview of existing technologies - just like you have a book "Physics of elementary particles" that explains general view of that area, but for computers/programming of course. Do you have some book to recommend?


title: Tips for working at home?

text: > **Possible Duplicate:**   >  I program from home. What can I do to be more productive? What about if your office is your home? I'm not talking about a self-employed devoloper. I'm talking about been hired and work from your home. Do you have some tips for been focus on work? Thanks


title: Nested classes vs namespaces

text: Is it good to use nested classes or should I use namespaces instead? In context: I have a templated codec loader and a codec have In objects and Out objects               template<class TypeOfData>     class Codec         {         private:             typename TypeOfData::In* reader;             typename TypeOfData::Out* writer;         };      On the other hand, I cannot use               using TypeOfData;      if i dont want to :: my way to a static method.


title: What specific task could be given to a Java web development candidate during an interview?

text: I'm looking for ideas for tasks that I can give to a Java programmer candidate to check his knowledge of Java; I'm specifically looking for a Java developer for web applications.


title: How to simulate and estimate long running application

text: We are building a large, modular application that is intended to run across multiple processors. I need to develop a method to estimate how long it will take to run all of the functions. I already have the function's execution time on a single processor. Now I need to find a way to account for the communication overhead. I also need to identify if there is a difference in execution time based upon particular functions being spread across a number of processors instead of remaining on the same processor. How should I simulate the overall application in order to identify the communication overhead and to provide an estimate for what the total execution time would be?


title: Is there a downside to using AggressiveInlining on simple properties?

text: I bet I could answer that myself if I knew more about tools to analyze how C#/JIT behaves but since I don't, please bear with me asking. I have simple code like this :                   private SqlMetaData[] meta;              [MethodImpl(MethodImplOptions.AggressiveInlining)]         private SqlMetaData[] Meta         {             get             {                 return this.meta;             }         }      As you can see I put AggressiveInlining because I feel like it should be inlined.   I think. There's no guarantee the JIT would inline it otherwise. Am I wrong? Could doing this kind of thing hurt the performance/stability/anything?


title: Web app that runs other applications?

text: I am trying to write a web application that interacts with a service that would run scripts at the system level. Something like a website that you can schedule a job, the service will run the job with the given inputs, write the outputs to a database, and inform the website of its status. A few questions: How is this typically done? Do I write to a "JOBS_QUEUED" table in my database and have the service check that? How can I pass a "% done" back to the web page? Is there a name for this type of thing? Not sure if it matters, but I am working with Ruby on Rails right now.


title: Dealing with the node.js callback pyramid

text: I've just started using node, and one thing I've quickly noticed is how quickly callbacks can build up to a silly level of indentation:               doStuff(arg1, arg2, function(err, result) {         doMoreStuff(arg3, arg4, function(err, result) {             doEvenMoreStuff(arg5, arg6, function(err, result) {                 omgHowDidIGetHere();             });         });     });      The official style guide says to put each callback in a separate function, but that seems overly restrictive on the use of closures, and making a single object declared in the top level available several layers down, as the object has to be passed through all the intermediate callbacks. Is it ok to use function scope to help here? Put all the callback functions that need access to a global-ish object inside a function that declares that object, so it goes into a closure?               function topLevelFunction(globalishObject, callback) {              function doMoreStuffImpl(err, result) {             doMoreStuff(arg5, arg6, function(err, result) {                 callback(null, globalishObject);             });         }              doStuff(arg1, arg2, doMoreStuffImpl);     }      and so on for several more layers... Or are there frameworks etc to help reduce the levels of indentation without declaring a named function for every single callback? How do you deal with the callback pyramid?


title: one programmer, many languages -- the name dilemma

text: When you work across multiple programming languages, there is a problem you encounter... _**A valid name (identifier) in one language is invalid in another._** For example... `var` `new` `function` `this` are a keywords in JavaScript, but you can use them freely in Python. Similarly `list` `dict` `def` can be used in JavaScript without problems. This is a very common and something programmers generally quickly become acquainted with when they program in multiple languages. However, when you're working in collaboration, you have to lay out some rules/guidelines for your team members to ensure consistency and uniformity in the code. With teams, this issue becomes more important than simply remembering what's valid and what's not while you program. So, my question is, what strategies you adopt...   * simply take a union of all the reserved words present in all the languages you use, hand out a list to everybody and abstain their use?   * accept the diversity and take extra pains when "context switching"   * adopt an intermediate ground where one language can use the other's, but not vice-versa (Note: i am only talking about Python and JavaScript in this question ... but please answer the question more broadly) **\-- UPDATE --** Thanks for all the answers. So the general consensus i see emerging is to let programmers use any name regardless of what they do other languages -- as long as names are descriptive, it doesn't hurt.


title: What would you do if a senior level programmer stole your code?

text: This was my experience at a previous company. As it was a small startup company, some of the normal software development procedures were not followed strictly. One of my colleagues was a senior programmer with the company for 2 years. His skills were quite lacking. He would allocate his tasks to me and then take credit for the work himself. He did this regularly, while I would also have to finish my own tasks. I felt that I couldn't express this situation to senior management as that colleague had their trust. Later, I tried to delay his tasks assigned to me so that reflect poorly on him (as he couldn't finish tasks) Also, client complaints piled up unresolved issues. Now the company knows about him. Actually, now I'm heading to a new company as a Lead. Now I'm completely free with these situation. Have any of you experienced situations like this? What would/did you do?


title: What happened to the this type of naming convention?

text: I have read so many docs about naming conventions, most recommending both Pascal and Camel naming conventions. Well, I agree to this, it's ok. This might not be pleasing to some, but I am just trying to get your opinion on why you name your objects and classes in a certain way. What happened to this type of naming conventions, and/or why are they bad? I want to name a structure, and I prefix it with "struct". My reason is that, with IntelliSense, I see all structures in one place, and anywhere I see the struct prefix, I know it's a "struct":               structPerson     structPosition      another example is the enum, although I may not prefix it with "enum", but maybe with "enm":               enmFruits     enmSex      again my reason is that in IntelliSense, I see all my enumerations in one place. Because .NET has so many built-in data structures, I think this helps me do less searching. Note that I used .NET in this example, but I welcome language agnostic answers.


title: What did Alan Kay mean by "assignment" in The Early History of Smalltalk?

text: I have been reading The Early History of Smalltalk and there are a few mentions of "assignment" which make me question my understanding of its meaning: > Though OOP came from many motivations, two were central. The large scale one > was to find a better module scheme for complex systems involving hiding of > details, and the small scale one was to find a more flexible version of > assignment, and then to try to eliminate it altogether. (from _1960-66--Early OOP and other formative ideas of the sixties_ , Section I) > What I got from Simula was that you could now replace bindings and > assignment with _goals_. The last thing you wanted any programmer to do is > mess with internal state even if presented figuratively. Instead, the > objects should be presented as _site of higher level behaviors more > appropriate for use as dynamic components_. (...) It is unfortunate that > much of what is called "object-oriented programming" today is simply old > style programming with fancier constructs. Many programs are loaded with > "assignment-style" operations now done by more expensive attached > procedures. (from _"Object-oriented" Style_ , Section IV) Am I correct in interpreting the intent as being that objects are meant to be façades and any method (or "message") whose purpose is to set an instance variable on an object (i.e. an "assignment") is defeating the purpose? This interpretation appears to be supported by two later statements in Section IV: > Four techniques used together--persistent state, polymorphism, > instantiation, and methods-as-goals for the object--account for much of the > power. None of these require an "object-oriented language" to be employed-- > ALGOL 68 can almost be turned to this style--and OOPL merely focuses the > designer's mind in a particular fruitful direction. However, doing > encapsulation right is a commitment not just to abstraction of state, but to > eliminate state oriented metaphors from programming. ...and: > Assignment statements--even abstract ones--express very low-level goals, and > more of them will be needed to get anything done. Generally, we don't want > the programmer to be messing around with state, whether simulated or not. Would it be fair to say that opaque, immutable instances are being encouraged here? Or is it simply _direct_ state changes that are discouraged? For example, if I have a `BankAccount` class, it's OK to have `GetBalance`, `Deposit` and `Withdraw` instance methods/messages; just make sure there isn't a `SetBalance` instance method/message?


title: What are the types of dynamically typed languages arrays?

text: For example, in JavaScript, I can do such things:               var arr = [1, "two", /three/, [4]];      There is no way to do such a thing in C! Except by using a `void*`, which is not an efficient/safe way. Is this how implementations do it? Using `void*` everywhere?


title: Recommended Payment Schedule for Freelance Development

text: I've been a freelance developer for many years and am setting up a system designed to attract clients through one of my developer websites. If successful, these would be clients I do not know, and some jobs may be very small. When working with clients I know on larger projects, I'm accustomed to doing the work before I get paid. But, here, that seems risky. I'm looking for suggestions on the payment schedule I should require for small projects. I suspect potential clients will not be willing to pay the full amount up front, and so the solution will probably be some sort of compromise.


title: Event notification for ::SCardListReaders()

text: In the PC/SC (Personal Computer Smart Card) Appln, I have (MSCAPI USB CCID based) 1) Calling ::SCardListReaders() returns SCARD_E_NO_READERS_AVAILABLE (0x8010002E). This call is made after OS starts fresh after reboot, from a thread which is part of my custom windows service. 2) Adding delay before ::SCardListReaders() call solves the problem. 3) How can I solve this problem elegantly ? Not using delay & waiting for some event to notify me. since a) Different machines may require different delay values b) Cannot loop since the error code is genuine c) Could not find this event as part of System Event Notification Service or similar COM interface d) platform is Windows 7 Any Help Appreciated.


title: How to know whether to create a general system or to hack a solution

text: I'm new to coding , learning it since last year actually. One of my worst habits is the following: Often I'm trying to create a solution that is too big , too complex and doesn't achieve what needs to be achieved, when a hacky kludge can make the fit. One last example was the following (see paste bin link below) http://pastebin.com/WzR3zsLn After explaining my issue, one nice person at stackoverflow came with this solution instead http://stackoverflow.com/questions/25304170/update-a-field- by-removing-quarter-or-removing-month When should I keep my code simple and when should I create a 'big', general solution? I feel stupid sometimes for building something so big, so awkward, just to solve a simple problem. It did not occur to me that there would be an easier solution. Any tips are welcomed. Best


title: How can I speed up the process of typing up specification during a meeting with developers?

text: I'm studying source code with other developers, and my job is to type up the specifications as the lead programmer describes what each function does. Are there any tips/tricks to doing this faster? a lot of times I have to ask him to repeat himself, as I didn't hear it well. How can I be a better specification writer?


title: What options are there for splitting UI layout from code logic using a markup language?

text: What tools similar to GWT's UIBinder exist in other languages? By this I mean a system where you can define your UI layout in a markup language (preferably html+css) and attach the functionality to the layout using the code. I'm most interested in anything for python, but answers in other languages would interest me as well. I'm interested because the benefits of having a non-programmer work directly on the layout without needing to touch the code and adjust a bunch of UI toolkit method calls is very productive. I'm aware of Flex for flash, but is there anything else out there? What search terms might I use to find such frameworks? I've looked around but I haven't found anything concrete. Edit: I'm not only interested in web frameworks, but desktop applications as well. Edit2: My question appears to be close to a duplicate of http://stackoverflow.com/questions/2962874/what-are-the-open-source- alternatives-to-wpf-xaml


title: How can I satisfy this project requirement?

text: I'm part of a two-person team that is building a web-based virtual tour application with specific extra functionality that doesn't exist in current applications. This is a summer school project. The team lead wants this application to be as platform and dependency-agnostic as possible. To do this, we're using Google's Fusion Tables and StreetView APIs to display the images and serve as a database. This way, a client installing this application on their server doesn't have to worry about configuring and maintaining a local database and all that is necessary on their end is a Google Apps account and the images themselves. My issue is how does the client make requests for images and data without a server-side language? Most, if not all of the data will be textual, and thus be able to render as JSON and parsed as such. However, that leaves the issue of the images themselves. They will be hosted on a to-be-determined location, and I need some way to access them. Using Ajax, I can execute a PHP call to load an image easily, and I already know how to do this. Its been suggested that I use the Java client library to interface with GData services, but I think this is overcomplicating things. My arguments for including PHP as an application requirement are   1. PHP is synonymous with hosting. I've yet to run across a commercial host that doesn't offer PHP   2. I already know how to implement the Ajax calls to the PHP function.    3. As this application has a 6 week deadline, I'd like to stick with what I know rather than learning a whole new methodology His arguments for looking somewhere else are   1. No guarantee that PHP will be loaded on the server to be used. Our school's CMS is based in Java, and PHP is not installed   2. Java is a standard inclusion in server and client configruations    3. The application should be server and dependency agnostic in the sense that it can be uploaded to a folder and accessed without any configuration Honestly, if I had the time, it would be an interesting side project to include this type of functionality, especially since I've never done it before and it sounds interesting. But I keep thinking about that 6 week deadline, and as I'm the one that will be doing the majority of the coding, I just don't think I can do it in time without PHP.


title: Implementation of a serial communication protocol

text: I need to implement a serial protocol to communicate with a device using .NET (C#). This implementation should be a library (.dll) to be used in different projects. I have the datasheet that describe the protocol (baudrate, stop bits, message protocol, commands, etc.) and I know that I need to use `SerialPort` class from `System.IO.Ports` namespace. But I have some doubts on how to struture/organize the code. Here are some questions:   1. Should I be concern about thread management or this aspect should be managed by how is using the library?   2. Can I manage received/sent data using strings or should I use bytes?   3. Commands and fixed contents should be stored using `enums`, `constants` or something else? Maybe those questions could be subjectives, but I would like to have some feedback from someone with more experience than me. If someone has some examples, tips, best pratices, etc. on this subject, I will be very grateful.


title: which directory to initialize git repo

text: I'm just getting started with Git. I'll be doing PHP development and was wondering if I should initialize my repo within my server root folder, or any directory on my hard drive and publish my changes to the server root. Does it really matter, any pros/cons? For now, this is just to keep track of personal projects I'm doing for fun, but any feedback on best practice, personal preference/experience, do's and don'ts will be greatly appreciated.


title: What is the benefit of hypermedia (HATEOAS)?

text: I don't understand the benefit to HATEOAS for APIs intended for use by programs (as opposed to humans directly browsing your API). Sure, the customer isn't bound to a URL schema but they are bound to a data schema which is the same thing in my mind. For example, assume I want to view an item on an order, let's assume I've discovered or know the order URL already. HATEOAS:               order = get(orderURL);     item = get(order.itemURL[5]);      non-HATEOAS:               order = get(orderURL);     item = get(getItemURL(order,5));      In the first model I have to know the fact that the order object has an itemURL field. In the second model I have to know how to construct an item URL. In both cases I have to "know" something ahead of time so what is HATEOAS actually doing for me?


title: Why REST Api do not follow the Facade design pattern

text: In comparing REST [api] structure with a OO model, I see these similarities: Both:   * Are data oriented      * REST = Resources      * OO = Objects   * Surround operation around data      * REST = surround VERBS (Get, Post, ...) around resources     * OO = promote operation around objects by encapsulation However, good OO practices do not always stand on REST apis when trying to apply the facade pattern for instance: in REST, you do not have 1 controller to handle all requests AND you do not hide internal object complexity. ![Simple object relation between 2 concepts](http://i.stack.imgur.com/SyVav.png) ![Analogy between OO and REST](http://i.stack.imgur.com/1CAFF.png) On the contrary, REST promotes resources publishing of all relations with a resource and other on at least two forms:   1. via resource hierarchy relations (A contact of id 43 is composed of an address 453) : `/api/contacts/43/addresses/453`   2. via links in a REST json response: > >     >> GET /api/contacts/43 >     << HTTP Response { >        id: 43, ... >        addresses: [{ >           id: 453, ... >        }], >        links: [{ >           favoriteAddress: { >               id: 453 >           } >        }] >     } >   ![Basic complexity hidden by objectA](http://i.stack.imgur.com/xwaSC.png) Coming back to OO, the facade design pattern respect a `Low Coupling` between an _objectA_ and its ' _objectB client_ ' and `High Cohesion` for this _objectA_ and its internal object composition ( _objectC_ , _objectD_ ). With the _objectA_ interface, this allow a developer to limit impact on _objectB_ of the _objectA_ internal changes (in _objectC_ and _objectD_ ), as long as the _objectA_ api (operations) are still respected. In REST, the data (resource), the relations (links), and the behavior (verbs) are exploded in different elements and available to the web. Playing with REST, I always have an impact on code changes between my client and server: Because I have `High Coupling` between my `Backbone.js` requests and `Low Cohesion` between resources. I never figured out how to let my `Backbone.js javascript application` deal with " _REST resources and features_ " **discovery** promoted by REST links. I understand that the WWW is meant to be served by multi servers, and that the OO elements had to be exploded to be serviced by many hosts in there, but for a simple scenario like "saving" a page showing a contact with its addresses, I end up with: > >     GET /api/contacts/43?embed=(addresses) >     [save button pressed] >     PUT /api/contacts/43 >     PUT /api/contacts/43/addresses/453 >   which lead me to move the saving action atomic transactional responsibility on the browsers applications (since two resources can be addressed separately). _With this in mind, if I cannot simplify my development (Facade design patterns not applicable), and if I bring more complexity to my client (handling transactional atomic save), where is the benefit of being RESTful ?_


title: What is the simplest archive file format to aim for when writing collections of files?

text: I've created a PHP-based document management system and hosted it on my Raspberry Pi. I created a "backup" function that zips together all the documents, but it takes too long due to the hardware constraints of the Pi, as well as the fact that compression cannot be disabled when creating zip files in PHP. This has led me to think that perhaps I should just devise some sort of binary file format that allows multiple files to be stored in it, and dump all my uncompressed documents into it when the user asks for backups. Oddly, I'm not necessarily concerned about the lack of possible "unarchivers". Which file format is the easiest to implement, whether a standard format, or a proposed new format? Is there any other alternative for solving my problem that does not require implementing a custom archiver? Note that I wish to avoid the following:   * Shell commands (not portable).   * Installing third party dependencies (may not work on a third party hosted system).   * Rewriting my system in a different language.


title: Should my colleagues review each others code from source control system?

text: So that's my story: one of my colleagues uses to review all the code, hosted to revision system. I'm not speaking about adequate review of changes in parts that he belongs to. He watches the code file to file, line to line. Every new file and every modified. I feel just like being spied on! My guess is that if code was already hosted to control system, you should trust it as workable at least. My question is, maybe I'm just too paranoiac and practice of reviewing each others code is good? P.S: We're team of only three developers, and I fear that if there will be more of us, colleague just won't have time to review all the the code we'll write.


title: Are there efforts to build a collaboratively edited HTML/JS/DOM reference?

text: W3Schools has a reputation of being incomplete, sometimes incorrect, and ridden with advertising; still, when looking to look up some things or link to documentation when answering a SO question, it still is the only handy cross- browser resource. There are other resources like the Mozilla Developer Network that is doing an increasingly great job documenting JavaScript, and the legendary and great Quirksmode. But they, as brilliant as they are, cover only parts of the areas I am talking about, and provide no community editing and quality control options. Is anybody aware of efforts to create a collaboratively edited, cross-browser HTML/CSS/JavaScript/DOM encyclopedia? If you will, I'm thinking of a challenger to W3Schools like SO was to Experts Exchange.


title: Scripts to run Java programs - e.g. Ant

text: My team currently use an Ant script to _execute_ various Java programs. Note that I am not asking about managing the build/deployment cycle for which we are already using Maven (quite happily). For example, we use something like the following:               <path id="lib">       <fileset dir="path/to/lib" />     </path>          <path id="run" >       <path refid="lib" />     </path>          <target name="aJavaProgram" >       <java classname="path.to.AJavaProgam"              classpathref="run" fork="yes" failonerror="false" append="true" />     </target>          <target name="anotherJavaProgram" depends="aJavaProgram" >       <java classname="path.to.AnotherJavaProgam"              classpathref="run" fork="yes" failonerror="false" append="true" />     </target>      We originally chose Ant for the following reasons (or rather I didn't choose Ant, it was that way when I joined, but I think these are good reasons for the choice):   * it was an easy way of managing dependencies (although we now pick up these from Maven)   * it allows us to easily build/maintain dependencies between particular jobs   * we can deploy the Ant script, and the Java libraries, and easily run particular jobs - i.e.      * we don't have to worry about classpaths (configured in the Ant script)     * we don't have to worry about building jars with main classes specified in the manifest     * we can use Ant to create / store / manage arguments passed to main() methods   * we can plug these ant scripts into our IDEs and run the jobs from there. Generally speaking, we have been very happy with this. However, an increasing issue is the ant-java-shutdown hook issue \- this means that if one of these Java programs fails but doesn't finish, terminating the Ant process from which it was started doesn't terminate the Java process - which then has to be done manually, and is a real bind. Also, I'm conscious of two other (possible) factors:   * this is using Ant in a slightly unusual way, which is perhaps not how Ant was intended to be used (or at least, so it seems to me...)?   * I'm not really sure, but it seems that fewer and fewer developers/teams are using Ant these days, with preference for other technologies. So, to clarify:   * I want a flexible approach to execute various Java programs   * the approach that we have been using was to do this via Ant scripts, but this had the following problems:      * terminating the Ant task does not kill the Java program      * this "feels" like Ant is not the right tool for the job   * how might we meet the needs specified above?      * if not Ant, the solution should not face the termination / shutdown hook issue


title: Is this a good practice or not?

text: I have a colleague who has come up with a way of 'genericizing' information from a database so that all his web application's drop-down lists can share the same object in his MVC.NET C# code and Views, which can contain different data depending on what tables it is being used against. We work for a government agency, and we have facilities divided up into areas called "Regions", which contain further subdivided areas called VISNs, which each contain "Sites" or "Facilities". My colleague has developed a very complex security scheme whereby people can be granted access to data based on their permission level which can be assigned by Region, VISN, Site, or any mixture of the three. It's a nice scheme and very clever. However, he has stored procedures that return lists of Regions, VISNs, and Sites based on a person's User Id, and he is returning "generic" values like `TextFieldID`, `TextField`, and `TextParentID`. My first problem with this, is that looking at this data coming out of the database, I would not know what the data is. I feel that fields coming from a query or stored procedure should be descriptive of the data they are delivering. What does everyone else think? The deeper issue for me however is that he is taking some of the data, concatenating it in his stored procedure like this               SELECT DISTINCT         t.VisnID,         NULL,         t.StationID,         'V' + CAST(t.VisnID as varchar) + ': ' + t.Station3N + ': ' + t.StationName,         t.Inactive     FROM Stations t       and sending it back in a "TextField" property, instead of sending back the discrete data separately (`Station3N`, `StationName`) and concatenating it in the View, which would allow for different concatenation depending on what device what accessing the application (perhaps mobile and desktop). His justification is that he can send all his various drop down data and capture them all, regardless of content, in the same C# object named "LookupValue."               public partial class LookupValue : IEquatable<LookupValue>     {         public LookupValue(string textFieldId, string textField, bool inactive)         {             TextFieldID = textFieldId;             TextField = textField;             Inactive = inactive;         }              public LookupValue(string textParentId, string textFieldId, string textField, bool inactive)         {             TextParentID = textParentId;             TextFieldID = textFieldId;             TextField = textField;             Inactive = inactive;         }              public LookupValue(string textParentId, string textSelfParentId, string textFieldId, string textField, bool inactive)         {             TextParentID = textParentId;             TextSelfParentID = textSelfParentId;             TextFieldID = textFieldId;             TextField = textField;             Inactive = inactive;         }              /// <summary>         /// Returns a custom string identifier if the Inactive property is true.         /// </summary>         public string GetInactiveString()         {             string value = "";             if (Inactive)             {                 value = "[I]";             }                  return value;         }              /// <summary>         /// Returns a custom text label that concatenates the TextField property with the custom string identifier of the Inactive property.         /// </summary>         public string GetDisplayNameWithInactiveString         {             get { return TextField + " " + GetInactiveString(); }         }              public bool Equals(LookupValue other)         {             //Check whether the compared object is null.               if (Object.ReferenceEquals(other, null)) return false;                  //Check whether the compared object references the same data.               if (Object.ReferenceEquals(this, other)) return true;                  //Check whether the products' properties are equal.               return TextFieldID.Equals(other.TextFieldID) && TextField.Equals(other.TextField);         }              // If Equals() returns true for a pair of objects         // then GetHashCode() must return the same value for these objects.         public override int GetHashCode()         {             //Get hash code for the TextFieldID field if it is not null.               int hashTextFieldId = TextFieldID == null ? 0 : TextFieldID.GetHashCode();                  //Get hash code for the Code field.               int hashTextField = TextField.GetHashCode();                  //Calculate the hash code for the product.               return hashTextFieldId ^ hashTextField;         }     }      He believes the re-usability of this object is worth the violation of Separation of Concerns and possible future difficulties in handling more than one display variation for a drop-down. I should point out that this object is contained in his Data project namespace (our projects are separated into Data, Web, Services, etc.) instead of the Web project namespace and he also returns this object to the Web layer via his Repository queries which call the stored procedures that I described earlier, which is gross violation of Separation of Concerns in my opinion. I am just looking for some confirmation from other programmers that this is in fact a bad practice, and also looking for ideas I can present him on better ways to do what he is attempting. I have my own ideas, but again I'm just looking for other's ideas so I have more options to present to him. \--Edit -- I forgot to mention that we are using Entity Framework as an ORM, and his Repository classes in his DAL are dumping the data from the stored procs into this LookupValue object.


title: Should I prefer instance methods over class methods in Ruby?

text: I'm working on a rails application, and I've been pulling functionality out of my rails code and into pure ruby classes in lib/. I've found myself often writing classes like this:                class MailchimpIntegration          def subscribe_email(email, fname, lname)         Gibbon.list_subscribe(:id => NEWSLETTER_LIST_ID, :email_address => email,           :merge_vars => {'fname' => fname, 'lname' => lname },           :email_type => "html",  :double_optin => false, :send_welcome => false)       end            def unsubscribe_email(email)         Gibbon.list_unsubscribe(:id => NEWSLETTER_LIST_ID, :email_address => email)       end            def change_details(old_email, email, fname, lname)         Gibbon.list_update_member(:id => NEWSLETTER_LIST_ID, :email_address => old_email,           :merge_vars => {'email' => email, 'fname' => fname, 'lname' => lname })       end            def get_email_info(email)         Gibbon.list_member_info(:id => NEWSLETTER_LIST_ID, :email_address => [email])["data"].first       end     end      My question is: Should I change these methods to be class methods? It seems reasonable to do, as I'll probably end up calling these by just newing up a MailchimpIntegration class each time. However, I generally prefer to have instance methods as they can be more easily stubbed etc, although this seems to be less of an issue in ruby. I have several classes like this in my system, so I'd be keen to see what people think about this.


title: The role of determination of the variable type (floating point or fixed point) in program performance

text: I know with changing the variable type, the speed of the program change. I want to understand the other effects of this change in the software performance. I want to know if we use a floating point variable instead of fixed point variable,the amount of memory consumption and speed of program, what will change?


title: How to design highly scalable web services in Java?

text: I am creating some Web Services that would have 2000 concurrent users. The services are offered for free and are hence expected to get a large user base. In the future it may be required to scale up to 50,000 users. There are already a few other questions that address the issue like - http://stackoverflow.com/questions/2567254/building-highly-scalable-web- services However my requirements differ from the question above. For example - My application does not have a user interface, so images, CSS, javascript are not an issue. It is in Java so suggestions like using HipHop to translate PHP to native code are useless. Hence I decided to ask my question separately. This is my project setup -   1. Rest based Web services using Apache CXF   2. Hibernate 3.0 (With relevant optimizations like lazy loading and custom HQL for tune up)   3. Tomcat 6.0   4. MySql 5.5 What are the best practices to abide by in order to make a Java based application scalable?


title: Learning about a new technology

text: I have approx 9 years of experience in the IT field. I've mainly worked on web applications and currently am looking forward to become a technical architect for J2EE applications. I usually face this challenge; in order to learn a new technology in depth I usually refer to a book. I was recently going through 'Java Persistence with Hibernate' to get in depth knowledge on Hibernate. It takes usually a month for me to complete reading the books/doing some R & D to know about how the APIs work and writing some sample program from books. I should mention that my reading is mostly done in spare time out of my regular project work. At the end of this exercise I get a decent idea about the technology and how it works (its uses in applications etc...). However after couple of months, I also start forgetting about what I read in my previous book (or about previous technology). Mainly because the project on which I work on do not use those technology, so if you do not practice, you will forget those things. For ex: I recently read about FTL, but in my project at the same time we were using plain JSPs, so I did not get chance to apply my FTL knowledge there and I forgot most of what I read about FTL. On one hand, I love to know more about the technologies around us and at the same time I want to keep that knowledge with me so that I could use it in future when needed. What am I doing wrong here? I sometime think that:   1. I should spend more time on one technology before switching on next, so that I could remember most of it.   2. My approach towards learning about new things this way is wrong.   3. Learning through Books might not be a good approach.   4. I need to do something extra to keep my learning up to date (but frankly what is that extra; I don't know). I need some help here.


title: When should I use StringBuilder or StringBuffer?

text: In a production web application, my fellow programmers used StringBuffer everywhere. Now I am taking care of application development and corrections. After reading StringBuilder and StringBuffer I have decided to replace all the StringBuffer code with StringBuilder because we don't need thread safety in our data beans. For example: (In each data bean I can see the use of StringBuffer)               @Override     public String toString() {         StringBuffer sb = new StringBuffer();// replace it from StringBuilder         sb.append(" ABCD : ").append(abcd);         sb.append(", EFGH : ").append(efgh);         sb.append(", IJKL : ").append(ijkl);     }      We create a separate data beans for each session/request. A session is used by a single user no other user can access it. Should I consider other points before migrating? If there is a single thread (no waiting threads/no new thread will be looking for object lock), it performs equally with either StringBuffer or StringBuilder. I know in the case of StringBuffer, it takes time to take the object lock but I want to know if there is any performance difference between them except the hold/release of the object lock.


title: What is the name of the method to find index from array, in Objective-c?

text: I have a following method to find index of a book object which have a book name:               +(NSInteger)indexXXX:(NSString *)bookName XXX:(NSArray *)books     {       for (NSInteger i = 0; i < books.count; i++) {         NSDictionary *book = [books objectAtIndex:i];         if ([[book objectForKey:@"bookName"] isEqualToString:bookName]) {           return i;         }       }       return -1;     }      But I don't know what name should I use for this method.   Could you tell me some method names commonly used for this kind of method.


title: application logic, business logic, models, controllers - where to put the application's brains?

text: I'm trying to wrap my head around models, views, and controllers, but I feel as though the more I read, the more conflicting information I seem to encounter. I guess the general goal is--as far as I've seen--to shoot for fat models and thin controllers, but I'm still a bit baffled by where to put what. Can I give an example from something I'm working on? This is just a personal project that I'm messing about with in PHP for fun--a mini-game of sorts. Adding timed tasks to an itinerary and collecting rewards when the task completes. So a class kind of like this exists:               class ItineraryEntry {         public $user_id;         public $task_id;         public $completion_time;     }      And another class like this:               class Task {         public $task_id;         public $description;         public $duration; //in seconds     }      So in the user interface, the user sees a task description and clicks something like "Add to Itinerary". Now if I'm understanding correctly, the controller needs to pick up that request and do something with it. But...how much? So for example, I need to figure out when the task will complete. Keeping it simple, that's merely time() + the duration of the task. So does the controller do that calculation and then give it to the model to validate, or does the model just handle all of it? And the controller is really just a glorified router of data? Then the second part is what happens when an itinerary task completes. So from the user interface, a task will show as completed if the completion time is in the past, and the user will have to click something like, "Claim Rewards". Let's just say it's...I don't know...XP (i.e., experience points)--something that gets updated on the user's account. And let's say that the amount of XP is calculated in some way based upon the difficulty of the task, time required, etc. So where would I put that calculation? Is that inside the model class for my user object, or do I have a controller that figures all of that out and then sends it to the user object? In the model for my itinerary entry model? And the reason I ask this specifically is because any kind of Claim Rewards code would have to do a couple of things at least:   1. Actually claim the reward and update the user's account   2. Clean up the expired task from the database (or marking it completed or something) So it would be interacting both with the user and the itinerary entry. A little specific guidance would be really helpful. My brain is starting to hurt from reading all of these explanations that are kind of like what I need to know, but not totally. So thanks in advance!


title: What should I call the process of converting an object to a string?

text: We are having a game of 'semantic football' in the office over this matter: I am writing a method for an object which will represent the object as a string. That string should be such that when typed (more likely, cut and pasted) into the interpreter window (I will keep the language name out of this for now), will produce an object which is, for our purposes, identical to the one upon which the method was called. There is a spirited discussion over the 'best' name for this method. The terms **pickle** , **serialize** , **deflate** , _etc_ have been proposed. However, it seems that those terms assume some process for the de-pickling (unserialization, _etc_ ) that is not necessarily the language interpreter itself. That is, they do not specifically refer to the case where strings of valid code are produced. This is closer to a **quine** , but we are re- producing the object not the code, so this is not quite right. any suggestions?


title: How best do you represent a bi-directional sync in a REST api?

text: Assuming a system where there's a Web Application with a resource, and a reference to a remote application with another similar resource, how do you represent a bi-directional sync action which synchronizes the 'local' resource with the 'remote' resource? Example: I have an API that represents a todo list. GET/POST/PUT/DELETE /todos/, etc. That API can reference remote TODO services. GET/POST/PUT/DELETE /todo_services/, etc. I can manipulate todos from the remote service through my API as a proxy via GET/POST/PUT/DELETE /todo_services/abc123/, etc. I want the ability to do a bi-directional sync between a local set of todos and the remote set of TODOS. In a rpc sort of way, one could do POST /todo_services/abc123/sync/ But, in the "verbs are bad" idea, is there a better way to represent this action?


title: Should a view and a model communicate or not?

text: According to the wikipedia page for the MVC architecture, the view is free to be notified by the model, and is also free to query the model about its current state. However, according to Paul Hegarty's course on iOS 5 at Stanford, lecture 1, page 18 all interaction must go through the controller, with Model and View that are never supposed to know each other. It is not clear to me if Hegarty's statement must be intended as a simplification for the course, but I am tempted to say that he intends the design as such. How do you explain these two opposite points of view ?


title: Is Lambda function same as Actor? How can it be explained?

text: Sometime back I read (from a book) that conceptually Lambda function is similar to Actor. However I am clear on the concept, and will appreciate any insight or explanations for this. If they are indeed similar how? If not is there any relationship between the concepts?


title: What's the best way to learn the MS Business Intelligence stack?

text: What's the best/easiest way to get into the MS BI stack on my own (preferably with a [kindle] book)? Specifically, I'd like to learn more about SSIS, SSRS, and SSAS in that order. I've tried looking at books on amazon, but I really have no idea. Some background: I just graduated with my bachelor's in computer science, and am going back for my masters in comp sci. I work right now as a C# developer, with some web and database background. I don't necessarily want to become a BI master, but I'd like to gain an intermediate-level understanding of the platform.


title: What does path finding in internet routing do and how is it different from A*?

text: **Note:** If you don't understand this question then feel free to ask clarification in the comments instead of voting down, it might be that this question needs some more work at the moment. I've been directed here from the Stack Excange chat room Root Access because my question didn't fit on Super User. * * * In many aspects path finding algorithms like A star are very similar to internet routing. For example: > A node in an A* path finding system can search for a path though edges > between other nodes. > > A router that's part of the internet can search for a route though cables > between other routers. In the case of A*, open and closed lists are kept by the system as a whole, sepratly from any individual node as well as each node being able to temporarily store a state involving several numbers. Routers on the internet seem to have remarkable properties, as I understand it: > They are very performant. > > New nodes can be added at any time that use a free address from a finite > (not tree like) address space. > > It's real routing, like A*, there's never any doubling back for example. > > Similar IP addresses don't have to be geographically nearby. > > The network reacts quickly to changes to the networks shape, for example if > a line is down. > > Routers share information and it takes time for new IP's to be registered > everywhere, but presumably every router doesn't have to store a list of all > the addresses each of it's directions leads most directly to. I'm looking for a basic, general, high level description of the algorithms workings from the point of view of an individual router. **Does anyone have one?** I presume public internet routers don't use A* as the overheads would be to large, and scale to poorly. I also presume there is a single method worldwide because it seems as if must involve a lot of transferring data to update and communicate a reasonable amount of state between neighboring routers. For example, perhaps the amount of data that needs to be stored in each router scales logarithmically with the number of routers that exist worldwide, the detail and reliability of the routing is reduced over increasing distances, there is increasing backtracking involved in parts of the network that are less geographically uniform or maybe each router really does perform an A* style search, temporarily maintaining open and closed lists when a packet arrives.


title: Is there a massive other side to software development which I've somehow missed, revolving entirely around Microsoft?

text: I'm still a beginning programmer; I've been at it for 2 years. I've learned to work with a few languages, a bit of web development technologies, a handful of libraries, frameworks, and IDEs. But over the past two years (and long before I even started, really), I keep hearing references to these...things. A million of them. Things such as C#, ADO, SOAP, ASP, ASP.NET, the .NET framework, CLR, F#, etc etc. And I've read their Wikipedia articles, in-depth, multiple times, and they all mention a million other things on that list, but I just can't seem to grasp what it all _is_. The only thing I've taken away with any certainty is that Microsoft is behind all of it. It sounds almost like a conspiracy. Are all these technologies just for developing on the Windows platform? What _is_ .NET? Do some software developers dedicate their entire career just to that side of things? Why would I want to get into it, and what advantage does...whatever it is...have over all the other technologies there are? I hope this makes sense. It's a broad question, but inside it there's a very specific question asking about something I don't know the name of. Hopefully you can grasp my confusion.


title: How to legally protect yourself from malicious and/or dumb users?

text: When building a public facing website that allows visitors to post comments, link to media and/or upload media (e.g. audio, video, images) ... what should I do to protect myself legally in the case such visitors link to or upload content that they shouldn't (e.g. adult oriented media, copyrighted images and/or media owned by someone else, etc...)? Some questions that come to mind in particular:   1. Should I allow folks to post anonymously?   2. If I make visitors agree to some kind of statement whereby they take full responsibility for what they upload, what should the copy of such a statement be? Please provide as specific as possible steps one should take if possible.


title: Qt's future in the light of Nokia-Microsoft partnership

text: In case you missed it, a lot has happened in the last two day that could potentially impact the Qt framework, for the worse. :-( It will impact the mobile sector in several and probably not currently acknowledged ways, for sure. It started yesterday with Nokia's CEO Stephen Elop internal letter depicting Nokia sitting on a burning platform and the need for a big and aggressive shift in business. A day later, at the Nokia World conference, Nokia announced the partnership with Microsoft, which at the moment resumes to Nokia adopting the Windows Phone 7 platform and development environment, dumping Symbian along the road and tagging Meego as **R &D**(a pretty dangerous keyword if you ask me), as for Maemo/N900 series I guess it's bye bye for good. I know what you're thinking but no, Qt is not going to be ported to the Window Phone platform. And I'm also scared about this. You can watch the Elop & Ballmer joint press release here. Now after reading this huge thread on the Qt-interest mailing list I can't help but wonder, what is the future of Qt at Nokia, now that they aren't focused(at all?) on Qt anymore(remember the **full** focus switch on Qt as main development framework for all Nokia products(including Symbian, yes) back in October?). I love Qt, in my opinion it is the only true cross-platform application development framework and one of the few to make C++ development a joy(to the extent possible) and good things has happened to the framework and considerable momentum while under Nokia, thus i am wondering, what are the chances that Qt might suffer a slow death at Nokia after this? Yes i know about KDE.org and the fact that Qt is easily spawnable, but I still feel uneasy. It also must be horrible for all of the efforts either by Nokia employees or third parties that have gone into Symbian and all of the Ovi Store Symbian/Qt content and business and why not, Maemo/Meego. There are also massive layoffs planned, I suspect Symbian techs and Qt? I'd love to hear your input on this? Is Qt future safe&proof? LE: The question as been gradually revised, improved and better referenced, thus you might want to throw a quick re-read to see what you might have missed.


title: Should a package manager modify your .bashrc file?

text: I am writing a package for something that requires an environment variable to be set in order to execute properly. Should the install step of a package manager modify a user's environment, or simply prompt the user to do so themselves? My intuition would be the latter, but I can see arguments for the former.


title: Provide a URL to a CouchDB document attachment without giving the username/password?

text: I posted this question on DBA, but it got closed and was never reopened even after I rewrote the whole thing to be more specific. I think its more appropriate for programmers anyway :) ## Background Information I have a CouchDB server (Server B) that is accessed by another server running PHP (Server A). My web app (Client-side Javascript) makes a request for a file to Server A. Server A sends requests to Server B with the access credentials (username:password). Server B returns JSON objects that correspond to matched files, then Server A returns that data to the client. The response includes some meta data about the file and a URL to the file on Server B. The actual file data itself is not included in the response. ## The Problem The URL to the document attachment included in the JSON response from Server B includes access credentials (username:password). Server A responds to the client-side request by returning those JSON objects. The client now has this information:               https://username:password@host:port/dbname/path/to/file.whatever      Currently all data contained within Server B resides in one database instance. If the client has access to the username:password to the CouchDB then all data could be queried with those access credentials. Like so,               https://username:password@host:port/dbname/_all_docs      ## Server-side considerations CouchDB on Cloudant ## Client-side considerations The Javascript running on the client requires a URL string to the file. The files that are being referenced are KML layers for Google Maps. A new KML layer is created using this constructor. ## What I am looking for Essentially my solution would come if I can provide a link to a CouchDB document attachment without giving the username/password.               https://host:port/path/to/file.whatever      ## What I did I had to enable cURL for PHP on Server A.               sudo apt-get install curl libcurl3 libcurl3-dev php5-curl     sudo /etc/init.d/apache2 restart      Got a bit of code from David Walsh's blog. My Javascript client code gets a list of JSON file meta data from Server A. This data includes unique DB IDs and file names (No passwords or API keys). I then pass the document ID and filename to another service on Server A which echoes the value of,               get_data('https://username:password@Server B:port/dbname/path/to/file.whatever');      I can now serve out the files to the client without revealing username or password for CouchDB on Server B.


title: Eager Loading Constraints

text: The thing is, eager loading some object with all of it's associations reduces the queries made to the database, but the query time is greatly increased.   The question is: This increased query time in the end pays off the database not being hitted so often? It seems to me that you are avoiding one problem and falling into another one.   Obs.: Would put eager-loading tag if i had reputation enough. Someone could create it and edit this observation.


title: Why is (position < size) such a prevalent pattern in conditionals?

text: In a condition statement (IF) everyone use `(position < size)`, but why? Only convention or there is a good reason for that? Example:               if (pos < array.lengh) {        // do some with array[pos];     }      why not               if (array.lengh > pos) {        // do some with array[pos];     }      ?


title: Teaching Programming Concepts Without a Specific Language

text: I'm teaming up with a guy who has no programming experience. We're using a tool to make our game (RPG Maker) that has an event-based system that allows you to do pretty much everything you want. They have a GUI and a simple text editor for events. My friend has no programming experience. None. I need him to understand basic stuff, like control flow (if/else, do/while), variables/constants, etc. What can I use to teach him this, bearing in mind that I don't care about specific language syntax? Ideally, I'm looking for a "programming" book that talks about these ideas (perhaps visually) and doesn't care much about code. Does something like this exist? My "google-fu" failed me.


title: How have languages influenced CPU design?

text: We are often told that the hardware doesn't care what language a program is written in as it only sees the compiled binary code, however this is not the whole truth. For example, consider the humble Z80; its extensions to the 8080 instruction set include instructions like CPIR which is useful for scanning C-style (NULL-terminated) strings, e.g. to perform `strlen()`. The designers must have identified that running C programs (as opposed to Pascal, where the length of a string is in the header) was something that their design was likely to be used for. Another classic example is the Lisp Machine. What other examples are there? E.g. instructions, number and type of registers, addressing modes, that make a particular processor favour the conventions of a particular language? I am particularly interested in revisions of the same family.


title: What software models are appropriate for daily builds and continuous integration?

text: On reading the joel test and about daily builds, a discussion with a few tech- lead friends of mine in various companies revealed that they never did daily builds or continuous integration because according to them:   1. Daily builds were meant for projects following Agile practices. It does not work for the waterfall model.    2. Continuous integration required automated testing which their OpenGL/OGRE/OSG type-of graphics project couldn't use, because apparently automated testing is impractical for projects where the graphics part is under (re)development.    3. One of them believes that it's not necessary to have configuration management. It's just enough to follow the philosophy of it, by defining small 2-3 day tasks, perform all activities of the development cycle for each task (code, code-review, unit test, integration), deliver to integration stream and build and generate the setup.    4. Even if they created scripts for the entire build and burn-to-cd process, creating automated tests were a problem because in any program you create, you can't always know what tests you'd have to run and scripting a test case for it takes up too much time and automated testing tools may not always support the specific kind of tests you might want to make. Is daily builds and continuous integration really practical for non-agile projects? Is it meant only for test driven development? And is it really sufficient to follow the point 3 (above) kind of philosophy? I was talking to them about the build-in-one-step kind of scripted automation that Joel talks about, but they weren't willing to buy the idea. p.s: I've been through the questions on this site about daily builds etc, but I believe this question is different. **EDIT: Point 3 should've started with "One of them believes it isn't necessary to integrate configuration mangaement with development tools"**


title: Why are cryptic short identifiers still so common in low-level programming?

text: There used to be _very_ good reasons for keeping instruction / register names short. Those reasons no longer apply, but short cryptic names are still very common in low-level programming. Why is this? Is it just because old habits are hard to break, or are there better reasons? For example:   * Atmel ATMEGA32U2 (2010?): `TIFR1` (instead of `TimerCounter1InterruptFlag`), `ICR1H` (instead of `InputCapture1High`), `DDRB` (instead of `DataDirectionPortB`), etc.   * .NET CLR instruction set (2002): `bge.s` (instead of `branch-if-greater-or-equal.short`), etc. Aren't the longer, non-cryptic names easier to work with? * * * When answering and voting, please consider the following. Many of the possible explanations suggested here apply **equally** to high-level programming, and yet the consensus, by and large, is to use non-cryptic names consisting of a word or two (commonly understood acronyms excluded). Also, if your main argument is about **physical space on a paper diagram** , please consider that this absolutely does not apply to assembly language or CIL, plus I would appreciate if you show me a diagram where terse names fit but readable ones make the diagram worse. From personal experience at a fabless semiconductor company, readable names fit just fine, and result in more readable diagrams. What is the _core thing_ that is different about low-level programming as opposed to high-level languages **that makes the terse cryptic names desirable in low-level but not high-level programming?**


title: Boundary conditions for testing

text: Ok so in a programming test I was given the following question. > Question 1 (1 mark) > > Spot the potential bug in this section of code:               void Class::Update( float dt )     {         totalTime += dt;         if( totalTime == 3.0f )         {             // Do state change             m_State++;         }     }      The multiple choice answers for this question were. > a) It has a constant floating point number where it should have a named > constant variable > > b) It may not change state with only an equality test > > c) You don't know what state you are changing to > > d) The class is named poorly I wrongly answered this with answer C. I eventually received feedback on the answers and the feedback for this question was > Correct answer is a. This is about understanding correct boundary conditions > for tests. The other answers are arguably valid points, but do not indicate > a potential bug in the code. My question here is, what does this have to do with boundary conditions? My understanding of boundary conditions is checking that a value is within a certain range, which isn't the case here. Upon looking over the question, in my opinion, B should be the correct answer when considering the accuracy issues of using floating point values.


title: Should we put the specification documents in source control system such as svn?

text: Today, One of my colleague and I have a debate about "Should we put the specification documents in source control system such as SVN?". In my opinion, It should be. Everything relate to developing project should be controled carefully with source control system. Is it a wrong concept in software development process?


title: Why don't interviewers  ask the applicant to read some code?

text: I had a dozen interviews in my life (I'm about to graduate) and I wonder why I was only once asked to read and explain some code. Roughly, 90% jobs are mostly about maintaining existing systems. IMO ability to read someone else's code is an important skill. Why don't interviewers check it?* *Among my friends I am the only one that was asked to review some code.


title: How to manage 2 DAO methods in a single transaction?

text: In an interview someone asked me : How do we manage 2 transactional/dao methods in a single transaction. Desired capabilities:   1. If anyone of them fails we need to rollback both methods.   2. Both of the methods can be called separately attached with a single transaction.   3. The management should be on DAO layer, not on service layer. I think : the question relates to spring transaction management.


title: Can I legally and ethically take an open-source project with community contributions to closed-source?

text: Let's say I start and develop some project under open-source license, and accept some community contributions. How shaky is the ground I stand on if I decide to take the project commercial and closed-source (or split license)? This question doesn't directly address the issue of a project with community contributions, which feels like different territory, at least as far as ethics are concerned. Legally, this might be iffy as well, because I'm not sure whether contributions fall under my copyright, or whether the contributor hold the copyright to the part of the project he added. Am I safe (ethically and legally) as long as I'm up front with the possibility that I may take the project commercial in the future?


title: Starting with Ruby on Rails? I see a lot of criticism everywhere. Is it okay to start with Rails now in 2012?

text: I have worked on C before and have never tried my hands on any web application creating framework. After some convincing from one of my friends I thought of giving Rails a go. Before starting to work on Rails I have just started learning Ruby a little and hence some curiosity to know what is being talked about the framework. In the last few days, I have seen a lot of criticism of Rails as a framework. Should I try my hands on Rails or should I try something else? Is python with Django the way to go? Is Nodejs the way to go? Is there some other ruby based framework which can work for me? Please suggest with an open mind. I want to be absolutely clear in my mind before I decide. [Note: The question was closed on Stackoverflow and I was suggested that the this is a better place]


title: Most appropriate OSS license for infrastructure code

text: I'm looking into potentially releasing some infrastructure code (related to automated builds and deployments) as OSS and I'm curious about how the various OSS licenses effect it. Specifically, LGPL prevents the code _itself_ (part/whole) being modified into a commercial product (which is what I'm after), but allows it to be "linked to" in the creation of commercial products (also ok). How does the "linked to" clause relate to infrastructure code, which is not deployed with the product itself? Would the application still be required to provide "appropriate legal notices" (which I'm not fussed over)? Would I be better off looking at the Eclipse Public License?


title: Is it possible to half-way synchronize javascript functions that include async calls?

text: I am wondering if there exists a way to half way synchronize javascript functions, where data is requested on the fly. I don't want to make it purely blocking (which I guess is impossible), I just want a nice way to write the overall algorithm in one piece. Let's take the following example:               function(){         command1;         var x1 = something;         async_function(x1, callback1);     }     function callback1(data){         var x2 = command2(data);         async_function2(x2, callback2);     }     function callback2(data1){         command3(data1);     }      I would like to write something like:               function(){         command1;         var x1 = something;         call(async_function, [x1], callback1);         var x2 = command2(data);         call(async_function2, [x2], callback2);         command3(data1);     }        * I tried playing around with the `caller` property of functions, but I'm not familiar enough with the execution environment.   * I also tried writing a function "call" like above, using the `apply` function to pass in a custom callback which returns the result of the async function to it's caller. What bugs me is that while programming\debugging, I have to follow the code from one function into another into another (just like the movie inception). I want one place to write the high-level algorithm without decomposing it into many functions.   For example, If I want to write A* algorithm, but the "getNeighbors" function is asynchronous.


title: What's special in July 26th and why is it used in examples for Expires header so often?

text: I've noticed that July 26th (my birthday) is used really often in various PHP examples related to preventing http caching using `Expires` header, like: http://stackoverflow.com/questions/12398714/cache-issue-with-private- networking-stream http://stackoverflow.com/questions/2833305/how-to-expire-page-in-php-when- user-logout http://expressionengine.com/archived_forums/viewthread/81945/ What's special in that date?


title: Why is mixing plural with singular and camel case with underscores in cake php naming convention better than a simpler convention?

text: I have been using cake php for over a year and generally I like it but I struggle to understand the advantages of the complex naming conventions over something simpler. Cake uses plural here and singular there (controllers vs models and reported controller names) for it's names and uses camel case and underscores too (method names and class variables vs database tables and view variables). As far as I can see picking either plural or singular and either underscores or camel case and using just one of each choice everywhere would still yield all of the advertised benefits but would be simpler to use for the programmer. What are the advantages of cake php naming convention which could not be achieved with the above system? Please demonstrate why a simpler system wouldn't work for any given assertion.


title: Caching factory design

text: I have a factory `class XFactory` that creates objects of `class X`. Instances of `X` are very large, so the main purpose of the factory is to cache them, as transparently to the client code as possible. Objects of `class X` are immutable, so the following code seems reasonable:               # module xfactory.py     import x     class XFactory:       _registry = {}            def get_x(self, arg1, arg2, use_cache = True):         if use_cache:           hash_id = hash((arg1, arg2))           if hash_id in _registry:             return _registry[hash_id]         obj = x.X(arg1, arg2)         _registry[hash_id] = obj         return obj          # module x.py     class X:       # ...      Is it a good pattern? (I know it's not the actual Factory Pattern.) Is there anything I should change? Now, I find that sometimes I want to cache `X` objects to disk. I'll use `pickle` for that purpose, and store as values in the `_registry` the filenames of the pickled objects instead of references to the objects. Of course, `_registry` itself would have to be stored persistently (perhaps in a pickle file of its own, in a text file, in a database, or simply by giving pickle files the filenames that contain `hash_id`). Except now the validity of the cached object depends not only on the parameters passed to `get_x()`, but also on the version of the code that created these objects. Strictly speaking, even a memory-cached object could become invalid if someone modifies `x.py` or any of its dependencies, and reloads it while the program is running. So far I ignored this danger since it seems unlikely for my application. But I certainly cannot ignore it when my objects are cached to persistent storage. What can I do? I suppose I could make the `hash_id` more robust by calculating hash of a tuple that contains arguments `arg1` and `arg2`, as well as the filename and last modified date for `x.py` and every module and data file that it (recursively) depends on. To help delete cache files that won't ever be useful again, I'd add to the `_registry` the unhashed representation of the modified dates for each record. But even this solution isn't 100% safe since theoretically someone might load a module dynamically, and I wouldn't know about it from statically analyzing the source code. If I go all out and assume every file in the project is a dependency, the mechanism will still break if some module grabs data from an external website, etc.). In addition, the frequency of changes in `x.py` and its dependencies is quite high, leading to heavy cache invalidation. Thus, I figured I might as well give up some safety, and only invalidate the cache only when there is an obvious mismatch. This means that `class X` would have a class-level cache validation identifier that should be changed whenever the developer believes a change happened that should invalidate the cache. (With multiple developers, a separate invalidation identifier is required for each.) This identifier is hashed along with `arg1` and `arg2` and becomes part of the hash keys stored in `_registry`. Since developers may forget to update the validation identifier or not realize that they invalidated existing cache, it would seem better to add another validation mechanism: `class X` can have a method that returns all the known "traits" of `X`. For instance, if `X` is a table, I might add the names of all the columns. The hash calculation will include the traits as well. I can write this code, but I am afraid that I'm missing something important; and I'm also wondering if perhaps there's a framework or package that can do all of this stuff already. Ideally, I'd like to combine in-memory and disk- based caching. EDIT: It may seem that my needs can be served well by a pool pattern. On further investigation, however, it’s not the case. I thought I'd list the differences:   1. Can an object be used by multiple clients?     * Pool: No, each object needs to be checked out and then checked in when no longer needed. The precise mechanism may be complicated.     * XFactory: Yes. Objects are immutable, and can be used by infinitely many clients at once. There’s never a need to create a second copy of the same object.   2. Does pool size need to be controlled?     * Pool: Often, yes. If so, the strategy to do so may be quite complicated.     * XFactory: No. An object must be delivered on demand to the client, and if an existing object is unsuitable, a new one needs to be created.   3. Are all objects freely substitutable?     * Pool: Yes, the objects are typically freely substitutable (or if not, it’s trivial to check which object the client needs).     * XFactory: Absolutely not, and it’s very hard to find out if a given object can service a given client request. It depends on whether an existing object is available that was created with (a) the same arguments and (b) the same version of the source code. Part (b) cannot be verified by XFactory, so it asks the client to help. The client fulfills this responsibility in two ways. First, the client may increment any of its several designated internal version counters (one per developer). This cannot happen in runtime, only a developer may change these counters when he believes that the source code change makes existing objects unusable. Second, a client will return some invariants about the objects that it needs, and XFactory will verify that these invariants are not violated before serving the object to the client. If any of these checks fail, XFactory will create and deliver a new object.    4. Does performance impact need careful analysis?     * Pool: Yes, in some cases a pool actually hurts performance if the overhead of object management is greater than the overhead of object creation/destruction.     * XFactory: No. The computation costs of the objects in question is known to be very high, and loading them from memory or from disk is without doubt superior than recalculating them from scratch.   5. When are objects destroyed?     * Pool: When the pool is shut down. Perhaps it might also destroy objects if told to (partially) release resources or if certain objects have not been used for a while.     * XFactory: Whenever an object was created with the version of the source code that is no longer current, as evidenced by either invariant violation or counter mismatch. The process of locating and destroying such objects at the right time is quite complicated. In addition, time-based invalidation of all objects may be implemented to reduce the accumulated risks of using invalid objects. Since XFactory is never certain that it is the sole owner of an object, such invalidation is best achieved by an additional “version counter” in the client objects, which is incremented programmatically on a periodic basis, rather than by a developer.   6. What special considerations exist for multithreaded environment?     * Pool: Has to avoid collisions in object checking out / checking in (don’t want to check out an object to two clients)     * XFactory: Has to avoid collision in object creation (don’t want to create two objects based on two identical requests)   7. What needs to be done if client does not release an object?     * Pool: It may want to make the object available to others after waiting for some time.     * XFactory: Not applicable. Clients do not notify XFactory about when they are done with the object.   8. Do objects need to be modified?     * Pool: May have to be reset to the default state before being reused.     * XFactory: No, the objects are immutable.   9. Are there any special considerations related to persistence of objects?     * Pool: Typically not. A pool is about saving the cost of object creation, so all the objects are kept in memory (reading from disk would defeat the purpose).     * XFactory: Yes, XFactory is about saving the cost of performing complex calculations, so storing pre-calculated objects on disk makes sense. As a result XFactory needs to deal with the typical problems of persistent storage; e.g. at initialization, it needs to connect to persistent storage, obtain from it the metadata about which objects are currently available there, and be ready to load them into memory if requested. And object may be in one of three states: “doesn’t exist”, “exists on disk”, “exists in memory”. While XFactory is running, the state may change only in one direction (to the right in this sequence). In summary, the pool's complexity is in items 1, 2, 4, 6, and possibly 5, 7, 8. The XFactory complexity is in items 3, 6, 9. The only overlap is item 6, and it’s really not the core function of either pool or XFactory, but rather a constraint on the design that is common to any pattern that needs to work in a multithreaded environment.


title: Why is studying an lisp interpreter in lisp so important?

text: I have seen many CS curriculums and learning suggestions for new programmers that call for the aspiring programmer to study a lisp interpreter that is specifically written in lisp. All these sites say things similar to, "its an intellectual revelation", "it is an enlightenment experience every serious programmer should have," or "it shows you hardware/software relationships," and other vague statements, particularly from this article taken from this reputable how-to. The general sentiment of my question is, how does lisp achieve the above goals and why lisp? Why not some other language? I am asking this because I just finished writing a scheme interpreter in scheme (taken from SICP http://mitpress.mit.edu/sicp/ ) and now I am writing a python interpreter in scheme and I am struggling to have this legendary epiphany that is supposed to come specifically from the former. I am looking for specific technical details between the two languages that I can exploit in their scheme interpreters to gain understanding about how programs work. More specifically: > Why is the study of an interpreter that is written in the language it > interprets so emphasized - is it merely a great mental exercise to keep the > original language and built language straight or are there specific problems > whose solutions can only be found in the nature of the original language? > > How do lisp interpreters demonstrate good architecture concepts for one's > future software design? > > What would I miss if I did this exercise in a different language like C++ or > Java? > > What is the _most used_ takeaway or "mental tool" from this exercise? ** ** I selected the answer I did because I _have_ noticed that I have gained from this exercise more skill in designing parsing tools in my head than any other single tool and I would like to find different methods of parsing that may work better for the scheme interpreter than the python interpreter.


title: Persist AJAX values

text: I have a simulator that pulls data from a DB - calculates and return JSON result to an ajax call that renders a table for the results. The calculation procedure are as follow:   1. grab X number of data that are group together and have weights to them.   2. use historical data and run a weight distribution algorithm on the group.   3. return as a JSON the metrics of each data, the old value, and the calculated new value 2 Questions: 1) Is Javascript calculation better or worse (or equal) to PHP calculation in order to yield the results. 2) IF Javascript calculation is faster or on par to PHP then I would assume the trip to call ajax is a small bottleneck. So one possibility would be to pre-load data and have it calculated on the fly. Now how would you persist that pre-loading efficiently? Would that just simply load everything in a simple var via ajax? Thus far it takes approx 55 seconds for the result to return 2000 entries on 14 days worth of data.


title: Unit test: How best to provide an XML input?

text: I need to write a unit test which validates the serialization of two attributes of an XML(size ~ 30 KB) file. What is the best way to provide an input for this test? Here are the options I have considered:   1. Add the file to the project and use a file reader   2. Pass the contents of the XML as a string   3. Create the XML through a program and pass it Which is my best option and why? If there is another way which you think is better, I would love to hear it.


title: Behavior-Driven Development / Use case diagram

text: Regarding growing of Behavior-Driven Development imposing acceptance testing, are use cases diagram useful or do they lead to an "over-documentation"? Indeed, acceptance tests representing specifications by example, as use cases promote despite of a more generic manner (since cases, not scenarios), aren't they too similar to treat them both at the time of a newly created project? From this link, one opinion is: > Another realization I had is that if you do UseCases and automated > AcceptanceTests you are essentially doubling your work. There is duplication > between the UseCases and the AcceptanceTests. I think there is a good case > to be made that UserStories + AcceptanceTests are more efficient way to work > when compared to UseCases + AcceptanceTests. What to think about?


title: Drawing a custom rendered control in Windows - resizing

text: Some background: in order to learn GUI programming and drawing in Windows I'm starting to create my own GUI toolkit in Windows (so this is a didactic exercise, please don't suggest "use Qt" or "use MFC"). I would like to draw the entire window area from memory DCs in double buffering (thus also handling mouse and keyboard events myself) but I'm now wondering how should I handle resize events from the window: suppose I have a text control and a sidebar and my window gets a resize command ![enter image description here](http://i.stack.imgur.com/YTwfs.png) the sidebar should grow larger and the text control should show more text (it is also larger). The first thing that comes to my mind is to redraw all the widgets on the memory DC and then BitBlt it to the screen. Anyway some widgets might not have changed at all or might be changed just a bit (the portion _"Text here, text here, te"_ hasn't changed at all during the resize). What can be done to exploit this fact and avoid redrawing (even in memory DC, not device DC) the parts which haven't changed?


title: c++ GUI application in linux without toolkit

text: We all know , there are number of toolkits available for GUI application in c++ for Linux. But for some reasons I want to create a GUI application without any toolkit.I know this question is ask earlier but there is no proper answer provided. So please tell the ways through which I can create GUI application on Ubuntu 12.04. Please do not suggest me toolkit, That's not an option for me.


title: Rewriting C# Formula Calculations in T-SQL

text: We have a 3-tier application with a C# client that connects to a C# web service via WCF and requests data from a SQL Server database. One feature in our application is a user-created form app in which our customers setup forms that have fields. The fields refer to values that can be imported, entered by the user, or calculated. The calculations can be thought of as Operation / Value / Timeframe. Each value referenced in a calculation might also be a calculated value. (Care is taken to ensure circular calculations do not exist.) For example, a user might setup a field that shows Cash Over / Short that subtracts the value Total to Account For and Total Accounted For. These fields might in turn add up sales, credit card payments, cash totals, etc. Changing Grocery Sales in the form UI would trigger a change that recalculates the Total to Account For, and that field's change triggers the Cash Over / Short field to recalculate itself. Complicating the calculations are historical values. Some calculations might be phrased in English like "Subtract Today's Totalizer Value from Yesterday's Totalizer Value". Or, someone might simply set a Last Year Sales field to the value of Total Sales exactly 365 days ago. All this calculation is done in the C# user interface. The C# code builds dependency trees and sets up event handlers when values change. Changing a value triggers an event, and calculations that depend on the changed value are recalculated. We also have a recalculation engine that verifies the totals are correct before making permanent changes (i.e. before drafting someone's account, so the amounts better be correct). This recalculation engine uses the same C# calculation engine across multiple threads. This incurs penalties of reading from the database, creating the C# objects, performing calculations, and writing to the database. The timeframe dependencies mean we really need to calculate in some kind of day order. I could use some kind of cursor to move day-by-day, gather up all the data on each day, figure out the dependencies, join to historical values, but... **My question: how would you approach performing complex user-defined calculations in a set-based manner in SQL?** I don't see how to do this without RBAR operations on each calculated value.


title: Multithreaded Pre/Post Functions

text: I'm programming an application for an embedded device. We are using an RTOS that supports multi threading. The device is supposed to mimic an older project that was programmed in plain C (without threads). The original project uses a stack and START / END functions at the beginning and end of each function that can be called throughout runtime. Each time START is called a constant number (identifying the function) will be put on the stack - END will remove it from the stack and check if the top is equal to the called function. If it is different something really bad has happened and the device will recover/reset. This feature is great for debugging purposes as it fully displays how functions are called. It would be very lovely to have such a feature in the multi-threaded version. I implemented START and END as a class in C++ using constructor and destructor which makes the handling fairly easy. Running this single-threaded works like a charm. Anything multithreaded will destroy the stack as the scheduler switches context and writing to one stack would not make sense. The most basic solution in my mind would be having one START/END stack for each thread -> Problem each function has to know which threads it runs on. Is there a better solution to this problem?


title: How to make script with faster queries?

text: # I have project to share useful urls with some information about the url. ## the project using:   1. add new post ( opening bootstrap with textarea )    2. user add content (url , hashtags, text)    3. the js fetch urls   4. the js fetch hashtags   5. the js send 1st url to php curl   6. php return title, description, images, site-name by tags title and meta-tag and    7. user select Image and share the post I did all that above, but there is some errors and new steps wanna ask about ## Errors ### On fetching url content   * some sites didn't have good data to fetch it ( title, description, images )   * PHP Curl fetching take long time ## The help:   * how can get the right data from any url   * how can make the Curl faster   * is there are any php class make this faster and secure  # new steps I wanna make ### 1 - I wanna display posts like as Twitter time line   * ( unread new posts button with #no of posts ) real time on click append new posts   * ( load older posts on scroll down )   * ( make it fast ) # Suggests load queries result to json file and update it by time will be faster ? if users posting the same url get it from db with out fetching ? will need to save the fetching on db ? i've insert all post as a json array on db table just the site name not url on other column? is that's good ![enter image description here](http://i.stack.imgur.com/nxlA3.png)


title: Do I need to use Node.js, Java or both for a multi-platform application?

text: I'm new on Java and I have experience building Node.js apps, so I'm thinking to create a program that it's kind of "multi-platform" where there's going to be a tablet kindle that's going to run the Java app, a PC that will show queues made from this java app in many tablets and another PC that's going to manage the data on the application (those could be web application from Node.js). So, Node.js could be the server managing queries and database while Java could be on Kindle Fire app making requests to the server, I really don't know Java too much but by the time I don't know if this project structure is fine, maybe it could work better using both sides on Java or Node.js web-app. Let's say this project is for a restaurant, waiters are going to have kindle fire (java app) instead of books, on a side there's going to be a big screen showing queues (this could be shown from Node.js) made from waiters on kindles, and the entrance there's going to be a PC that's going to manage the money and other stuff (maybe Node.js as well).


title: Passing the HR Screening Process

text: Just a quick question here. I already have a Bachelor's degree in Statistics, and I am thinking of getting the Graduate Certificate in Software Engineering offered by Harvard Extension. Assuming that I hold both BS in Statistics and Graduate Certificate in Software Engineering, Would it be possible me to pass the HR screening process if I apply for a programming job later on? (I am asking this because many programming analyst jobs seem to require a degree or diploma in Computer Science or Computer Engineering) Thanks,


title: User roles in GWT applications

text: I'm wondering if you could suggest me any way to implement "user roles" in GWT applications. I would like to implement a GWT application where users log in and are assigned "roles". Based on their role, they would be able to see and use different application areas. Here are two possible solution I thought: 1) A possible solution could be to make an RPC call to the server during onModuleLoad. This RPC call would generate the necessary Widgets and/or place them on a panel and then return this panel to the client end. 2) Another possible solution could be to make an RPC call on login retrieving from server users roles and inspecting them to see what the user can do.   * I'm also considering java security frameworks like Apache Shiro and Spring Security... What do you think about them? What do you think about? Thank you very much in advance for your help!