title: Was API hooking done as needed for Stuxnet to work? I don't think so

text: Caveat: I am a political science student and I have tried my level best to understand the technicalities; if I still sound naive please overlook that. In the Symantec report on Stuxnet, the authors say that once the worm infects the 32-bit Windows computer which has a WINCC setup on it, Stuxnet does many things and that it specifically hooks the function `CreateFileA()`. This function is the route which the worm uses to actually infect the .s7p project files that are used to program the PLCs. ie when the PLC programmer opens a file with .s7p the control transfers to the hooked function `CreateFileA_hook()` instead of `CreateFileA()`. Once Stuxnet gains the control it covertly inserts code blocks into the PLC without the programmers knowledge and hides it from his view. However, it should be noted that there is also one more function called `CreateFileW()` which does the same task as `CreateFileA()` but both work on different character sets. `CreateFileA` works with ASCII character set and `CreateFileW` works with wide characters or Unicode character set. Farsi (the language of the Iranians) is a language that needs unicode character set and not ASCII Characters. _I'm assuming that the developers of any famous commercial software (for ex. WinCC) that will be sold in many countries will take 'Localization' and/or 'Internationalization' into consideration while it is being developed in order to make the product fail-safe_ ie. the software developers would use `UNICODE` while compiling their code and not just 'ASCII'. Thus, I think that `CreateFileW()` would have been invoked on a WINCC system in Iran instead of `CreateFileA()`. Do you agree? My question is: If Stuxnet has hooked only the function `CreateFileA()` then based on the above assumption there is a significant chance that it did not work at all? I think my doubt will get clarified if: my assumption is proved wrong, or the Symantec report is proved incorrect. Please help me clarify this doubt. Edit: For more clarity of my question and what I'm looking for. Is it possible that the WinCC STL Editor be programmed in the following way?               //Pseudocode Begins     if (locale == ASCII Dependent) //like US, UK, Australia etc.     {          CreateFileA(); //with appropriate parameters     }     else if (locale == UNICODE Dependent) //like Middle East, China, Japan etc     {          CreateFileW(); //with appropriate parameters     } //Pseudocode ends      If it is possible then does it follows that Stuxnet would work appropriately in the US but not in China or Japan or Iran?


title: How do programs like JAVA and C++ store variables in a database , does it still use MySQL like in PHP?

text: I imagine they have to have some sort of query to goes to a database , or maybe I'm wrong and they can just store it to their computer? Is MySQL for server - side scripting only?


title: When do you 'speak' C++ fluently?

text: I see that many companies require the same skill. This skill is often described as following: > _"Applicants are required to speak C++ fluently."_ I never really understand what _fluent_ meant for programming. So, my question is: When do you speak a programming language fluently?


title: What has been learned about making variance part of the type?

text: In Java, the variance of parameterized types is indicated depending on how it's used:               <A extends B,B> void store(ArrayList<B> list, A elem) {         list.add(elem);     }      Whereas in Scala it is indicated in the class declaration with a `+` or `-`. What I want to know is, now that Scala has been around awhile, what has been people's experience with making variance a property of the type? Is it generally flexible enough for what you want to do? Are there aspects you would have done differently, knowing what you know now?


title: When developing a piece of software, when do you start thinking/designing the concurrent sections?

text: Following along with the principle of not optimizing too early, I'm wondering at what point in the design / development of a piece of software do you start thinking about the concurrency opportunities? I can well imagine that one strategy would be to write a single threaded application, and through profiling identify sections that are candidates to run in parallel. Another strategy I've seen a little of is to consider the software by groups of tasks and to make the independent tasks parallel. Part of the reason for asking is that of course, if you wait until the end and only refactor the software to operate concurrently, you may structure things in the worst possible way and have a major task on your hand. What experiences have helped to determine when you consider parallelization in your design?


title: What are some common algorithm optimization opportunities - mathematical or otherwise

text: What are some common algorithmic optimization opportunities that everyone should be aware of? I have recently be revising/reviewing some code from an application, and noticed that it appeared to be running considerably slower than it could. The following loop turned out to be the culprit,               ...         float s1 = 0.0;         for (int j = 0; j < size; ++j) {             float diff = a[j] - b[j];              s1 += (diff*diff * c[j]) + log(1.0/c[j]);         }     ... This is equivalent to, ∑j { (aj-bj)2*cj \+ log(1/cj) } Each time the program is run, this loop is called perhaps over 100k times, thus the repeated calls to log and divide result in a very large performance hit. A quick look at the sigma representation makes it pretty clear that there is a trivial fix - assuming you remember your logarithm identities well enough to spot it, ∑j { (aj-bj)2*cj \+ log(1/cj) } = ∑j { (aj-bj)2*cj } + ∑j { log(1.0/cj) } = ∑j { (aj-bj)2*cj } + log(1.0/(Πjcj)) and leads to a much more efficient snippet,               ...         float s1 = 0.0;         float s2 = 1.0;         for (int j = 0; j < size; ++j) {             float diff = a[j] - b[j];              s2 *= c[j];             s1 += (diff*diff * c[j]);         }         s1 += log(1.0/s2);     ... this lead to a very large speed-up, and should have made its way into the original implementation. I assume it did not because the original developer(s) either weren't aware, or weren't 'actively aware' of this simple improvement. This made me wonder, what other, similar, common opportunities and _I_ missing out on or overlooking, and how can I learn to better spot them? I'm not so much interested in complex edge cases for particular algorithms, but rather examples like the one above that involve what you might think of as 'obvious' concepts that crop up frequently, but that others may not.


title: Function like C# properties?

text: I've been thinking about how C# properties work and could work. I know the purpose that C# properties were originally designed for, which is certainly useful. However instead in this question I'm comparing them more abstractly to functions and other programic elements. Firstly, I wondered, if it were possible, and if so why not, to have a function like C# property. For example:               byte n = 4;          byte test // property     {         get         {             return n;         }         set         {             n = value;         }         func         {             n++;         }     }      To use as follows:               // n is 4     byte n2 = test; // get     test = 2; // set     // n is now 2     test; // function     // n is now 3      The 'n++' in this example being used only as a simple demonstration. I also noticed that there is room for more polymorphism than just in function parameter types. For example having overload resolution by return type, get/set and private/public as well.               public test     {         get         {         }         get byte         {         }         private get byte         {         }         get bool         {         }         get myType         {         }         set byte         {         }         set myType         {         }         func         {         }         func(bool)         {         }         func(byte, myType)         {         }         // etc...     }      The above example defines "test" along with reasonably fine detail involving different implementations for using test in various different ways. More examples: Read only:               byte test     {         get         {         }     }      Function like:               test     {         func         {         }     }      Function like with parameter polymorphism, returns a byte:               byte test     {         func(bool)         {         }         func(myType, Int16)         {         }     }      Behaves differntly depending on the type assigned to it:               test     {         set bool         {         }         set myType         {         }     }      Function like and could return a value or not, depending on the context it is used:               test     {         byte get         {         }         func(bool)         {         }         func(byte, byte, myType)         {         }     }      The additional possibility for expression and code tidiness should be apparent. However I have been challenged to find specific uses. One example of how this could be used is equality. Where a bool is expected, for example in an 'if' statement, the behaviour could be defined as being '==', however where there was either nothing to return to, or the return to was other than bool, the behaviour would instead be '='.               if (n.equals(4)) // if n == 4         n.equals(2); // n = 2      Another example is as follows:               class my_list<T>     {         List<T> store;         public count         {             get             {                 // unless otherwise apparent,                 // use the Int32 version.                 return (Int32)count;             }                  get byte             {                 byte n = 0;                 ForEach(var e in store)                     n++;                 return n;             }                  get Int32             {                 Int32 n = 0;                 ForEach(var e in store)                     n++;                 return n;             }                  private get             {                 // An implmentation of "count get" that only                 // occurs when count is used from inside the                 // my_list class.             }                  func             {                 print store.Count();             }                  set int             {                 if (value == 0)                     list.Clear();             }         }     }


title: At what point should developers become involved in a triangular relationship among the client, the design agency, and the developers themselves?

text: Imagine that there is a project to be completed. This project involves three parties: client, a development organisation (a one that you work for), and a design agency. The design agency is a subcontractor of the client. The role of the design agency are largely responsible for doing styling; however in the past these designers have produced substandard work such as extensive use of id targetting in css instead of class targetting, etc. At what point should developers become involved in a triangular relationship among client, design agency, and themselves? What meetings or communication would you expect to take place at this point?


title: Is there any legislation requiring how we store passwords?

text: Given the Sony data breach and other events recently, is there any actual laws or regulation regarding how to store passwords? I think there are with credit cards, you're not allowed to store the 3 digit key or something. Is it illegal to actually store plaintext passwords without warning the user? Or it there a level of encryption that has to be used? Are there any standard guidelines that anyone can point me to?


title: Number of semi-random combinations / permutations given a set of constraints

text: ### Background: There are around 60 students at the boarding school I work for. The counselor asked my colleague and me to come up with a better way to come up with seating arrangements for dinner than by hand. He would like assignments for the rest of the school year. He also asked us to try to solve some of the issues he has hearing about from students and faculty. ### Constraints:   * Most of the students are not from the US, so when they are surrounded by people of the same nationality (i.e., at the dinner table), they speak the language they are fluent in, instead of practicing English,   * Complaints are made when students have sat at a certain table "too many" times overall,   * or if they sit at the same table more than twice in a row,   * and some of the students do not get along, so they cannot sit together. ### Input: At run time, the program is supplied with:   * A set of people,   * A set of tables, and   * Each table has a different number of seats (repetition is allowed) The size of both sets, and the size of each table does not change between each assignment. ### Tests: I am using 18 people of different nationalities, and 4 tables of size 3 through 6, inclusive. I picked numbers that I thought made sense for that data set:   * No more than 3 people of the same nationality can sit together at a time   * No person can sit at a table more than 4 times ### Results: I have run the generator around 15 times without changing the input data. Each time, it comes with anywhere from 6 to 12 "weeks" of assignments. ### Questions: (least to most important)   1. Why do I get a different number of generated assignments every time I run the program? The data set isn't changing between runs.   2. How do I find the...      * minimum number of people of the same nationality that can sit at a given table,     * minimum number of overall times they sit at a given table, all while     * maximizing the number of generated assignments?   3. How do I guarantee that these actually are the correct numbers? ### Edit: Each time I generate a new assignment, I call `Collections.shuffle(List)` on the list of people to randomize their order. I then pass the list of tables and people to a backtracking method based off of kapilid's eight queens implementation on github to assign people to tables.


title: How do open-source projects grow?

text: I know of lots of software that is open-source. For at least some of it, someone, somewhere must have written the first version alone. How does good open-source software become well known? I'm most interested in the first steps. How does software written by one person gain its first new contributors? I'm looking for practical advise. I've started a project here, called aodbm. What steps can I take to give it the best possible start?


title: Component Diagram, what's next?

text: I'm working on an iPhone application and I created a component diagram. I defined interfaces for each component. For example I have an AI component and I have made some interfaces for it. How should I carry on? Should I create a class diagram to go into details, should I go into details of each interface or should I just start implementing my interfaces? I am a bit confused on how to proceed.


title: How do I create a .NET WebService for File Upload

text: I need to create a web service using the .NET platform for accepting file uploads. What are the options available for doing this in C#? What is the best approach to use? Can please you provide me with blogs/code samples/references for further reading?


title: Do you do any validation on directories when recursively deleting them?

text: How do you recursively delete paths of the data that your app created? The deleting process itself is trivial. The question is, do you do extra validation? And if so, what kind? From one point of view, maybe it's simply an uncomfortable task to do, but on the other, imagine if the program has a bug and something passes "c:\" to the recursive function, or if there is a memory overflow and some data becomes corrupt, causing paths you work on to be truncated etc. Is there even a way to do a clean validation?


title: In pseudo code what does := mean?

text: The section entitled Algorithmic Implementation has the following code:               // Return RC low-pass filter output samples, given input samples,      // time interval dt, and time constant RC      function lowpass(real[0..n] x, real dt, real RC)        var real[0..n] y        var real α := dt / (RC + dt)        y[0] := x[0]        for i from 1 to n            y[i] := α * x[i] + (1-α) * y[i-1]        return y      what does := mean?


title: Why are references rarely used in PHP?

text: I have some C++ knowledge and know that pointers are commonly used there, but I've started to look at PHP open source code and I never see code using references in methods. Instead, the code always uses a return value instead of passing the reference to the variable to the method, which then changes that variable's value and just returns it. I have read that using references uses less memory, so why aren't they used in PHP?


title: Object oriented versus function oriented for backend design in PHP?

text: I am curious as I am currently using functions exclusively in my webpages. The MVC pattern is very interesting, and I know Code Igniter utilizes classes which works very well. I want to be able to keep my code as clean as possible, and I thought about trying to move my functions into classes. Currently I am separating the files by logic, so I have functions that output the html with arguments that pass any dynamic content, and the functions which handle the user input. I also have functions that interact with the database. I require and include the necessary files between them. As one can tell, there are a lot of arguments being passed around. So that leads me to wanting to try a style of OOP in PHP that I can do the same without having any html inside of the actual class. I really don't want to hear anything about frameworks as the point is to learn and incorporate these ideas into my own website. That being said, I am fairly new at web development, so I do not understand the many different styles in setting up the logic of websites. I would like to get some insight on how to best clean up my code in OOP? EDIT: It is fairly obvious people have strong feelings about frameworks. So I decided to make this very clear; MY WEBSITE IS A PROJECT FOR LEARNING. I WISH ONLY TO LEARN FROM IT. THEREFORE I do not wish to use a framework as it makes more sense for me to learn how it all works before making my life easier and actually use a framework. A FRAMEWORK FOR MORE ROBUSTS PROJECTS. Thank you.


title: Reducing Valgrind Findings (uninitialised value)?

text: I'm trying to run some code though Valgrind. The code depends on OpenSSL, and OpenSSL is making Valgrind useless due to uninitialised values. I know where the use lies in OpenSSL's PRNG, but I'm getting hundreds more at the moment. I'd like to try an run a tool over the OpenSSL sources that initializes values. So:               int* p;     int n;      is changed to:               int* p = NULL;     int n = 0;      **Question** : Is anyone aware of a tool to perform bulk initialization on declarations of primitives? I'm more than happy to perform an un-needed initialization and have the optimizer remove it later. That's the optimizers job. For completeness, "speed" has never been a top concern for me. I'm more interested in "correctness" and assuring it. To me, it does not matter how fast someone arrives at the answer if its wrong.


title: How can resolve an URL on a specific DNS server

text: I'm currently facing a issue on a project. I'm resolving URL's on multiple DNS servers using a node.js server. Until here, everything is fine. But some ISP restrict the incoming requests from IPs outside their IP range. So how could I modify my request to those specific DNS servers to make it look like I'm one of their clients? If I understand DNS request correctly, there are no such things as x-forwarded-for header as an HTTP request would have. So can it be achieve ? Or am I facing a real blocker ? (I hope I am on the correct stackexchange for this question)


title: Am I potentially hurting my career by taking a dev test position?

text: Background: If you haven't read much of what I've written here, then:   * I'm a sole developer   * I've developed professionally for ~3 years, personally for 13   * I love my work   * Top-to-bottom, I find the whole process of developing software interesting, fun and exciting (with the slight exception of marketing)    * I hate the environment I'm in now and had to leave Now: I've applied for a position as a Software Development Engineer in Test which potentially pays significantly more than I'm making now (~70%), is located somewhere I'd really like to be and looks like a company I'd really like to work for (interesting product, good tools, smart people - I was referred by an existing employee). So obviously, I'm really hoping that I get the position. I don't want to get pigeonholed as a test developer, however, because they can sometimes have a bad reputation as not being good 'production' developers (not sure why... and this could be wrong, but that's the vibe I've gotten). I'd prefer my career path to end up at a senior dev/lead dev position in 5-10 years. If I'm offered** the position, is there a possibility of hurting this desired path? ** I'm getting ahead of myself. I know. I haven't even had the interview yet. I'm anxious. Still, I interview well and I think that I have the knowledge/experience for the position.


title: What would the role of a "Software Engineer in Test" be?

text: > **Possible Duplicate:**   >  Microsoft SDET position   >  How difficult is it to transition from a software test engineer to a > software development engineer? I interviewed for a Software Engineering role, but unfortuantely wasnt offered the position. The company said there were impressed with me and Inwas close behind the other cadidate and that they wanted me to go in and talk to about another role, Software Engineer in Test. So my question is as per the title really, What is the role of a Software Engineer in Test? What do you envisage the type of work would be involved in a role like this? Would taking a role like this limit me to moving into regular software engineering?


title: Does any software come with a warranty?

text: > THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, [blah blah > blah]. It's everywhere. **Is there any software which expressly comes with warranties** which can be taken seriously? That is:   * Provided by a group/company which has the **resources** to handle warranty claims, not uncle Bob.   * Assures something " **useful** ," such as ACID or ISO-whatever compliance, not protection from meteor impacts.


title: How to improve the training of students regarding maintainability?

text: Maintainability is a major stake of professional software development. Indeed, maintenance is nearly always the longest part of a software life cycle, as it lasts from the project release until basically the end of times. Moreover, projects being in maintenance represent a large majority of the overall number of projects. According to http://www.vlegaci.com/298/interesting-statistics-%E2%80%93-numbers-of- programmers-in-maintenance-vs-development/, the proportion of projects being in maintenance is about 2/3. I recently came across this question, where the guy looks pretty surprised discovering that his job is mainly about maintenance. I then decided to open a discussion (french) on the main site of the French community of software development professionals (http://www.developpez.com/). The discussion is entitled "Are students well-enough trained to the reality of professional software development?" and is mainly about **maintainability**. It was pointed out that, at least in France, people are not well-enough prepared to face maintenance in both aspects of it:   * maintain existing code   * make maintainable code My question here echoes to this discussion and aims at finding a good way to teach maintainability.   * How can we teach maintainability?   * What kind of exercise would you suggest?   * If you have been well-trained regarding maintainability, what particular kind of courses did you take? [edit] After some misunderstanding, I think I must clarify my question. As a project leader and software developer, I often work with trainees or freshly graduated students. I once was freshly graduated myself. The thing is that students are usually unfamiliar with principles such as SOLID that increase the maintainability of a project. We often end up having important difficulties making projects evolve (low maintainability). What I am looking for here is a concrete academical example of successful teaching about the importance of maintainability and how to make better code regarding this particular point; or possible suggestions to improve the way students are trained.


title: OOP technology death

text: I've heard many times about the aspect-oriented programming, mostly that it is the "next generation" technology in programming and is going to 'kill' OOP. Is it right? Is OOP going to die or what can be reason for that?


title: Is code duplication a necessary evil in C?

text: I'm rather new to C, and I'm wondering if code duplication is a necessary evil when it comes to writing common data structures and C in general? I could try to write a generic implementation for a `hash map` for example, but I'm always finding the end result to be messy. I could also write a specialized implementation just for this specific use case, keep the code clear and easy to read and debug. The latter would of course lead to some code duplication. Are generic implementations a norm, or do you write different implementations for each use case?


title: How to Release to the App Store as an Individual

text: I've written an iOS app, and I'd like to release it on to the App Store. I'm an individual so it's not being released via a company or anything, just me. Is it typical to just release a free app under your own name? If so, what would be appropriate copyright information to submit?


title: How can I obtain feedback from external developers?

text: One of our external devs is leaving after successfully completing a **short (1 month) project** which he was contracted for. I'd like to get some feedback from him by doing an exit interview to find out what could be better in our organization and development process. What sort of questions can I ask to get detailed feedback from him, and not just vague responses?


title: I want to master ASP.NET - What concepts should I focus on/What concepts do you most value?

text: I start a job this summer doing work in ASP.NET 4 (C#). I plan on working with some legacy code as well as MVC. I want to get a running start. I have good understanding of HTML/CSS/Javascript, and pretty good understanding of C# itself, Design principles, Design Patterns, and understand masterpages, basic MVC2, and code behinds for web forms.   * In your opinion what aspects of ASP.NET are the most important to master for web applications?    * What do you value most in your usage of ASP.NET?    * Do you have a recommendation for understanding the internals of ASP.NET itself?


title: Converting from web to PhoneGap

text: I was going through the `PhonGap Documentation` about how to package your `HTML/JS/CSS` to a platform specific `"native app"`. They have maintained separate documentations for the separate `Cordova` versions which seems fine. I essentially understand most of the things there. But the confusion I have is the disparity or the loss of information in the documentation from the older ones to the newer ones. For an instance, if you take a look at this documentation for the version `2.1.0` about setting up the android project and scroll a bit down, they have mentioned such things:   * In the root directory of your project, create two new directories:       * /libs     * assets/www   * Copy cordova-2.0.0.js from your Cordova download earlier to assets/www   * Copy cordova-2.0.0.jar from your Cordova download earlier to /libs   * Copy xml folder from your Cordova download earlier to /res ....   * Change the class's extend from Activity to DroidGap   * Replace the setContentView() line with super.loadUrl("file:///android_asset/www/index.html"); ... and so on which clearly mentions the steps to follow while migrating or creating an app for a specific platform. But upwards from the `version 2.1.0`, these information are missing. Like in the newer documentations, all they have is just the `regular android setup stuffs and android hello world` which we can obviously find on the official android documentation. I tried searching the whole documentation for that version and I could not find any information regarding the steps I mentioned above in the older documentation. Otherwise how are the readers supposed to know those steps? Am I missing something here or have they provided?


title: Cache While Developing or Finish Development then Cache?

text: I'm new to cache and haven't used it on my projects. I would like to know about what is best practice in caching. Should caching be done while developing or finish development then cache everything?


title: Is 'process debt' a term people work with

text: As a result of a retrospective we were uncovering worse ways of developing software. We had a idea we though was great and tried it. We stayed with it during the development of a major update which took 3 months. After a retrospective with the maintenance engineers it turn out our idea does not work for them (we had discussions with them before we tried the idea and the also thought it was a great idea). We came to the agreement we better get back to the old situation. The team for the update is dismantled and the maintenance engineers don't have time to do so (although their project manager has agreed to invest the time). We're now in the situation the maintenance engineers pay the interest each time a minor release has to be made. This is very much like technical debt but has nothing to do with the product itself. Is this called process debt or is this put under the term technical debt? And what would be a good way of dealing with it? (Any other or concrete ideas to make it visible to product managers?) PS The idea was migrating a 4 product VSS database to SVN. The database heavily leans on shared files and is a mess to untangle and pour in a usable SVN structure. It's very counter intuitive but is seems some things are better kept in VSS.


title: What are some good resources for debugging/disassembling proprietary software?

text: From time to time, I experience different bugs with proprietary software that I need to interact with. In order to get through these bugs, I need to develop various workarounds. Is there a good book for debugging/disassembling proprietary software to write better workarounds?


title: Quantify value for management

text: We have two different legacy systems (window services in this case) that do exactly the same thing. Both of these systems have small differences for the different applications they serve. Both of these system's core functionality lies within a shared library. Most of the time, the updates occur in the shared library and we simply deploy the updated library to both of these systems. The systems themselves rarely change. Since both of these systems do essentially the same thing, our development team would like to consolidate these two systems into a single service. What can I do to convince management to allocate time for such a task? Some of the points I've noted are:   * Easier maintenance   * Decrease testing/QA time Unfortunately, this isn't enough. They would like us to provide them with hard numbers on the amount of hours this will save in the future and how this will speed up future development. Since most of the work is done in the shared library and the systems themselves never change, it's hard for us to quantify how many hours this will save. What kind of arguments can I make to justify the extra work to consolidate these systems?


title: Continuous Integration using Docker

text: One of the main advantages of Docker is the isolated environment it brings, and I want to leverage that advantage in my continuous integration workflow. A "normal" CI workflow goes something like this:   * Poll repository for changes   * Pull from repository   * Install dependencies   * Run tests In a Dockerized workflow, it would be something like this:   * Poll repository for changes   * Pull from repository   * Build docker image   * Run docker image as container   * Run tests   * Kill docker container My problem is with the "run tests" step: since Docker is an isolated environment, intuitively I would like to treat it as one; this means the preferred method of communication are sockets. However, this only works well in certain situations (a webapp, for example). When testing different kind of services (for example, a background service that only communicated with a database), a different approach would be required. What is the best way to approach this problem? Is it a problem with my application's design, and should I design it in a more TDD, service-oriented way that always listens on some socket? Or should I just give up on isolation, and do something like this:   * Poll repository for changes   * Pull from repository   * Build docker image   * Run docker image as container   * Open SSH session into container   * Run tests   * Kill docker container SSH'ing into the container seems like an ugly solution to me, since it requires deep knowledge of the contents of the container, and thus break the isolation. I would love to hear SO's different approaches to this problem.


title: How do you validate critical input that cannot be vetted?

text: How does one prevent users from creating erroneous input sets, when there is no practical way to vet the input? ### The scene I modify a small ERP package written in Visual FoxPro. One part of the package concerns itself with printing truck manifests and invoices to be sent with the drivers on their delivery routes. The print routine, when fed nothing as an input, will attempt to print everything, resulting in reams and reams of printer paper being wasted on a high-speed printer. I am not in a position to re-write any of the GUI interface elements, nor can I adapt any frameworks, tool kits, or other outside code to be used in this situation. The reasons are related to office politics, please do not suggest that I can override the existing ERP framework, as it is not an option for me. ### The issue The users are in a high-pressure, time-critical environment. Each process is measured in minutes or even seconds, which means that I have to minimize processing time as much as possible. Because of this environment, and possible distractions, users _frequently_ ignore the dialogs, pressing the [Enter] key which causes the focus to rapidly move through the form and eventually landing on the action button for the input dialog, resulting in them triggering an automatic printout. The input consists of a date range, route range, and sales order range. The input for date range cannot be auto-set to "today's date", as frequent back-printing is required. Also, the end-users work during midnight, i.e. date rollover makes this impractical without rigging a routine that auto-detects the change, etc. The input for routes cannot be hard-coded, nor can it be deduced from routes that have already been shipped, because re-prints are required (see above). The input for sales orders only has meaning when printing single orders or specific ranges. So, frankly, _there is no practical way to validate input_. The action button that triggers printing cannot be blocked. Any suggestions that a blocking dialog be placed in front of the user will be ignored. I am not at liberty to discuss why this is not an option, other than the concept has been already discussed elsewhere on the site (from a different vantage point) and was rejected. Blocking printouts when all inputs are empty was rejected as a design decision as the software _must_ accommodate this as a feature. ### The users The users have been repeatedly asked not to do this. They frequently ignore this advice. Triggering this unfortunate event is not something that their foremen/managers will address, so there is no pressure to end the behavior. ### The organization I do not have a say in the workflow involved, only the modification of existing software components affected by that workflow. ### The vendor The vendor second-sources the package as a custom installation from the original software vendor. The vendor requires that all code changes be sent back to them for integration into their codebase. Significant changes to architecture will result in increased future costs during version migrations due to the extensive customization involved; in some cases, the programmers have even told me that they will completely ignore such large changes and will do as they please. ### The software I have no say in the selection or installation of the software, so changing the platform is out of the question. Regarding the environment of the software, each invoice printed is a single call. There isn't a batch printing facility, and because of how the print facility is integrated into the system (and some language quirks as well) it isn't feasible to make a batch wrapper around that API. Topping this off, this part of the program calls another program that does the invoice print, which in turn calls the print-a-report API, which prints a single invoice. Horrid design, I know. Input forms are a weird combination of a form header that is devoid of input boxes, but can contain other GUI elements. Input boxes are defined at runtime. ### The objective The software will prevent the users from erroneously printing all paperwork. How would you solve this issue?


title: Is going to grad school going to hurt your engineering career?

text: I study software engineering and have every intention to become one and stay one. However, I also love logic, computability theory, automata theory, and similar computer sciency math topics, and would love to do at least a Masters degree _at some point_ after I graduate to study these topics more in depth. This is really something I want to do for myself, and not because it will contribute something to my career as a software engineer (and let's face it- it won't either), but I'm worried that a few years of absence from the field will be frowned upon, and will make it harder for me to get back on the horse, so to speak. Is that true? How _do_ employers react to such absence?


title: interview for an internship but I think I may be unprepared

text: I have an interview for a C++ internship position. Now, the thing is I've taken two out of three quarters of the basic CS classes (in C++) at my community college and we covered the basics up to arrays, pointers, linked lists, recursion, etc (basically all of Walter Savitch's Absolute C++ book). I spoke to the interviewer on the phone and he said the interview will include technical questions on trees, hashes, probably some sorting algorithms, and other stuff like that. I have less than a week to prep for the interview. What can I do to familiarize myself with the absolute, bare, essentials of the aforementioned interview question topics? Or, is it just a waste of time for me until I take the next class that covers all of those things?


title: Design strategies for storing and validating serial numbers

text: We are writing software to track Foo Widgets. Each Foo Widget has a serial number. The serial number is an 32-character alphanumeric string. The string is separated into five sets. Each set is separated by a dash (so the s/n is 32-characters NOT including dashes). So for example: 11111111-1111-1111-1111-111111111111. But this may change, since our software isn't actually creating the serial numbers. I'd like to learn about different strategies for storing the serial number and doing user validation of the serial number in the UI. To start with, I'd like get talk about strategies for storing the the serial number in our system. This issue came up at Foo Widgets Incorporated, and there was a disagreement about whether we should store each serial numbers with or without the dashes. I think the most flexible way of doing this (but maybe not most simple) would be to store the serial number without the dashes, store the schema of the serial number (as a regular expression), and then create an identifier that is used to track which schema is used (so later if the manufacturer changes it we can support that and perhaps both schemas at the same time). The counter argument to this was that the dashes "are a part of the data" and that it's "not like a phone number". I'm having some trouble understanding this point of view.


title: How to store record statuses (like pending, complete, draft, cancelled...)

text: Quite a lot of applications require records in their tables to have a status, such as 'complete', 'draft', 'cancelled'. What's the best way of storing these statuses? To illustrate what i'm getting at here is a *very short) example. I have a simple Blog application and each post has a status one of: published, draft or pending. The way i see it there are 2 ways to model this in the database.   1. The Post table has a text field that includes the status text.   2. The Post table has a status field that contains the ID of a record in the PostStatus table The Blog example here is a very simple example. Where an enum (if supported) might suffice. However i'd like responses to the question to take into account that the list of statuses could change at any time, so more could be added or removed. Can anyone explain the advantages/disadvantages of each? Cheers! My initial optnion on this is that its better to use another table and look up the status as its better for normalisation and i've always been taught that normalisation is good for databases


title: Separation of Concerns when adding new types

text: I have a system I've been working on this week where I'm having a hard time balancing separation of concerns with easy extensibility. I'm adding new types to the system, and it feels like shotgun surgery. The basic idea is that data is collected (polled) from a remote system and then made available to a number of different kinds of clients. To support their interface type (protocol), I'm doing a lot of translation. I'm going to try to simplify this so I can fit it in a question box. There's a FruitService out in the world with an SNMP interface. My publisher's job is to collect that data and then publish it.   1. So for each kind of new Fruit we decide to publish, I create a class that knows how to pull the attributes for that fruit via SNMP.   2. Internally Fruit is translated to DTOs (the same objects used to talk to client #1 (RMI)).   3. A cache is updated and checked for changes to trigger async notifications.   4. A class to translate the fruit into the xml schema used by another client (#2).   5. A class to translate the fruit into simple attribute/value pairs used by another client (#3). In the end I create 5 classes and edit 8 more to plug in a new type. It's not a lot of work; couple hours to write code, test, and check-in for a simple type. Note that there isn't a lot of commonality in the fruit types (e.g.: pear and coconut), so most of the common abstractions are based around the process of updating the data and not the data itself. My design concerns are:   1. The SNMP interface changes 2-3 times a year   2. The xml schema (client 2) changes 10 times a year.   3. Adding new types happens less frequently, generally when someone gets around to it. But maybe if it was easier... So the notional goal with the design was to handle those external changes easily. This lead to all the separation in the translation layers. But adding types feels harder than I'd like. Is there a technique or example I might look into? An idea I'm missing? Am I applying SRP wrong and there should be an Apple type that speaks SNNP, xml schema, DTO, etc? ![alt text](http://imgur.com/IaAEU.png) EDIT: Client #1, the RMI client, is custom written when a new fruit is added, to take advantage of all the fruit's capabilities. So if we decide to pull banana information from the FruitService we will also write a client that allows you to peel the banana, get a notification when it's ripe, and tell you which bunch it belongs to - along with the basic fruit attributes like size, weight, color, time till rotten, etc.


title: What are the disadvantages of a "simple factory"?

text: I am reading the book »Head First Design Patterns« from O'Reilly. Before explaining the Factory Method Pattern, they introduce a Simple Factory first. They are using the example of a pizzeria. In a first step they show the problem:               Pizza orderPizza(string type) {       Pizza pizza;       if (type.equals("Pepperoni") { pizza = new PepperoniPizza(); }       else if (type.equals("Salmon") { pizza = new SalmonPizza(); }       // ... and so on            pizza.Prepare();       pizza.Bake();       pizza.Cut();       pizza.Pack();       return pizza;     }      The obvious problem is that you had to change Pizzeria whenever you add or remove a Pizza.   Hence they introduce a "Simple Factory Idiom" first. They move the creating part into a class "SimplePizzaFactory". Now you don't need to modify Pizzeria anymore when adding or removing a Pizza. Then they say that this approach isn't that good, when you have more than one pizzeria (in several towns).   I don't really understand their reasoning. They give the following example code and then they say that each pizzeria wouldn't be using the procedure as implemented above but were using different methods in order to "bake", "cut" and "pack" the pizza.               BerlinPizzaFactory berlinFactory = new BerlinPizzaFactory();     Pizzeria berlinPizzeria = new Pizzeria(berlinFactory);     berlinPizza.Order("Pepperoni");      Instead of using the Simple Factory, they suggest using the Factory Method Pattern. First, I don't see why the BerlinPizzeria is supposed to not using the procedure. It's still a Pizzeria and when you call Order, you're using the same procedure. My best guess is that they are implying that you are able to implement, let's say, a cafeteria (I'm deliberately using something entirely different to make my point) and use the factory (as it is independent of the pizzeria) and prepare the pizza in a way you want to. But even when using the Factory Method Pattern, nobody forces you to use the default procedure. It's even simpler to "hide" that you're doing it differently. Their code examples are given in Java and Java methods are virtual by default. So I would be able to implement BerlinPizzeria and override Order (or had to explicitly declare the method as final). The client, however, wouldn't notice that my BerlinPizzeria is doing things differently. In conclusion I don't see any significant difference between a Simple Factory and the Factory Method Pattern. The only advantage of the Factory Method Pattern I'm seeing is that you would save a few classes (namely, the 'outsourced' factories). So, what is really the disadvantages of a Simple Factory and why isn't is a good idea to 'outsource' the creating part?   Or what is really the advantage of the Factory Method pattern and why is it a good idea to force the creating part being implemented in the subclass?


title: Open .doc file from my website in browser

text: What's the best way to give the end-user of my web application the ability to open, edit and save (via browser) word documents that are stored in my database? I have this working by doing an html conversion of the file (via Aspose Words) but this method seems not even close to flawless and i'm trying to improve this. Is integrating with google docs possible/good? Their edition seems awesome and very powerful. I can't use any Microsoft Word objects (and this is even discouraged by MS). EDIT: The application is developed in .NET and currently uses the .NET framework 2.0. However, as this is fairly obsolete the idea is to restart from scratch and therefore use the 4.0 framework and C# or VB.


title: Wolfram is out, any alternatives? Or how to go custom?

text: We were originally planning on using wolfram alpha api for a new project but unfortunately the cost was entirely way to high for what we were using it for. Essentially what we were doing is calculating the nutrition facts for food. (http://www.wolframalpha.com/input/?i=chicken+breast+with+broccoli). Before taking the step of trying to build something that may work in its place for this use case is there any open source code anywhere that can do this kind of analysis and compile the data? The hardest part in my opinion is what it has for assumptions and where it gets that data to power the calculations. Or another way to put it is, I cannot seem to wrap my head around building something that computes user input to return facts and knowledge. I know if I can convert the user input into some standardized form I can then compare that to a nutrition fact database to pull in the information I need. Does anyone know of any solutions to re-create this or APIs that can provide this kind of analysis? Thanks for any advice. I am trying to figure out if this project is dead in the water before it even starts. This kind of programming is well beyond me so I can only hope for an API, open source, or some kind of analysis engine to interpret user input when I know what kind of data they are entering (measurements and food).


title: Complex fetching of Domain Objects

text: Usually whenever I want to fetch an aggregate root by ID I just use some type of Repository::findByID(...) function Whenever I started with DDD I thought factories where just a pattern to build _new_ objects, but after meeting some aggregates needing one or two extra queries to load, I realized that Factory::objectWithID(...) were useful to also create instances of objects already existing in the database. Now I have a tree relationship of entities, like **Project->Task**. The number of relations is huge and I have no framework providing lazy loading. Since Tasks can be nested, have complexity of their own, and should not be fully retrieved in one query, I made **Project** and **Task** different aggregate roots How should I retrieve and persist **Tasks**?. It seems that a **ProjectFactory** is not the solution this time because a **Project** does not contain the whole **Task** tree. I still want some aggregate root like features for my **Project** , and since I am avoiding queries inside my entities, I decided to write the relationships inside a Project-Service-Aggregate. Now I can retrieve a single **Project** with a Repo::findByID() function, but fetching a **Task** looks like               ProjectAggregationService *service = ProjectAggregationService.new(SomeProject)     Task task_1 = service.findTask(...)     Task task_1_child_2 = service.findTaskChild(task_1,2)      I am puzzled at this point because:   1. I have a service to represent entity relationships.    2. I am declaring many instances of a service, whereas before, services tended to be quite unique objects.   3. Not having a clear object tree like Project.tasks[1].subtask[3] make the code above look like more complex than necessary. Basically I could summarize my question to: Did I take the right approach? I would greatly appreciate any comment on my reasoning. I am mostly concerned about degenerating my code with overblown complexity, but I still think that keeping references to queries and repos outside my entities implementation is a good goal.


title: How to detect root cause of problem or bug

text: Often in coding, I find it very slow and difficult to detect the root cause of a bug and sometimes I end up going to wrong point in my code. It's painful. I know that to detect the root cause of a bug is a very important skill for programmers. Does anybody have a trick or technique to suggest a good way of finding the root cause?


title: Confused About Virtual Memory for All Processes

text: I hope this is the right place. This is a homework assignment for my Operating Systems course and I have to implement a working virtual memory system in C++ so programming is directly involved. I've read some sources about Paging and Virtual Memory now (Tanenbaum, What Every Programmer Should Know About Memory, etc) and noticed that everybody starts off with the phrase `Every process gets its own virtual memory.` Then off they go into a detailed analysis about page size, page replacement algorithms, the MMU and TLB, etc. Those things are actually quite fine in my mind, what doesn't make sense is the concept of virtual memory. If I have four processes running simultaneously and each process uses it's own virtual address space, how is the physical memory protected? The MMU translated the virtual address 0 the same whether it comes from process one, two, three or four. Let me give an example: Every process has a 32-bit virtual address space that it can use. Every process starts off the same way               MOVI 10, 0  // r10 = 0      LOAD 11, 10 // r11 = MEM[r10]; value at address 0x00000000      I just don't understand this concept of distinct virtual address space if every process tries to call the same virtual address which will be translated the same way by the MMU. So all four processes will receive the same data? We have a page table which keeps an index of every mapped and unmapped page to a page frame. If each page entry is unique, then how can it account for the duplicated virtual address space that each process has? I'm at the point where I have written design drafts for the MMU, TLB and the Page Table, but I can't continue until I properly understand how the heck virtual space is defined and used for each process.


title: Is Clojure a 3GL or a 4GL?

text: A bit of background (in case I'm mistaken)... I think I understand that (it's an oversimplification):   * manually entering codes into memory (or on a punchcard) is "first generation language"   * using mnemonics corresponding to CPU instructions would be a 2GL (like assembly language)   * C/C#/Java/Objective-C are all 3GLs   * SQL is a 4GL Where would Clojure stand in such a classification? I'm particularly confused by this Wikipedia sentence: > The archetypical example of a declarative language is the fourth generation > language SQL, as well as the family of functional languages and logic > programming. This sentence seems to imply that all functional languages are declarative. Is that correct? Then Clojure can be used in a functional way (and it is probably recommended to use it "as much as possible" in a FP style), so is Clojure a declarative language ? Also, I can see that Clojure make it really easy to create 4GLs (e.g. as embedded DSLs, like core.logic reproducing logic programming in about 200 lines of code) but is Clojure itself a 4GL?


title: What are the requirements for an open-source license inside an open-source license?

text: If I include an open source library in my project that is licensed under the MIT license, but contains BSD-licensed code that requires attribution (correctly attributed inside the project), is it my responsibility to attribute it again if I decide to use that library? Normally this is not a problem (I would just credit everyone regardless of the license) but on a mobile platform there is not a lot of real estate or efficient ways to show / bundle these licenses.


title: Polymorphism versus authorization

text: I have something bother me in the understanding of polymorphism (vs role):   Note: I am using rails (but it's a general question) I have **4 models** :   * User   * Pro   * Customer   * Company There is a **polymorphic association (profileable)** between Pro/Customer and User [because Pro has many more fields for the registration process than Customer]. User is used for the session (I am using the devise gem) Basically something very similar to this writing is used: http://jeffsaracco.com/blog/2012/03/04/ruby-on-rails-polymorphic-user-model/ ### Company association   * Now, I want to create my association with Company.   * By now, only **Pro has one Company** (but I figure it could be other profileable_type which can also have a Company).   * Customer doesn't have a Company. In that case which association is preferable: ### Approach 1   * User has_one Company   * Company belongs_to User   * and manage authorization (with a gem like cancan) to permit company creation only for Pro (with my profileable_type field in the user table) or: ### Approach 2   * Pro has_one Company   * Company belongs_to Pro   * So in that case I don't need any authorization management anymore (User (and by extension Customer) cannot create company by default) Looking for pros/cons of the 2 approaches. I am pretty sure the first one is the best solution as I have a user_id in my company table which would be more generic and expandable than having a pro_id.. I would be pleased to be sure. Thanks!


title: How to add image support to client-server database application?

text: I have an architectural question about a project that I am working on. Currently it is a simple .NET C# application that runs on several client machines, and communicates with a central MySQL server for data storage. There is not an application or service on the server at this time, just MySQL. I would like to add image support so that users can add images to the database (and view after the fact), but after storing the images directly in MySQL as `BLOB` I've decided this approach is a bad idea, as suggested in many posts on SO. The application can't store images on the local filesystem because they would then be inaccessible to other users not on the same local host. That being the case, I'm not sure how best to implement image support otherwise:   * The machines are all Windows-based, I can set up a shared folder but then I have the headache of maintaining a mapped network drive and user credentials/permissions.   * I've thought of adding another application (or service) that runs on the server and handles reading/writing of images on the server side, but this seems redundant in light of the fact that the computers already are capable of file transfers.   * Should I consider creating an application on the server to handle all communications between clients and the SQL database, adding filesystem communication there?


title: Writing to event log - best practice if log is full

text: I have an application that writes to its own Event Source. The Event Source itself is created upon install to prevent user vs admin access issues at runtime. Should writing to our own Event Source fail, the event is instead written to the Application log (two events actually, on for the original event data, and another saying 'Could not write to own event log because...' or something similar). We've recently discovered a problem that when the Application event log is full, the exception is unhandled. Now granted, I could just eat the exception (similar to what this answer says). So what is the best behavior? The application is attempting to log the issue and attempting to log that there is a problem. Should I eat the exception, let the logging operation fail silently and continue execution? Or should I let the exception bubble up the call stack so that user/developers know of the issue? What's the recommended approach under these conditions?


title: Move a player to another team, with players stored in one arraylist and teams in another using java

text: Basically I have a team class, which has an array list that store the players in. In the driver class there's an arraylist that stores the teams. Anyhow I've worked out how to add a player to a specific team and likewise remove a player from said team. Where I'm hitting problems is when I try to transfer one player to another. My understanding is to scan through the first team, and get the player. Then somehow add this player to another, by scanning through the chosen team and add to it? I've tried this way but it seems to replace the original player with the new player in both teams. My other approach would be to somehow return the parameters of the player object, create another with the return parameters, remove the original then add the new instance in the other team? Really not quite generally how I can go about this, been trying all afternoon!   If someone could offer me a general idea, then I can go off and apply the understanding to practice.


title: How to store exception messages

text: How are exception messages commonly stored? for any domain. I'm thinking about this from a maintenance standpoint.               if(!Condition1)         throw new Exception("Some exception");          if(!Condition2)         throw new Exception("Some exception");      If it was decided that the exception message in that snippet needed to be changed, it would have to be changed in two places; leaving it wide open for inconsistent messages and such. How better to store exception messages then? Perhaps as a static class with constants?               public static Exceptions     {         public const string CONDITION_NOT_MET = "Some exception";     }     ...     if(!Condition1)         throw new Exception(Exceptions.CONDITION_NOT_MET);          if(!Condition2)         throw new Exception(Exceptions.CONDITION_NOT_MET);      Are they often (in production) hardcoded?


title: Validation and Verification explanation (Boehm) - I cannot understand its point

text: Hopefully my last thread about V&V as I found the B.Boehm is text which I just do not understand well (likely my technical English is not that good). http://csse.usc.edu/csse/TECHRPTS/1979/usccse79-501/usccse79-501.pdf Basically he says that verification is about checking that products derived from requirements baseline must correspond to it and that deviation leads only to changes in these derived products (design, code). But he says it begins with design and ends with acceptance tests (you can check the V model inside). The thing is, I have accepted ISO12207 in terms of all testing is validation, yet it does not make any sense here. In order to be sure the product complies with requirements (acceptance test) I need to test it. Also it says that validation problems means that requirements are bad and needs to be changed - which does not happen with testing that testers do, who just checks correspondence with requirements.


title: Is there an open source license with proprietairy-like terms?

text: Is there any license meeting the following criteria:   * source code available (users allowed to browse the source)   * users are allowed to modify the code with credits to the original author   * not allowed to sell the software itself or any other program using code from it   * can be sold by original author


title: Knowing so much but application is a problem?

text: In my work, my friends always tell me, you know so much about computer science, electronics engineering,..etc. But I have difficulty in applying them and my code is crap. How to solve that problem? Will I be better or programming isn't my career? For example, yes I know OCTree that is used for space partitioning in games and it is used for optimization, did I implement it? No, but I know about it in principle.. Do I know algorithms like Sorting, Searching,..etc? Yes, and I know them pretty well, but didn't implement them.. When I get a task, I struggle in applying the things that I know...


title: When defining directory path, should a trailing slash be included?

text: Say I'm defining a directory and then including files from it. Is it better practice to do:               define('PATH', 'C:/xampp/htdocs/includes/');     require PATH.'header.php;      or:               define('PATH', 'C:/xampp/htdocs/includes');     require PATH.'/header.php;


title: Using foldr to append two lists together (Haskell)

text: I have been given the following question as part of a college assignment. Due to the module being very short, we are using only a subset of Haskell, without any of the syntactic sugar or idiomatic shortcuts....I must write: _append xs ys : The list formed by joining the lists`xs` and `ys`, in that order_               append (5:8:3:[]) (4:7:[]) => 5:8:3:4:7:[]      I understand the concept of how foldr works, but I am only starting off in Functional programming. I managed to write the following working solution (hidden for the benefit of others in my class...) : > append = \xs -> \ys -> foldr (\x -> \y -> x:y) ys xs However, I just can't for the life of me, explain **_what the hell is going on!?_** I wrote it by just fiddling around in the interpreter, for example, the following line :               foldr (\x -> \y -> x:y) [] (2:3:4:[])      which returned `[2:3:4]` , which led me to try,               foldr (\x -> \y -> x:y) (2:3:4:[]) (5:6:7:[])      which returned `[5,6,7,2,3,4]` so I worked it out from there. I came to the correct solution through guess work and a bit of luck... I am working from the following definition of foldr:               foldr = \f -> \s -> \xs -> if null xs then                                   s                                else                                   f (head xs) (foldr f s (tail xs) )      Can someone baby step me through my correct solution? I can't seem to get it....I already have scoured the web, and also read a bunch of SE threads, such as How foldr works


title: Is having C++ header files without extension a good practice?

text: I have an argument with a collegue of mine regarding the C++ guidelines to follow. He currently designs all his libraries that way:   * He uses inconsistently uppercase and lowercase letters in his filenames   * Some of his headers don't have any extension I believe that having no extension is something reserved for C++ standard files and that using uppercase letters is error prone (espcially when you deal with code which is meant to work on both Windows and Linux). His point is that he follows `Qt` conventions (even for code that doesn't uses Qt) and keep saying : "If Qt does it that way, then it can't be bad." Now I try to keep an open-mind, but I really feel bad when I have to work on/with his libraries. Is there a common established set of rules regarding this ? Does the standard tell something about it ? Thank you very much.


title: Dynamic Fields/Columns

text: What is the best way to allow for dynamic fields/database columns? For example, let's say we have a payroll system that allows a user to create unique salary structures for each employee. How could/should one handle this scenario? I thought of using a "salary" table that hold the salary component fields and joining these columns to a "salary_values" table that hold the actual values. Does this make sense? **Example Salary Structures:** Notice how the components of the salary can be shared or unique. \-- Jon's Salary --               Basic           100        Annual Bonus    25        Tel. Allowances 15      \-- Jane's Salary --               Basic             100     Travel Allowances 10     Bi-annual Bonus   30


title: Best practices for deploying multilingual API

text: I have a hobby project and it looks like there is need to have some API library (which in turn is a wrapper over existing http API) at least for two languages - JavaScript and Python, adding support to Perl would be nice as well. The question is - what are the best practices for minifying the cost of supporting and developing of such multilanguage APIs? Is it better to choose one language and write just wrappers that for other ones? Or it's better do move slower but to implement thoroughly each method on each language.


title: Is Independent Java Development Worth it Compared to Objective-C?

text: First I would like to say that I'm not developer, but I love to code whenever I can. I mainly use Perl which is the language I use when doing System Administration. For different reasons (that I'm not sure of) I recently have been told to learn Java by my manager, so I'm starting to do so. I was thinking that I should take advantage to the situation to build some Android Apps. But it seems that Objective C has increased in popularity recently because of the iPhone and iPad. I want to know if it's worth it to develop with Java for Android compared with to develop with Objective C for iPhone (or iPad). Of course, not based on the APP functionality, let's say someone has developed the APP X for both platforms. In which platform would it become the worthiest? And no, I'm not gonna learn both (sadly ain't got much time) Thank you!


title: industry averages for time spent on maintenance

text: A manager recently announced that were were spending far too much time fixing bugs. I guess he thinks we should write perfect code all the time (whilst still hitting those impossible deadlines of course!) and it made me wonder what the industry average of time spent bug fixing v writing new code was. So does anyone have any metrics on time spent bug fixing against new code development? Or is there any empirical analysis of bug fixing time for the industry as a whole? Is 50% spent bug fixing too much, or about right? How about 20% or 33%? I'm happy to accept anecdotal evidence from personal experience as that would form part of some statistics here that I could compare our performance against.


title: Shouldn't documentation be written together with tests rather than in the code?

text: It is popular to write documentation in the same file as the code and extract that using software to generate documents. In order to not affect performance, the documentation is written within commented lines, in a DSL designed just for the purpose of that. And that often results in cumbersome source file. Nowadays, test driven development is popular, and usually tests are written on separate files from the code. Since test files are not run during production, it does not interfere with performance, and hence test are not written within commented lines in a DSL, but are written in the same programming language as the code. Doesn't it make more sense to write documentation in the same file as tests not in commented lines but in the same programming language using DSL? For each syntactic element like class, method, first a documentation telling the features of it can be written, and then test can follow it. That would make things nicer in my opinion. I have scripting languages like Ruby in mind if that makes difference.


title: What "code smells" are there that are a symptom that an event listener model is required?

text: What are the symptoms in a code base that indicate that an event-listener approach is required? It seems to me that when there are classes that need to be called by multiple, not defined at design-time set of other classes, you need some sort of signaling framework, but I would like to hear what other situations are there that would be improved by changing to an event-based model.


title: Development Test Interview

text: I have a development test I am required to solve a given problem with any language of my liking in about 8 hours. The company is GFI if anyone was wondering. How can I truly prepare for such a test?


title: How to continue development without the webservice?

text: We make iOS apps where we often get data in a list from an API, then we select the data and go to the next ViewController. Often it happens that the server is down or some API is not ready. What is a good development practice where we can continue our regular work flow without depending on the webservice and then when its ready without making much changes continue using the web-service and till then use some fixed data.


title: Is using dynamically generated code as cache a good idea?

text: I have a web search interface that can compare products in a table. This data set changes a few times a week. I have been storing a "DISTINCT" list (used for parametric selection) in a `cache` table. The query is computationally expensive because it involves table joins and thousands of records, hence the reason to cache it. I was wondering if it is a good idea to "cache" certain data in PHP in dynamically generated code. The idea is that I could create a cache.php file that is 'included' which has the data in arrays for PHP to use without going to the database. This PHP file could be cached using any of the PHP compiler caches out there. I'm not having speed issues (yet), but I don't like the idea of having to ask the database for cache data, as it seems the overhead of the php->mysql transaction is expensive.


title: Why is Java not 'pure' OOP?

text: Java is designed in a very OO approach, and somewhat even 'forces' programmers to program within the OO paradigm (which can be considered good or bad, a matter of opinion). However while _almost_ everything in Java is a class or an object, primitive data types (`int`, `double`, etc) are not. While I see no advantages to this, there are disadvantages. For example, when a method wants to take in as a parameter 'any value', it usually declares the parameter of type `Object`, the supertype of all classes in Java. However if the programmer wants to input an `int` to the method - a perfectly valid value - he/she has to 'box' the value in an instance of the `Integer` class, created specifically for these kinds of needs (as far as I understand). My question is: why aren't primitives in Java classes, like everything else?


title: What naming anti-patterns exist?

text: There are some names, where if you find yourself reaching for those names, you know you've already messed something up. For example: **XxxManager**   This is bad because a class should describe what the class does. If the most specific word you can come up with for what the class does is "manage," then the class is too big. What other naming anti-patterns exist? **EDIT** : To clarify, I'm not asking "what names are bad" -- that question is entirely subjective and there's no way to answer it. I'm asking, "what names indicate overall design problems with the system." That is, if you find yourself wanting to call a component Xyz, that probably indicates the component is ill concieved. Also note here that there are exceptions to every rule -- I'm just looking for warning flags for when I really need to stop and rethink a design.


title: Does it make sense to use ORM in Android development?

text: Does it make sense to use an ORM in Android development or is the framework optimized for a tighter coupling between the UI and the DB layer? * * * **Background** : I've just started with Android development, and my first instinct (coming from a .net background) was to look for a small object- relational mapper and other tools that help reduce boilerplate clode (e.g. POJOs + OrmLite \+ Lombok). However, while developing my first toy application I stumbled upon a UI class that explicitly requires a database cursor: `AlphabetIndexer`. That made me wonder if maybe the Android library is not suited for a strict decoupling of UI and DB layer and that I will miss out on a lot of useful, time-saving features if I try to use POJOs everywhere (instead of direct database access). * * * **Clarification** : I'm quite aware of the advantages of using ORM _in general_ , I'm specifically interested in how well the Android class library plays along with it.


title: Is C++11 Uniform Initialization a replacement for the old style syntax?

text: I understand that C++11's uniform initialization solves some syntactical ambiguity in the language, but in a lot of Bjarne Stroustrup's presentations (particularly those during the GoingNative 2012 talks), his examples primarily use this syntax now whenever he is constructing objects. Is it recommended now to use uniform initialization in _all_ cases? What should the general approach be for this new feature as far as coding style goes and general usage? What are some reasons to _not_ use it? Note that in my mind I'm thinking primarily of object construction as my use case, but if there are other scenarios to consider please let me know.


title: Is there a universal date format that anyone in the world can understand?

text: In Canada, everyone is familiar with the date format `YYYY-MM-DD`. In Europe or South Africa, they prefer `DD-MM-YYYY`. There are users from South Africa who get confused with the `YYYY-MM-DD` date format. Is there a way to handle this situation? I was thinking of using the following method format for all: `Feb 02, 2011`


title: What are the hardest parts of the C++/C#/Java programming languages?

text: Just wondered what are the features of the three main programming languages which show you are an 'expert'? Please exclude 'practical' skills such as indenting. Am I right in saying for C++ the most difficult aspect to master is STL/generics? Java seems much easier as memory is handled for you. I'm not entirely sure on C# either? I'm trying to use this to guage my current level of ability and what i wish to aim for. ps this was posted on stackoverflow but got binned due to arguing, please do try to keep it civil as I am really interested in the answers from everyone :)


title: Do programmers possess the means of production?

text: I was listening to The Servile State by Hilare Belloc this morning and pondering whether or not I possessed the means of production, as did the peasant of the Middle Ages; as did not his descendants after the oligarchs of England forced him into servitude. The means of production was the arable land that the serf was seated on, which, even though not legally his, was illegal to evict him from. So, as programmers, with the hitherto unknown supply of free tools and resources, have we reclaimed as a class of workers, unlike any others, the means of production? Given the chance, a midrange PC and a stable internet connection, could we not each of us be wholly self-sufficient and not just wage-earners?


title: Web application deployment and Dependencies

text: I have a free software web application that using other free software scripts for appearance. I have trouble to decide whether should I copy source code of used scripts to my project main repository or list them as dependencies and ask user (who installs application to his server) to install them himself? Since some of scripts solving browser compatibilities issues and I'm not a good web designer (i hate to check my web site on IE to see compatibility) using the newest version of scripts is preferable and second solution works here. But it has problem with scripts aren't backward-compatible with versions I've used them for development. Maybe another method is well-known for this issues that I don't know them.


title: When is it not appropriate to use the dependency injection pattern?

text: Since learning (and loving) automated testing I have found myself using the dependency injection pattern in almost every project. Is it always appropriate to use this pattern when working with automated testing? Are there any situations were you should avoid using dependency injection?


title: Why c++? Where to start?

text: I know there was many questions like this one, but please hold on one more. All programming languages I know now are made for web purposes. I've been learning ActionScript, php and a bit of Javascript, AJAX, etc.. I've liked php very much but I'm still looking something I'll really love! That's why I want to try something new. Can You tell me what are positives and negatives of this language? Is there some big example of C++ usage? Is it a good language to start this journey (maybe You can recommend something else)? Are there some good video tutorials which I can buy on CD/DVD? Could You recommend some books? @edit: After reading Your answers and some info on the internet I'm confused about two languages. Those are C++ and Python. Python can be used for web so it combine great with my current knowledge. But how about Python for desktop applications? Is it hard to build cross-platform apps? Could You compare for me this two languages? PS. I'm really glad about all of Your answers. It is very helpful for me & it forces me to productive thinking about my future ;)


title: How can I translate my android app help and keep it up to date?

text: My Android application is almost done and I spend much time creating a set of very precise help pages in HTML that I display using WebViews. I am now ready for the next step, which is _i18n_. Translating my app is no problem, the strings.xml is not that long and I can easily ask friends to translate it. My problem is about these help pages. When I'll update my app, I'll probably have to update the help pages as well. I saw that it wasn't that simple, even with one language. I need your opinion on how to perform such a massive work (which is not at all my job as a developer). Do I need to:   * Manually update every language help page when I update the app, which means asking all of my translators to provide a new version of their work each time I change anything.   * Provide help only in a default language (probably English, even though the default language is French. French people would still have the French help ;-D).   * Google-translate the help pages, even if it _"not well English is"_. I don't know any way to do it automatically.   * Do something else, which you probably thought of long ago. Thanks for your answers, tips and tricks.


title: Creating a separate project for JPA entities

text: Where I work it is a common practice to create a separate for JPA entities and a project for the web application (the WAR). So basically you have (at least) two project for each application - appJPA and appWEB. The people who started this convention are no longer there, so I have been wondering about the benefit of having this separation. The only advantage I could think about is the Eclipse JPA facet which provides various tools for JPA. But if I am not mistaken, this facet can be applied to WAR projects as well. So my question is: is this separation unnecessary?


title: How can I sell my boss on Python+Django instead of PHP+a different framework?

text: My boss has tasked me with a re-write of our intranet website. The existing system is very old PHP that doesn't use a framework. My preference is strongly to do the rewrite in Python and Django but my boss does not like Python syntax (he is also a developer). I'm on the opposite end... I don't like developing in PHP and my PHP experience is extremely limited but I've done a lot of work in Python. My boss is aware of my experience but still wants me to sell him on Python. Some of the things he mentioned he does not like about Python:   * indentation is the only marking for the begin/end of a code block (he loves his curly braces)   * documentation issues (I told him python documentation is great)   * IDE support is limited (mentioned PyCharm and Wing IDE, not sure which is better)   * he's had compatibility issues moving between older versions of python He may be the only other pair of eyes on the new code. How can I convince him that Python is a better choice? Is Ruby a potential middle ground?


title: Assembly instructions execution time

text: Where can I find the x86 instructions execution time? How to find out which instruction is faster or smaller?


title: Inserting HTML code with jquery

text: One of our web applications is a page that takes in a serial number and various information is returned and displayed to the user. The serial is passed via AJAX, and based on the response, one of the following can happen -   * An error message is shown    * A new form replaces the previous form Now, the way I am handling this is to use jQuery to destroy (using $.remove()) the table that displayed the initial serial form, then I'm appending another html table that contains another form. Right now I am including that additional form as part of the html source, and just setting it to display:none, then using jQuery to show it when appropriate. However, I don't like this approach because if someone views source on the page, they can see that table html code that is not being displayed. My next thought would be to use AJAX to read in another HTML file, and append it that way. However, I am trying to keep down the number of files this project uses, and since most pages in our project will use AJAX, I could see a case where there are multiple files containing HTML snippets - and that feels sloppy to me. What is the best way to handle a case where multiple html elements are being shown and removed with jQuery?


title: What must I take into consideration when designing a UI around a 0..1:1 relationship?

text: I'm designing the database schema for a new product feature. In my current design I have some related optional data. Rather than have nullable fields I have a separate table with a 0..1:1 relationship to the main table. I chose this design because the queries are simpler* if null data doesn't have to be taken into consideration. The team lead pointed out to me that it will complicate data binding in the UI and suggested that I just use nullable fields. I am wondering what complications the optional table approach will introduce? The obvious thing that comes to mind is the data aware controls can't bind to a closed data set so I'll need to either create a record on the fly when the user attempts to fill in the optional data or create the record at the same time as the main record, negating the purpose of have a separate table. Is there anything else I should be aware of? **Clarification** *Simpler, by which I refer to the dizzying amount of rules and ambiguities concerning null's behavior under different query scenarios in the SQL standard and the fact that no two vendors agree on which of these rules to implement.


title: What to do when there are no logical user stories but separate development tasks?

text: We need to generate a release in 3 weeks, and for the planning we are doing today we don't have coherent logical user stories from the backlog tasks. Is valid to match say each development task is equivalent to an user story? Methodologically what is the correct way of handling this?, because anyway we are going to have standup meetings and we are going to control the progress of the project against those development tasks. For example, we have things like: . Adapt ETL to process numeric lists . Adjust licensing component . Remove DTC and so on. So, for the planning poker and iteration planning is valid to use those tasks? if not, what is the alternative?


title: Choosing the simplest platform version of a source when porting to another platform

text: The question will sound weird as I'm not very experienced in C, C++ and ASM. Let's say I have a hard time finding a C# managed, safe-code-only solution to solve a problem. Then I find that in 1998, some codes for (e.g.) a codec have been written in C for PPC, x86, arm, etc. This code can have 20000+ lines, and I need to port it. Then I try one platform, and notice a lot of API call, CUDA stuff, inline assembler in most of the code. Etc. Is there a preference, concerning portability, between PPC, PS2, x86, arm, sparc, etc, when porting to another platform that helps reducing the number of platform-specific code occurrence? I know that all these builds exist especially because there are specific features on each processors, but I wonder if some processors have less antennas, third eye, and four legs, and are less simpler (or "limited") than others. I spent the last week porting codes, and had the intuition that focusing on certain aspects helps finding more cross-platform code. I may be wrong, and I - know - that it highly depends on skill. But that doesn't change anything to the fact that, e.g., a 20000 lines Java code may be easier to port to .Net for Windows Phone than a x86 asm code. More specifically, my question is about a good approach when porting Orange to Peach, and avoiding going through several platform specific implementations.


title: Does Liskov Substitution Principle also apply to classes implementing an interface?

text: LSP states that classes should be substitutable for their base classes, meaning that derived and base classes should be semantically equivalent. But does LSP also apply to classes implementing an interface? In other words, if an _interface method_ implemented by a class is semantically different from what user expects it to be, would this be considered as a violation of LSP?


title: What is the "1620's multiplication operation"?

text: I was stumbling through Wikipedia when I came across the entry for FLOPS, specifically the table in this section. The first entry is for a computer from 1961, the comment on the right reads > The 1620's multiplication operation takes 17.7 ms.[46] What is this operation? I assume it means it can do multiplication in 17.7ms?


title: Should Developers Perform All Tasks or Should They Specialize?

text: Disclaimer: The intent of this question isn't to discern what is better for the individual developer, but for the system as a whole. I've worked in environments where small teams managed certain areas. For example, there would be a small team for every one of these functions:   1. UI   2. Framework code   3. Business/application logic   4. Database I've also worked on teams where the developers were responsible for all of these areas and more (QA, analsyt, etc...). My current environment promotes agile development (specifically scrum) and everyone has their hands in every area mentioned above. While there are pros and cons to each approach, I'd be curious to know if there are more pros and cons than I list below, and also what the generally feeling is about which approach is better. **Devs Do It All** **Pros**   1\. Developers may be more well-rounded   2\. Developers know more of the system   **Cons**   1\. Everyone has their hands in all areas, increasing the probability of creating less-than-optimal results in that area   2\. It can take longer to do something with which you are unfamiliar (jack of all trades, master of none) **Devs Specialize** **Pros**   1\. Developers can create policies and procedures for their area of expertise and more easily enforce them   2\. Developers have more of a chance to become deeply knowledgeable about their specific area and make it the best it can be   3\. Other developers don't cross boundaries and degrade another area   **Cons**   1\. As one colleague put it: "Why would you want to pigeon-hole yourself like that?" (Meaning some developers won't get a chance to work in certain areas.) It's easy to say how wonderful agile is, and that we should do it all, but I'm somewhat of a fan of having areas of expertise. Without that expertise, I've seen code degrade, database schemas become difficult to manage, hack UI code, etc... Let's face it, some people make careers out of doing just UI work, or just database work. It's not that easy to just fill in and do as good of a job as an expert in that area.


title: How do you get into the habit of using a repository (e.g. GitHub)?

text: Are there some best practices on the repository front, or some common newcomer-traps that I should avoid? I have recently been reading about the benefits of repositories even for single-developer projects and, in addition, I am likely to start working with multiple other engineers in a short while but, how do I go from never having used a repository to setting one up - for multiple people, even! **Background:** I am an electronics engineer before anything else, and while application programming has been part of that, it's never been something I've done a lot of - it has mainly been snippets of C for embedded systems where I was the only person working on it.


title: Trying to understand the 2N lnN compares for quicksort

text: I was going through the analysis of quicksort in Sedgewick's Algorithms book. He creates the following recurrence relation for number of compares in quicksort while sorting an array of N distinct items. ![enter image description here](http://i.stack.imgur.com/6g8bm.jpg) I am having a tough time understanding this... I know it takes 1/N probability for any element to become the pivot and that if k becomes the pivot, then the left sub-array will have k-1 elements and right sub-array will have N-k elements. 1.How does the cost of partitioning become N+1 ? Does it take N+1 compares to do the partitioning? 2.Sedgewick says, for each value of k, if you add those up, the probability that the partitioning element is k + the cost for the two sub-arrays you get the above equation.   * Can someone explain this so that those with less math knowledge (me) can understand?   * Specifically how do you get the second term in the equation?    * What exactly does that term stand for?


title: How to design a composite pattern in Python?

text: # The concept I'm programming an interface over pygame as a personal project, to make the creation of games easier for me. So far I managed to design an architecture that behaves like this :   * Objects are displayable components that can appear and move on the screen   * Objects can have children objects   * When an object displays itself, it ask all his children to display themselves on the parent's surface.   * Objects have three important elements : a callback system, a graphics system and a physics system to respectively act, display and move. Then, when I want to create a game "scene", I create a "root" object that contains other objects like the player, the mouse, the ground, monsters... Then I just have to ask the root to display itself, and every object appears recursively. I designed this without knowing about the composite pattern at first, only the basics of OOP. My main issue was to make the substitutability property of objects that comes from inheritance to work well with the recursive composition I made. I mean that I have an "abstract" class called "Object" (I put abstract into quotes because Python doesn't really have such concept) that is inherited by classes like "Image" (to be able to display) or "MovingObject" (to be able to move). Here, inheritance is meant to extend my object abilities. But my composite pattern requires that "groups of objects must be considered the same as single objects". So when I call recursively a method from an object, it calls that method from every child of the object, regardless of the fact that some of them may not have that method. # Example For instance, let's use this root element :   * root (Image)      * player (MovingObject)     * cloud (MovingObject)     * background (Image)     * sun (Image) Now let's suppose we want to call the method `move()` on the root element, to make every child move : First, we cannot because root is an Image instance, so it doesn't know the `move()` method. But even if it was the case, the children "background" and "sun" would not know it. So I decided to put an empty method `move()` inside my "abstract" Object class, so every object knows it, even if it doesn't do anything. The issue is that my Object class is now containing empty methods that it doesn't understand nor needs, only to permit the recursive behavior. # Possible solution Then I heard about all the "inheritance vs composition" fuss and one of the solutions that came to my mind was to stop using inheritance for Object abilities and use composition instead. That means I would create, for example, a "Body" class, an "Image" class and a "Callback" class that would represent different actions, and then plug these into an Object instance to "equip" it and give it more power. But then I thought that this will barely change something because I will have to call `move()`, and then the object will check if it has the Body plug-in, and use it. But it still requires the `move()` method to be present inside the Object class. # Questions So I'm turning to you guys to gave me advices about my pattern :   * Did I understand well how the composite pattern works ?   * Is my approach correct ?   * Does the use of "plug-in" classes will help me ?   * Is the recursive behavior a good idea ?   * Is there other patterns that are more fitting to my needs ? I hope you can give me some hints!


title: Making a business case for a future proof Silverlight application

text: I have recently started working for a pretty big bank writing internal apps. I am being subcontracted out by the company I work for (who I have also recently started working for). This bank **has recently** upgraded to Windows XP, they previously used Windows 2000. I have been tasked with re-writing a report viewing application, which I am currently doing in MVC4 (Windows XP == Visual Studio 2010). The original app was written in .net 2 with webfoms, and is a bit of a mess. The whole application seems to rely on state, where MVC is all about embracing the stateless nature of the web, as in the data you input to form A, affects the options you see in form B, options you select in form B affect form C etc etc (I love MVC and think that it is an awesome thing in the right context). The whole maintaining models between states thing is starting to get pretty messy, and I can't help but thinking that I am either doing it wrong, or not using the right tool for the job. My thoughts are that WPF would be perfect for this but the Computers are controlled by an external agency and are pretty locked down. We have slightly more control over the servers hosting the applications. The obvious next option is Silverlight(I think, maybe I'm horribly wrong!) A couple of questions. First: Is MVC ASP actually the best option here, or am I doing it wrong? Second: What argument would you present to management if you agreed with me and thought a Silverlight based application was the way to go? Using non MS based technologies is a no go. MVC4 is controversial.


title: Can I turn off Visual Studio white space at bottom of code files?

text: In any open file within Visual Studio, there is the ability to scroll all of the code out of sight". In other words, there is heaps of white space below the code lines that one can scroll to. This to me is of no use, and when I pull my mouse wheel down with aggression, my code disappears off the screen. Is there a way to turn this annoyance off? Also, can someone explain to me any logical reason as to why it's even there? ps: I tagged this question as visual-studio since I'm pretty sure it's been in every version of VS that I've ever used... though I'm currently using visual- studio-2010 ![This space is completely useless](http://i.stack.imgur.com/HKsUI.png) ![Now it's even worse because I scrolled to the bottom \(note the line #46\)](http://i.stack.imgur.com/QPfVf.png) ## EDIT Jon Galloway pointed me to another thread stating that it was added by popular request. Still makes no sense why they wouldn't make it a switchable feature on/off