Is it appropriate to use inheritance to prevent code duplication of the logic for a user control?

Suppose I have two or more `UserControl` implementations with vastly different implementations but near identical code-behind. One strategy to avoid code duplication is as follows:   1. Change each `UserControl` to inherit from a new abstract class, `AwesomeUserControl`   2. Move all of the codebehind from each `UserControl` into `AwesomeUserControl` (`AwesomeUserControl` does not have an ascx file).   3. Add abstract getters to `AwesomeUserControl` for any controls from the ascx file of the original UserControls.   4. Implement these getters in each `UserControl`. This strategy works extremely well and is easy to maintain. However, it also introduces stupid scaffolding code; every new implementation of `AwesomeUserControl` has a bunch of getters to hook `AwesomeUserControl` the UI elements inside of the new control. Any time I find myself using a strategy which _requires_ copy-pasted scaffolding code, I worry that I am doing something wrong. Though it does have a nice effect of failing to compile if the UI elements are missing (as opposed to skipping the scaffolding code in favor of reflection and required naming). Is this use of inheritance reasonable?


What's the algorithm of "Shuffle Mode" in audio/music players

I was researching on how is the "Shuffle mode" in music players implemented and what is the algorithm behind this. How it makes sure that any songs won't repeat? What's the most efficient algorithm for doing this?   * **Added on 2014-Apr-23:** The Fischer-Yates Shuffle Algorithm is the simplest algorithm for Shuffling. This blogpost titled "The Art of Shuffling Music" explains another algorithm with illustrations.


What is the most efficient way to manage large collection

I have a rather difficult problem: I periodically receive a `Dictionary<decimal, int> subDict` containing 100 records where   * decimal is a Price   * and int is Amount The outcome I need is a dataGrid showing prices with amounts. But I cannot display subList directly, because sublist is often missing some prices: subDict:   * Price | Amount   * 100.0001 | 192   * 100.0005 | 123   * 100.0007 | 2   * 100.0008 | 123 above needs to be displayed as:   * Price | Amount   * 100.0001 | 192   * 100.0002 | 0   * 100.0003 | 0   * 100.0004 | 123   * 100.0005 | 0   * 100.0006 | 0   * 100.0007 | 2   * 100.0008 | 123 I have to store a price with 4 decimal places, however the range of Price can be anything from 0 to 10 000. Final requirement is - once I click on the amount in the DataGrid, I need to be able to get access to all values in the row. So I decided to ask for some help - can anyone think of a good strategy of dealing with such a problem? One idea that came to my mind would be to initialize `Dicionary<decimal, int> bigDictionary` containing every price in the range. However, if I initialize this dictionary with all the prices, with specified granularity (i.e. step of 0.0001) I end up with 10 000 * 10 000 records. That is rather large list, which takes considerable amount of memory. Of course it is easy to bind it to DataGrid in WPF so this can sort of work, but is in my opinion very inefficient. The other idea I have would be to save incoming prices to a `Dictionary<decimal, int> smallDict` but then I would need to have some sort of mechanism to update DataGrid in such a way, that price gaps would be filled on the fly. Also I would somehow need to keep the dataGrid sorted by the price. The first idea I am able to implement. The second one, I have no idea about so any code would be excellent. I would be greatfull for any ideas! Thank you for your time


Do accompanying tools/scripts also need to be licensed to put my bash script under GPLv3?

This is some sort of follow up to an older question of me. So I put the GPLv3 license into the project which contains my script and also added the copyright notice and copying permission statement to the top of my script. Now, apart from the script, the package also contains files which are helpful for using the script (e.g. a bash completion file and unit tests) but which are not relevant for the script to actually work. Do I also need to put copyright notice/permission in there? I've looked into some projects on github, and most don't seem to add these information to accompanying things. Still, I'm unsure what's the best approach.


How to detect impacts caused by changes?

I've often run on this problem. Now I am working on a team of 4 and we built a lot of stuff. We are still finishing somethings and making **changes**. The problem is that those changes can (and most probably will) cause interface/business to crash. We do not have any kind of map that show us something like "If you change the DataSource of this table the code X on that table will have to change. And on the screen X the list will have to be changed". Unit tests can help validate business rules, what about interface business? Can it also validate code bound to the interface? Should we rely only on unit tests? And how deep does it have to be to prevent the code breaking because of changes? Should we use some other approach as well?


Git workflow / practices for a small project (flowchart in png)

I'm trying to come up with a personal workflow. I've put together a flowchart of the hypothetical lifespan of a release: one developer pushing to a public github repo + a friend helping with some feature and fixing a bug. Is this a reasonable approach to version control? The main idea is to keep the public repo tidy:   * Each new release gets on its own branch until it's finally tagged in the master branch when it's finished.   * All work is done on "feature" or "hotfix" branches, never on an actual release branch, to prevent anomalies.    * Merges to higher-level branches are always rebased or squashed (to avoid clutter).  If it's overkill I don't mind because the whole point is for me is to learn skills I might need for a larger project. The only problem would be if I'm doing something flat out wrong or unnecessary. **edit 2:** fixed bad idea in the original flowchart and made it a bit easier to navigate. ![v1.1](http://i.stack.imgur.com/kxOIy.jpg)


Is Object Oriented Programming a solution to complexity?

Do you think Object Oriented Programming is a solution to complexity. Why? This topic may be a bit controversial but my intentions to know the answer of Why from the experts here !


Class design for internationalized object

I'm looking for some pointers on class design for a global application. Let's say I have to make a class structure to manage products, and the products are sold in different countries. Some of the fields for the product will have the same value across all countries (eg. product code, ERP Description) I will call these "international" fields, and some fields will be specific to a single country (eg. Local Description), lets call these "local" fields. Of course, some "local" fields will be the same for groups of countries (es. weight : 1 kilogram / 2 pounds). Also I expect that not all countries will have values for all fields. Which fields are "international" and which fields are "local" may change from one installation to another and I am reluctant to bake this into the design as I'm sure it will bite me later on. So, I'm trying to figure out how to structure the objects so that I can use a product at an international level and always refer to the same "product", but also maintain and use the local information when necessary? Just to be clear, I'm not talking about user-locale, number or date formatting etc. The source data is coming from different database schemas (one for each country). The end product will be written in C#. I'm wondering if anyone has experience or can point me to a pattern that would provide a good solution to this before I go and reinvent the wheel?


S-expressions readability

In a nutshell and for those who didn't know it, Lisp functions/operators/constructs are all uniformly called like this:               (function arg0 arg1 ... argN)      So what in a C-like language you would express as               if (a > b && foo(param))      is transformed to a Lisp sexp like               (if (and (> a b) (foo param)))      . As things get more real/complicated, so do their corresponding s-expressions, for me. I'm aware that this is most likely a subjective question, but - is for many Lisp hackers this one little annoyance one will have to always deal with? Or does one mostly get used to this (lack of) syntax sooner or later? In any case, is adding breaklines (that you wouldn't add in your C equivalent, most times) for readability a good idea, especially on the long run? Any other suggestions would be welcome.


Best permissive license for a utility library?

I have a small utility library of useful stuff written in Java that I plan on releasing open source. I've been wavering on what license to use. I quite like the BSD license, which is short and easy to understand, but I don't want/need the clause about including the disclaimer in their product's documentation. Considering just dropping that bit out. Would the MIT license suit me better, then? It doesn't have the endorsement prohibition clause like the BSD one does, which is something I like about BSD's. Also, does MIT's clause about keeping the copyright notice on substantial portions of the software just refer to the source code, and not binary form or any documentation they produce? From surveying other SO questions on the topic, I've seen a few people recommend the Apache license. Having a quick scan though it, it actually might do most of what I want really well, although even that amount of legalese makes my head hurt (particularly at 2:30AM when I should be in bed instead of on SO.) Thoughts? Basically I want something that is:   * easy to understand,   * says you can use the code as you like, but keep my copyright and permission notice on the source code,   * you don't need to put the name of me or my product or copyright notice etc. in any documentation, manuals, etc. that you produce,   * don't try and use me or my product as a selling point for your product (not that my endorsement would count for much anyway!)   * and covers my butt in a reasonable manner. :-) EDIT: Wow, 30 minutes and already some good responses! In response: I'd prefer not to "mix and match" if I can help it, and produce yet another open source license. Using a standard license makes it easier for all of us. The butt covering comment is a bit tongue in cheek. The warranty disclaimer that all the licenses mentioned include is really all I'm talking about. EDIT: Reading through the Wikipedia page on the MIT License, I discovered that ncurses uses a modified version that has been approved by the FSF, that adds a non-endorsement paragraph. I figure if it is good enough for them, it is good enough for me. I was considering the Apache license, however compatibility problems with GPLv2 would be an issue I didn't want to introduce.


Is the book "Structure and Interpretation of Computer Programs" a good read for Java programmers?

This may be subjective and likely to be closed but I still wanted to know if its really helpfull to read Structure and Interpretation of Computer programs. Structure and Interpretation of Computer Programs The book does not use Java. Not that I wanted to learn Java. I am just curious as to know if it be will useful read to be a better programmer and what are the things that I can gain from the book or are their any other alternatives to this book more suited to Java programmers?


Is it good style to store view data inside the model?

I'm using a variant of the MVC pattern. In my GUI code, often the need arises to synchronize "view data" (e.g., selected item) between different views. For example, let's imagine a vector drawing program. We have two views: the image, and a listview of all objects (rectangles, squares, ...). The currently selected item should remain in sync - if you click on "Rectangle A" in the listview, the same rectangle should be highlighted in the image view. The way I usually do it is to have a ViewState class contained in my model. Is that a good idea? If not, what would be a better solution?               class VectorDrawing     {       List<Object> Items;       DrawingViewstate Viewstate;     }     class DrawingViewstate     {       Object SelectedItem;       event SelectedItemChanged;     }     class ListviewController     {       ListviewController(VectorDrawing model)       {         model.Viewstate.SelectedItemChanged += ... // Subscribe to event         ...       }     }     class ImageViewController     {       ... // similar to the ListviewController     }


implement cons function in Java - type safety question

I am working on a small functional library written in Java, which mimics the a functional style of programming. I am stuck with a undesirable type cast in one of my method definitions and would love some help. Ok, so we do not have first class functions in Java, so I define them as objects, with one method 'apply()' like so:               public abstract class Function2<R,T1,T2> {         public abstract R apply(final T1 paramOne, final T2 paramTwo);     }      I then define my cons method as a Function2 object, which I can pass around like I would a function in another language that supports it:               public static <T> Function2<List<T>, T, List<T>> cons(){         return new Function2<List<T>, T, List<T>>(){             @Override             public List<T> apply(T x, List<T> xs) {                 return new NonEmptyList<T>(x, xs);             }           };         }      I have omitted my list structure for brevity; assume it is a functional style list data structure with all the usual head/tail/etc. operations. I then want to implement a function like 'reverse', which returns a list of items in reverse order. I use foldl1 (fold a non empty list from the left) to achieve this, and pass the cons function as a parameter to foldl1 like so:               public static <T> List<T> foldl( Function2<List<T>, T, List<T>> f,                                      List<T> acc,                                      List<T> xs ){         if(xs.isEmpty()){ return acc; }         return foldl(f, (f.apply(xs.head(), acc)), xs.tail());     }              public static <T> List<T> reverse(List<T> xs){         // how do I avoid this cast??         return foldl( (Function2) cons(), new EmptyList(), xs);      }       But when I pass my 'cons()' object in 'reverse', I need to cast it as a Function2, and I have no idea how to avoid doing this. I have tried all manner of messing around with types...I feel this is simply a lack of experience on my part with the Java type system...anyone? PS. I am aware of other functional libraries in Java, I just wanted to do my own small one as a learning experience. EDIT - OK, so I am using a regular 'foldl' now to get back a List, but I still have to perform the cast? The return type of 'cons' align with 'foldl'...


Explaining Drupal to a Programmer

(Apologies in advance for the vague and miasmic question) Is there a book, or other resource, there that can explain **using** Drupal, The System, to a web app oriented programmer? I've read through the Apress Pro Drupal Development book and it was a fantastic overview of the system's architecture. That's not what I'm looking for here. Instead I want something that's going to tell/show me "Here is how people use Drupal to manage their sites and build applications". I've been building websites and web applications since the beginning, and whenever I sit down to spend some time with Drupal I find I can't leave behind my concepts of   1. A URL equal one HTML page, and everything flows from there   2. A URL equals a controller action, and everything flows from there and Drupal seems to be built on an entirerly different model. So any books, tutorials, or explanations that start from the above two points and explain how Drupal is different, and what Drupal developers spend their days doing would be fantastic.


How extensive is the difference between building a WPF app and a Silverlight 5 app?

I have a fair amount of experience with WPF (C#) and XAML. I might soon be asked to create a Silverlight 5 application. I have no experience with any version of SL. What sort of learning curve could I expect in creating a SL 5 app, given that I have some experience with WPF?


Is my mediator layer a sensible way to manage this scenario using the Single Responsibility Principle?

I'm not sure how to start to explain my question, but here goes. We have just finished an MVC application that hits 2 WCF services. But there has been a bit of a disagreement between those who worked on the project and some who haven't over the design used. What we have is two WCF services, one on each site (site specific data) and another at head office (data shared/common between all sites). Normally we would have two apps, one for site and another for head office. In this case I decided from a UX point of view that it would be better to have it look like one app from the users point of view so they would not need know two urls. Basically, the user does not know if they are hitting site or head office. Now comes the design decision that has caused the disagreements. The MVC App has controllers that need to hit either a site wcf service or a head office WCF service. So to prevent the need of the controllers needing to be aware of the two WCF communications layers and converting the WCF results into a model the controllers could use, I created a layer in between the controllers and WCF Proxies. Which accepts a request from a controller, then calls the appropriate site or central WCF proxy call, then if needed, convert the WCF result into a model that the controller can use. This layer, I called a Mediator, but after much discussion, I am of the opinion that it is not the correct description for it. Anyway, the reason for this layer is when tring to keep to the SOILD object oriented principles, in particular the Single Responsibility Principal. The controllers responsibility is to handle client requests and return a view/result. It should not need to know or maintain a WCF proxy and convert its result. (It could go directly to a database instead of a WCF call but the controller shouldn't be responsible or even aware of that because it is responsible for the view) The same goes for the WCF proxy, it should not know what is consuming its result and that the WCF data contract should be converted into a model specific for each controller. The mediator layer in between is what decides which WCF service and method to call and then either via a extension method or a specific handler converts the result to a model the controller can use. (sometimes it may take several wcf calls to create the model).               Controller1 -> Mediator -> HeadOfficeWCFProxy     Controller2 -> Mediator -> SiteWCFProxy        * So the controller asks for data (not knowing where it comes from)   * The mediator converts and passes the request to the appropriate WCF Proxy(s)   * The WCF Proxy(s) make the calls across the wire and return the results.    * The mediator then converts the result(s) into a model (if needed) via an extension method and returns it to the controller.    * The controller renders the view using said model. Now what I described here was just on the MVC side. I have a similar setup on the WCF service side but the mediators benefit is clearer. On the head office WCF service               WCFListener -> Mediator -> DataLayer (LinqToSQL)                             -> SiteSyncHandler (sends change to all sites asyncronously)                             -> ThirdPartyContentManagementHandler (via web service)      Now the devs that have worked on the project, like the separation of concerns alot as it is very clear where everything belongs and keeps code to a minimum in each layer. But the down side in the MVC app is for a lot of the calls the mediator just makes a single WCF call and doesn't even need to convert the result (most of the time the data contract is fine for use as a model) resulting in a fair amount of one liner method boiler plate code. The mediator doesn't really add much in that scenario except to keep things consistent across controllers. Some devs that haven't worked on the project, insist that there is no need at all for the Mediator layer and that it could be all handled by the controllers themselves. Which means maintaining the appropriate WCF Proxy in each controller. This in my mind violates the Single Responsibility principle. To which they argue that SOLID is more like a set of guidelines, and not to be blindly followed. Which while I kinda agree with that statement its also not to be blindly ignored. I have conceded that the term mediator is not really appropriate (perhaps director or relay), but I still think the basic design is valid, and would use it again. The same can be said for those who have worked on the project. I would like to know what other people think. Is there a better solution or have I "over complicated it". (I still don't agree that is is complicated, its a very simple concept and easy to maintain)


UML to portray SQL objects

I am delving into the science of UML. The tool I am using is **ArgoUML**. I feel very confident portraying OO designs through this tool. But what still vexes me is the incorporation of the database. What does one do in UML to show table structure? Stored procedures? So on and so forth.


Is it possible to have a mutable type that is not garbage collected?

I'm wondering if such a thing can exist. Can there be an object that is mutable but not flagged as garbage collected ( specifically, tp_flags & Py_TPFLAGS_HAVE_GC ) I have a C++ struct-like object that I'm writing and I'd like to know if all of its members are immutable. I'm thinking of checking for the Py_TPFLAGS_HAVE_GC flag to determine this. If all members are immutable I want to speed up the deepcopy by doing a faster shallow copy, since I know members are immutable then it shouldn't have to go through an expensive deep copy. Is this logically sound, or is there some mythical type that will blow me out of the water here.


What is decoupling and what development areas can it apply to?

I recently noticed decoupling as a topic in a question, and want to know what it is and where it can apply. By "where can it apply", I mean: Is it only relevant where compiled languages like C and Java are involved? Should I know about / study it as a web developer?


Modern.IE VM license

Microsoft provides some VMs for testing purposes (advertised on StackOverflow) and I'm trying to understand the license terms. The one I don't really understand is > 1.b. You may use the software for testing purposes only. You may not use the > software for commercial purposes. My thoughts: a) Testing a website in several browsers on several different virtual machines seems a quite professional approach. I hardly believe many private developers would do that. Of course they should, but which private developer has the time to do so? b) If that's really only available to private developers, what is the offer to companies doing the same thing? I am missing the advertisement for a paid service. My question as a non-native English speaker: Is testing by a company considered as a commercial purpose? Can I use the VMs within a company for testing or not?


Should source-code in textbooks and the like be translated?

A few weeks ago, my class was assigned to translate to Portuguese the book Real World Haskell. As I did the translation of the text and comments, I started to wonder if I should translate the code as well, as the instructor suggested. For example:               data BookInfo = Book Int String [String]                   deriving Show would become               data InfoLivro = Livro Int String [String]                    deriving Show Since I haven't read any software-related books in Portuguese, I don't know if that's a common practice, neither if it should be done this way. In the end, the code is a language mix (perhaps the example in Haskell is not a good one, since you can create synonyms quickly like `type CadeiaDeCaracteres = String`, but you get the point). So it doesn't really matter how hard you try, you'll have to rely on the reader previous experience with some sort of basic English words. Knowing this, I really don't see the point in translating code, since we learn in the early days of our coding life it should be written in the universal language. Nevertheless, if the surrounding text (comments, for example, and text itself in a book) needs to be translated, what is possible and feasible in this matter? Can you provide me with some guidance of what to do?


Should I tell a departed coworker about their "sev 1" defect?

I had a co-worker leave our company recently. Before leaving, he coded a component that had a severe memory leak that caused a production outage (`OutOfMemoryError` in Java). The problem was essentially a `HashMap` that grew and never removed entries, and the solution was to replace the `HashMap` with a cache implementation. From a professional standpoint, I feel that I should let him know about the defect so he can learn from the error. On the other hand, once people leave a company, they often don't want to hear about legacy projects that they have left behind for bigger and better things. What is the general protocol for this sort of situation?


Emacs stops taking input when a file has changed on disk

I'm using Emacs v24.3.1 on Windows 8. I had a file change on disk while I had an Emacs buffer open with that file. As soon as I attempt to make a change to the buffer, a message appears in the minibuffer.               Fileblah.txt changed on disk; really edit the buffer? (y, n, r or C-h)       I would expect to be able to hit `r` to have it reload the disk version of the file, but nothing happens. Emacs completely stops responding to input. None of the listed keys work, nor do any other keys as far as I can tell. I can't `C-g` out of the minibuffer. `Alt-F4` doesn't work, not does `Close window` from the task bar. I have to kill the process from task manager. Anyone have any idea what I'm doing wrong here? In cases it's various modes not playing nice with each other, for reference, my init.el is here. Nothing complex. Here's the breakdown:   * better-defaults (ido-mode, remove menu-bar, uniquify buffer `forward, saveplace)   * recentf-mode   * custom frame title   * visual-line-mode   * require final newline and delete trailing whitespace on save   * Markdown mode with auto-mode-alist   * Flyspell with Aspell backend   * Powershell mode with auto-mode-alist   * Ruby auto-mode-alist   * Puppet mode with auto-mode-alist   * Feature (Gherkin) mode with auto-mode-alist The specific file was a markdown file with Github-flavored Markdown mode and Flyspell mode enabled.


When is an object oriented program truly object oriented?

Let me try to explain what I mean: Say, I present a list of objects and I need to get back a selected object by a user. The following are the classes I can think of right now:               ListViewer          Item          App [Calling class]      In case of a GUI application, usually click on a particular item is selection of the item and in case of a command line, some input, say an integer representing that item. Let us go with command line application here. A function lists all the items and waits for the choice of object, an integer. So here, I get the choice, is choice going to conceived as an object? And based on the choice, return back the object in the list. Does writing this program like the way explained above make it truly object oriented? If yes, how? If not, why? Or is the question itself wrong and I shouldn't be thinking along those lines?


multitenancy with some data sharing

I'm in the planning stages of a new webapp, and I am leaning strongly toward a multitenancy model. The app has a file storage function, where the user can upload (and operate on) files. I would like the ability of the user to share these files, however. How is this typically accomplished in a multi-tenant model? The example would be something like google docs. Each user has their own files; they can edit and tag and build collections with these files. Then, they can share a doc or a collection with someone else for collaboration. If every user has their own Database and tables, what strategy would one use to allow this kind of sharing while minimizing duplication of files and associated metadata?


Should I use Ruby version 1.8.7 or 1.9.2 to start developing Rails apps?

I'm diving into RoR and I see that the current version of Rails (3.0.5) works with both 1.8.7 and 1.9.2. Currently, I have both versions of Ruby installed using RVM, but I'm wondering which version I should be using as I dive into Rails and start developing apps. I suppose I'd prefer to use the newest version (1.9.2), but I don't know the technologies well enough to know pros/cons of using either. Thanks so much!


How to use BPMN and use case and other diagrams together

I asked this question on stackoverflow, but it seems this question is not suitable there, so I post here for discussion. BPMN (Business Process Modeling Notations) is used for modeling business process by visualization, thus making intangible ideas become physically concrete through the expression of BPMN diagrams. The question is, **how do I organize the BPMN with the UML**. Initially, I thought of two ways to organize use cases and business process diagram:   * **1 to one/many:** By mapping each step (`step` here means each node in the BPMN digram) in the business process diagram with one or several use cases. Each use case is mapped with relevant several class diagrams/component diagrams (I prefer this one, since you can encapsulate a set of classes into one component which has input and output), several sequence diagrams (optional). After you have class diagrams/sequence diagrams, code is written/generated based on the model.    * **Many to one:** By mapping several steps into one use case. The subsequence steps are the same.   * **Many to many:** For example, one step in the business process can be mapped with two or more use cases, and the same two or more use cases can be mapped with other steps. The above methods can be done by the modeling tool, and in my case, I use Enterprise Architect from Sparx System. I discover it recently and I am using its trial, but I will buy it in the future. I can organize many use case diagrams with one step of the BPMN diagram, and can click to view the necessary use cases. However, I don't if it supports many to many cases. After thinking my own method for organizing BPMN and Use Cases, I searched the Internet, and found two other papers, each suggest the following method:   * **Turn each use case into each step of BPMN diagrams:** To visualize how refined use cases fit into the business process. I like this approach, since the business process with steps can be modeled, and later each step is turned into a use case. One step is one use case. This is the same with my one to one mapping above. Original presentation is here: Visualizing Use Case Sets as BPMN Processes ![Use case - BPMN mapping](http://i.stack.imgur.com/uxPpf.png)   * **Each use case is exactly a business process:** Each step in the use case is each step of the business process. Original paper is here: Describing Business Processes with Use Cases ![Use case is a process](http://i.stack.imgur.com/jpYVW.png) It seems to me that there's not standardized way of gluing these artifacts (BPMN and Use Cases and other digrams) together. Maybe it's a management problem and rely more on creative usage rather than follow a formal steps. **What are the usage of these diagrams together?**


What is the genesis of the "Golden Master" term?

The name "Golden Master" evokes a level of martial arts proficiency or maybe even a final cut of a film. I think context clues provide adequate explanation of a Golden Master release. I would define it as the version of a software [product] that has been approved as the release version following a pre- determined phase of development completion and testing. If my definition is nearly accurate, what is the genesis of the term Golden Master? Apple is famous for their iOs, OSX GM candidate releases and I have yet to hear anyone else use the same term.


Why should I declare a class as an abstract class?

I know the syntax, rules applied to abstract class and I want know usage of an abstract class > Abstract class can not be instantiated directly but can be extended by other > class What is the advantage of doing so? How it is different from an Interface? I know that one class can implement multiple interfaces but can only extend one abstract class. Is that only difference between an interface and an abstract class? I am aware about usage of an Interface. I have learned that from Event delegation model of AWT in Java. **In which situations I should declare class as an abstract class? What is benefits of that?**


Can an agile shop really score 12 on the Joel Test?

I really like the Joel test, use it myself, and encourage my staff and interviewees to consider it carefully. However I don't think I can ever score more than 9 because a few points seem to contradict the Agile Manifesto, XP and TDD, which are the bedrocks of my world. Specifically: the questions about schedule, specs, testers and quiet working conditions run counter to what we are trying to create and the values that we have adopted in being genuinely agile. So my question is whether it possible for a true Agile shop to score 12? **Edit:** On recommendation from an answerer below I am adding a link to my blog where I originally wrote about this and which led to me wanting to post the question here. http://simonpalmer.com/2011/03/16/why-i-will-never-score-more-than-9-on-the- joel-test/ I'm putting this in because I agree with much of what has been said below and I wanted to declare my full position.


Should a github maintainer rewrite author's in pull requests?

I'm not a programmer by profession, but I do some coding and have used github some. I've run across what I find to be a surprising situation. I'm very familiar with git. There is a project which I found a (small) bug in that was affecting me. I spent an afternoon finding and fixing it. I forked the repository, commit the change, and issued a pull request. After seeing that it was closed as "Merged into development branch" I figured all was well. I was browsing the repo today getting ready to remove my branch, and I can't find where the commit was merged into the maintainer's repo at all. After some time I realize it's been added as a commit, but the author is no longer me. As far as I can tell the only way to do that would be to specifically use a rebase, amend, or other history rewrite to remove the original author. This seems very wrong to me. At best it's confusing, at worst the author of this repo is taking credit for everyone's commits and then the history of the original contributor is lost. Again it's a small bug, I don't use this for my professional resume, it just seems dishonest. Is this normal? Should I say something about it? Edit: The general feeling seems to be that I should go ask, so I'll do just that this morning. As per the request below. I've checked and my code exists and was applied exactaly as I wrote it (including the comment). I verified that both the committer and author have been changed. There was one additional change also added at the same time as my changes. It's a single line, which would affect the patch as well as other code before it. IE the one line addition is not related to the bug I was fixing. **Update** It seems the answer was that the author maintains a development branch and does not want to merge from his master branch into it. He re- authored my commit to avoid a merge. I wasn't concerned with the original branch b/c git's plenty powerful to cherry-pick, rebase, and merge commits around as needed. Is this typical on github?   Should I be contacting the maintainer of a project to ask which branch to apply patches to?


I want to start using TDD. Any tips for a beginner?

I never used an automated test mechanism in any of my projects and I feel I'm missing a lot. I want to improve myself, so I have to start tackling some issues I've been neglecting like this and trying Git instead of being stuck on SVN. What's a good way to learn TDD? I'll probably be using Eclipse to program in Java. I've heard of JUnit, but I don't know if there's anything else I should consider.


I'm scared for my technical phone interview for an internship!

[EDIT 2.0 ]Hello everyone. This is my second phone interview for a development internship. My very first one was okay, but I didn't get my dream internship. Now, I'm facing fears about this upcoming interview. My fears include the following:   1. I'm 19 years old. The thought of 2 lead developers interviewing me makes me think that I'll know so little of what they'd want me to know. Like they will expect so much.   2. I'm a junior having these panic attacks that I did not get in the other internship. I have a little voice saying "You didn't get the other one. What makes you think you'll get this one?".   3. I'm scared that I'll freeze up, forget everything I know, and stutter like an idiot. I'm still traumatized by the last one, because I really really wanted that internship, and I even studied very hard for it. When I was in the interview, I was so nervous I couldn't think clearly. As a result, I didn't do as well as I know I could have. The minute I hung up, I even thought of a better solution to the interview question! Any tips for a soon-to-be intern (hopefully!)? Thank you! P.S. I'm preparing by using this guide for phone interviews.


Visual Studio c++ Windows forms?

I've been slacking off with learning how to program because I'm at my wits end trying to figure out the next step. I want to be able to create forms applications just to test random things and give myself the freedom I feel I have with javascript, which is why I learned it and am as comfortable with it as I am. I have no clue, however, what to do in Visual C++. I'm staring at an ugly, gray, blank form right now and have no clue what to click or what to write. I don't know how to find any tutorials either, as it's quite a specific request (c++, visual basic, windows forms). Does anyone have any advice for me? thanks


What is ethical/unethical while seeking help on the web with programming assignments?

I have used the web and Stack Overflow extensively during the past month or so in creating my final project for my C# class. I have used so much code that I didn't write myself that I feel I am being unethical by not giving proper credit to the people who helped me; or the websites that have provided excellent examples. Is it unethical to publish work which was created by me, even though its hardest problems were solved by other people? Should I credit these people for helping me with my assignment? Or the web sites which provided examples?


Programming Interview : How to debug a program?

I was recently asked the following question in an interview : > How do you debug a C++ program ? I started by explaining that programs may have syntax and semantic errors. Compiler reports the syntax errors which can be corrected. For semantic errors, various debuggers are available. I specifically talked about gdb, which is command line, and Visual Studio IDE's debugger, which has a GUI, and common commands. I also talked about debug and release version of code, how assertions should be used for debug build, how exceptions helps in automatic cleanup & putting the program in valid state, and how logging can be useful (e.g. using std::clog). I want to know if this answer is complete or not. Also, I want to hear how other people will go about answering this question in a structured manner ? Thanks.


Automatic static analysis vs White box testing

Many sources note that automatic static code analysis include data flow and control flow. But these two are included in white box testing as well. Is there a difference in the automation? That in automatic static analysis all is done by the tools while in white box testing, a person creates the data to exercise the possible paths?


How do I stop designing and start architecting this project as suggested by my lead?

I'm a junior developer (~3 years' exp.) and at my job we're in the process of architecting a new system. My lead developer will be the principal architect, however he's challenged me to try architecting the system myself (in parallel). Over the course of a few iterations of brainstorming ideas and proposing what I saw as architecture suggestions, my lead has given me the feedback that most of what I've been doing was "designing" and not "architecting". He described the difference as architecture being implementation-agnostic whereas a design is the description of an implementation. He said I need to take off my designer hat and put on my architect hat. He gave me a little bit of advice on how to do so, but I would like to ask you as well: **How do I get out of software designer mode and start thinking more like an architect?** * * * Here are some **examples** of "designs" I came up with that weren't seen as relevant to the architecture by my lead:   1. I came up with an algorithm for loading and unloading resources from our system and my lead said that algorithms are categorically not architecture.   2. I came up with a set of events the system should be raising and in what order it should raise them, but this too didn't seem to cut it as architecture. I seem to be getting caught up in the details and not stepping back far enough. I find that even when I come up with something that is at an architecture level, I often got there by trying out various implementations and mucking around in the details then generalizing and abstracting. When I described this to my lead, he said that I was taking the wrong approach: I needed to be thinking "top down" and not "bottom up". * * * Here are some more **specific details about the project** :   * The project we're architecting is a web application.   * I'm estimating around 10-100 thousand lines of code.   * We're a start up. Our engineering team is about 3-5 people.   * The closest thing I could compare our application to is a lightweight CMS. It has similar complexity and deals largely with component loading and unloading, layout management, and plug-in style modules.   * The application is ajax-y. The user downloads the client once then requests data as it needs it from the server.   * We will be using the MVC pattern.   * The application will have authentication.   * We aren't very concerned about old browser support (whew!), so we're looking to leverage the latest and greatest that is out there and will be coming out. (HTML5, CSS3, WebGL?, Media Source Extensions, and more!)  * * * Here are some **goals of the project** :   * The application needs to scale. In the near term our users will be on the order of hundreds to thousands, but we're planning for tens of thousands to millions and beyond.   * We hope the application will be around forever. This isn't a temporary solution. (Actually we already have a temporary solution, and what we're architecting is the long-term replacement for what we have).   * The application should be secure as it may have contact with sensitive personal information.   * The application needs to be stable. (Ideally, it'd be stable around the level of gmail but it doesn't need to be at the extreme of a Mars rover.)


Dealing with "I-am-cool-and-you-are-dumb" manager

I have been working with a software company for about 6 months now. I like the projects I work on there and I really like all the people there except for 1 guy. That guy is technically smart, and he is a co-founder of the company. He is an okay guy in person (the kind you wouldn't want to care about much) but things get tricky when he is your manager. In general I am all okay but there are times when I feel I am not being treated fairly:   * He doesn't give much thought to when he makes mistakes and when I do something similar, he is super critical. Recently he went as far as to say "I am not sure if I can trust you with this feature". The detais of this specific case are this: I was working on this feature, and I was already a couple of hours over my normal working hours, and then I decided to stop and continue tomorrow. We use git, and I like to commit changes locally and only push when I feel they are ready. This manager insists that I push all the changes to the central repo (in case my hard drive crashes). So I push the change, and the ticket is marked as "to be tested". Next day I come in, he sits next to me and starts complaining and says that I posted above. I really didn't know what to say, I tried to explain to him that the ticket is still being worked upon but he didn't seem to listen.   * He interrupts me in-between when I am coding, which I do not mind, but when I do that same, his face turns like this :| and reacts as if his work was super important and I am just wasting his time. He asks me to accumulate all questions, and then ask him altogether which is not always possible, as you need a clarification before you can continue on a feature implementation. And when I am coding, he talks on the phone with his customers next to me (when he can go to the meeting room with his laptop) and doesn't care.   * He made me switch to a whole new IDE (from Netbeans to a commercial IDE costing a lot of money) for a really tiny feature (which I later found out was in Netbeans as well!). I didn't make a big deal out of it as I am equally comfortable working with this new IDE, but I couldn't get the science behind his obsession. He said this feature makes sure that if any method is updated by a programmer, the IDE will turn the method name to red in places where it is used. I told him that I do not have a problem since I always search for method usage in the project and make sure its updated. IDEs even have refactoring features for exactly that, but...   * I recently implemented a feature for a project, and I was happy about it and considering him a senior, I asked him his comments about the implementation quality.. he thought long and hard, made a few funny faces, and when he couldn't find anything, he said "ummm, your program will crash if JS is disabled" - he was wrong, since I had made sure it would work fine with default values even if JS was disabled. I told him that and then he said "oh okay". BUT, the funny thing is, a few days back, he implemented something and I objected with "But that would not run if JS is disabled" and his response was "We don't have to care about people who disable JS" :-/   * Once he asked me to investigate if there was a way to modify a CMS generated menu programmatically by extending the CMS, I did my research and told him that the only was is to inject a menu item using JavaScript / jQuery and his reaction was "ah that's ugly, and hacky, not acceptable" and two days later, I see that feature implemented in the same way as I had suggested. The point is, his reaction was not respectful at all, even if what I proposed was hacky, he should be respectful, that I know what's hacky and if I am suggesting something hacky, there must be a reason for it. There are plenty of other reasons / examples where I feel I am not being treated fairly. I want your advice as to what is it that I am doing wrong and how to deal with such a situation. The other guys in the team are actually very good people, and I do not want to leave the job either (although I could, if I want to). All I want is respect and equal treatment. I have thought about talking to this guy in a face to face meeting, but that worries me that his attitude might get worse and make things more difficult for me (since he doesn't seem to be the guy who thinks he can be wrong too). I am also considering talking to the other co-founder but I am not sure how he will take it (as both founders have been friends forever). Thanks for reading the long message, I really appreciate your help.


What kind of interface should a double container offer?

I want to write a class which offers two sequences of elements to its users. The first one (lets call it "primary") is the main of the class and will be use 80% of the time. The second one (lets call it "secondary") is less important, but still need to be in the same class. The question is: what interface should the class offer to its users? By looking at STL style, a class with a single sequence of elements should offer begin() and end() functions for traversal and function like insert() and erase() for modifications. But how should my class offer the second sequence? For now, I have two ideas:   * Expose the two containers to the user (what about the Law of Demeter ?)   * Provide the main container with STL interface and expose only the second one. Here is an example.               #include <vector>          class A {          public:             std::vector<int>&  primary();             std::vector<char>& secondary();              private:             std::vector<int>  m_primary;             std::vector<char> m_secondary;     };          class B {          public:             std::vector<int>::iterator begin();             std::vector<int>::iterator end();             std::vector<char>& secondary();              private:             std::vector<int>  m_primary;             std::vector<char> m_secondary;     };          // Classes implementation     // ...          int main() {              // --------------------------------------------------         // Case 1         // --------------------------------------------------              A a;              for(auto it = a.primary().begin(); it != a.primary().end(); ++it) {             // ...         }            for(auto it = a.secondary().begin(); it != a.secondary().end(); ++it) {             // ...         }                 // --------------------------------------------------         // Case 2         // --------------------------------------------------              B b;              for(auto it = b.begin(); it != b.end(); ++it) {             // ...         }            for(auto it = b.secondary().begin(); it != b.secondary().end(); ++it) {             // ...         }        }      What is the more C++ish way to do that? Is one best than the other or is there an other solution? ## Context This problem came in the context of an exercise in which I am writing a simple database access framework. Here are the classes involved in the question:   * table   * column   * row   * field The table class consists of a sequence of columns and an other sequence of rows. The main use of the table is manipulating (access, add and remove) the rows. Deeper in the hierarchy, a row is made of column and field so a user can ask the value (field) corresponding to a given column or column name. Each time a column is add/modify/remove from the table, every rows will need to be modify to reflect the modification. I want the interface to be simple, extensible and combining well with existing code (like STL or Boost).


Why don't more languages have the ability to compare a value to more than one other value?

Consider the following:               if(a == b or c)      In most languages, this would need to be written as:               if(a == b or a == c)      which is slightly cumbersome and repeats information. I know my above sample syntax is slightly clunky, but I am sure there are better ways to convey the idea. Why don't more languages offer it? Is there performance or syntax issues?


What's the best way to learn image processing?

I'm a senior in college that hasn't done much image processing before (except for some basic image compression on smartphones). I'm starting a research project on machine learning next semester that would require some biomedical image processing. What's the best way to get up to speed with the basics of image processing in about two months? Or is this impractical? It's my impression that once I'm good with the basics learning more from other resources would be easier.


UML Diagram for Locations of Components

I am about to deploy a new project that will have different components being deployed on different servers and in different web sites/technologies/etc. I was just wondering what would be the best way to communicate this with the business? I want to show that Service X will exist on server Y as a Windows Service and Service Z will exist on server Q as a .NET web service etc.


Enforcing coding standards: What are the trade-offs of different methods?

Our team has recently agreed on some very light coding standards, and that we need a means of enforcing them. We already have a mature Continuous Integration practice including frequent, small check-ins and pre-tested commits. We're considering two methods for implementing an enforcement mechanism: a pre-commit SVN hook, or a dedicated build configuration on the CI server. Here's the trade-offs we've considered so far:   * An SVN hook ...      * (-) requires SVN server admin privileges to setup, which we don't have. We can work with IT, but avoiding the overhead is nice.     * (-) points to a script, which we'd like to keep under version control with the rest of the product. I don't immediately know how to point at the correct hook-script, taking into account branches, tags, and trunk work.     * (-) requires more work for reporting. The script would need to handle both generating and publishing the report.     * (+) gives quick feedback.     * (+/-) provides hard enforcement: the code checks-in, or it doesn't . Usually a good thing (it's called "enforcement" for a reason), but may give false positives.   * The CI build configuration ...      * (-) consumes time on both the CI server and an agent. Might be trivial, but does add up.     * (-) introduces some extra latency, making feedback less immediate.     * (+) easily handles standards that evolve over time, by pointing to the version of the script that exists in whichever branch we're working on.     * (+) provides easier reporting. We already use the CI system for other reports. Adding a new one would be straight-forward.     * (+) configurable enforcement: easier to soften the requirements, if necessary. We could collect a list of violations to fix out-of-band, or provide warnings about standards we're adopting on a trial basis. What are the trade-offs of these different methods in enforcing coding standards here? **Related** : Should coding standards be enforced by the CI server? \- Raises some good points, but doesn't consider SVN hooks.


Is it possible to work with distrusting clients

One of our junior developers has been assigned a new client (we don't have the client yet, we're still working with him to see if we can meet his needs) and the junior developer said the client will hire us if we can do the work on his project without getting access to his server. I've had a direct conversation with the client who turned out to have had his code stolen before by some offshore company that he outsourced. This made me more sympathetic but I still have mixed feelings about this. On one hand I want to prove to the client that we're not all bad apples. Also if we do a good job with him, we get a loyal client who'll hire us for all his projects. I haven't heard of this happen before but I guess it happens more often than we'd all like to admit. On the other hand I'm hesitant to accept working with him because deployment time is going to be a nightmare and no where in my career or education has anyone taught me how to work with clients like him. I (or the junior developer) would have to write a detailed description of exactly what to do with the source to deploy it and that is an annoying burden when I could deploy and test the whole thing in an hour myself. As I said, I've never had to deal with this before (we're signing a non- disclosure but apparently so did the offshore company before us). We're not fully fully booked so it's not like I have an immediate replacement, but we're not begging for work either and I wonder if working under such restricted environment is worth the trouble. Another side is that the experience itself could be rewarding for us, but is it experience worth having, as in what's even the likelihood of getting a similar client anytime soon. Are we even expected to comply with such clients? So since I don't have any first hand experience with this and it definitely wasn't covered in school, how would those with longer experience working with clients deal with a distrusting client like this? Would you even accept the job?


Large MySQL Batch Inserts From PHP: Run insert from script, or save as SQL file?

We have a large dataset that's current residing in many, many spreadsheets.   I've been tasked with getting part of that data into our MySQL DB.   When all is said and done, I will probably be inserting somewhere around 3 million rows. I intend to collect the inserts into batches of about a quarter-million or so (parsing through it with PHP).   Initially, my plan was to just run/send those batch INSERTs straight from my script.   More recently, though, I thought about actually writing out the INSERTs to _.sql_ files for later importing. I tried to google around on this a little ... didn't find much.   Are there any real pro's/con's one way or the other?   If not, I'm inclined to stick with my original plan.   Otherwise, I'm completely open to suggestions.


How to build completely modular web applications

In the coming months we're going to begin a project where we take a system we've built for a client (v1) and rebuild it from scratch. Our goal with v2 is to make it modular, so that this specific client will have their own set of modules they use, then another client may use a different set of modules altogether. The trick here is that Company A might have a series of checkout and user modules that change how that system works. Company B might stick with the standard checkout procedure but customize how products are browsed. What are some good approaches to application architecture when you're building an application from scratch that you want to have a `Core` that's shared among all clients while still maintaining the flexability for anything to be modified specifically for a client? I've seen CodeIgniter's hooks and don't think that's a good solution as we could end up with 250 hooks and it's still not flexible enough. What are some other solutions? Ideally we won't need to draw a line in the sand.


Are there any frameworks available for drawing with CSS?

I realize this sounds silly. Let me explain: I just came across this page about using CSS elements to create shapes- square, circle, triangle, star, yin-yang (yin-yang!), etc. using pseudo elements. Having struggled with HTML5 Canvas drawing in the past, I immediately thought that some combination of JavaScript and CSS pseudo-elements should be able to draw just about anything. So I first googled "CSS Fractals". No dice. Then "JS Fractals". Some dice, but not what I was looking for. Am I crazy, or is there potential here? jQuery can add and remove elements from the DOM by the thousands all day long. It seems to me that--given the existence of triangles via pure CSS--there is potential for a nice drawing mechanism (2D and 3D) sans Canvas. Any thoughts, frameworks, tutorials, white papers, etc would be appreciated!


Self-Executing Anonymous Function vs Prototype

In Javascript there are a few clearly prominent techniques for create and manage classes/namespaces in javascript. I am curious what situations warrant using one technique vs. the other. I want to pick one and stick with it moving forward. I write enterprise code that is maintained and shared across multiple teams, and I want to know what is the best practice when writing maintainable javascript ? I tend to prefer Self-Executing Anonymous Functions however I am curious what the community vote is on these techniques. **Prototype :**               function obj()     {     }          obj.prototype.test = function() { alert('Hello?'); };     var obj2 = new obj();     obj2.test();      **Self-Closing Anonymous Function :**               //Self-Executing Anonymous Function      (function( skillet, $, undefined ) {         //Private Property         var isHot = true;              //Public Property         skillet.ingredient = "Bacon Strips";              //Public Method         skillet.fry = function() {             var oliveOil;                  addItem( "\t\n Butter \n\t" );             addItem( oliveOil );             console.log( "Frying " + skillet.ingredient );         };              //Private Method         function addItem( item ) {             if ( item !== undefined ) {                 console.log( "Adding " + $.trim(item) );             }         }          }( window.skillet = window.skillet || {}, jQuery ));        //Public Properties           console.log( skillet.ingredient ); //Bacon Strips            //Public Methods      skillet.fry(); //Adding Butter & Fraying Bacon Strips           //Adding a Public Property      skillet.quantity = "12"; console.log( skillet.quantity ); //12             //Adding New Functionality to the Skillet      (function( skillet, $, undefined ) {         //Private Property         var amountOfGrease = "1 Cup";              //Public Method         skillet.toString = function() {             console.log( skillet.quantity + " " +                           skillet.ingredient + " & " +                           amountOfGrease + " of Grease" );             console.log( isHot ? "Hot" : "Cold" );          };               }( window.skillet = window.skillet || {}, jQuery ));     //end of skillet definition               try {         //12 Bacon Strips & 1 Cup of Grease         skillet.toString(); //Throws Exception      } catch( e ) {         console.log( e.message ); //isHot is not defined     }      I feel that I should mention that the Self-Executing Anonymous Function is the pattern used by the jQuery team. **Update** When I asked this question I didn't truly see the importance of what I was trying to understand. The real issue at hand is whether or not to use new to create instances of your objects or to use patterns which do not require constructors/use of the `new` keyword. I added my own answer, because in my opinion we should make use of patterns which don't use the `new` keyword. For more information please see my answer.


Why exclusively UNIX is taught at universities' operating systems courses?

I'm not sure this question can be asked here, but nevertheless. Almost each operating systems or systems programming course is taught using UNIX only. I wonder what are the reasons for this? Why Windows does not take at least a half of those courses?


Push vs Poll when large delay (hours) is acceptable

It seems commonsense nowadays that polling is a bad practice and pushing is the way to go when developing mobile applications that require to constantly receive data from a remote server. All major mobile shops provide their version of a push notification service:   * Apple Push Notification Service   * Google Cloud Messaging for Android   * Microsoft Push Notification Service However I'm wondering to what extend this assumption is valid. I mean, if I have an application that polls a remote server only a couple of times a day, and to which "notifications" don't need to be delivered instantly (a large delay is acceptable), then would it be a good decision to poll for data instead of pushing it? Thanks in advance!


Tags or specify revision?

At my company, we have your typical svn structure. Each project has branches, tags and trunk.               repo     -Project A      * trunk      * branches      * tags     -Project B      * trunk      * branches      * tags     -Project C      * trunk      * branches      * tags     -Project D      * trunk      * branches      * tags     -Application 1      * trunk      * branches      * tags      So Project A is core functionality pretty much all of our other projects use. D may depend on C & B as well, and application 1 uses them all. Note that we have many more libraries and applications than I've illistrated above, but its all done the same way. The assemblies generated by building project A are included in needed library or application projects as externals. We've got quite a few libraries like this. What we've been doing after a release is tagging the RC branches we created for each project used by the application, and then these then become tags. Obviously this is a fair amount of work as we ensure that tags only point to other tags, and you start by creating the tag for Project A, making the other stuff point to that, etc., the idea being we want to branch from the tags should a patch release be required before our next feature release. Given the amount of effort that can be involved getting this all together, one proposal is to tag only the application's RC and for all the externals point to a specific revision. If we need to create a branch to fix one of the libraries, branch from that revision and do the work then. I'm not against this, as I would like to not have to spend the time getting all the tags for all the projects setup, but I wanted to ask, can anyone think of any pitfalls of this approach? Is there any reason to create these tags over just pinning to a specific revision?


Can we compare programming languages ergonomically?

For instance, would Python be a more ergonomic programming language since it doesn't force you to make curly braces which requires the AltGr key. Also Python usually requires less code to achieve the same or am I being biased towards Python and PHP actually is an ergonomical and comfortable language despite forcing the programmer to use the AltGr key? Isn't forcing the programmer to use the AltGr key not very ergonomical?


c++ makefile importance and cross platform

I'm new to c++ and I wanted to know few questions regarding makefile. 1) Is writing makefile really important ? I mean there are many IDE's which does this automatically. Also, do people in programming job write makefiles or do they use automation? 2) Should I learn GNU make or something else like cmake or other ? Can anyone point of pros and cons of these?


Is it fair to patent workarounds?

While developing a FAT32 driver for my bootloader, I thought to make it complete by adding the long file name support.   While watching around for some specification, and I also found articles about Microsoft suing for infringement of their patents on something that basically is a workaround.   Knowing about this events made me think: is it fair to patent things _that are_ workarounds?


Is it legal to distribute EXEs inside system32 folder with my product

I'm developing a product related to printing. To work it properly in all windows versions I need to include few exe (lpr.exe) files from system32 folder. So I need to know it is legal to distribute these exe file with my product.


Picking a code review tool

We are a startup looking to migrate from Fogbugz/Kiln to a new issue tracker/code review system. We are very happy with Jira, especially the configurability, but we are undecided on a code review tool. We have been trialing Bitbucket, but it doesn't fit our workflow well. Here are the problems we have identified with BB:   1. Comments can be hard to find:      * when commenting on code not visible in the diff     * when code that is commented on is later changed     * viewing the full file doesn't include comments (also doesn't show changes)     * Viewing comments on individual commits can be a pain   2. We have the implementer merge the diff and close the issue, whereas pull requests are more suited to the open source model where someone with commit rights merges   3. We would like to automate creation of the code review (either from Jira or a command line tool)   4. No syntax highlighting   5. Once the pull request exceeds a certain size, BB won't show the whole thing and you have to view individual commits   6. Linking BB pull requests to Jira issues is a bit janky: we have a pull request URL field on Jira, but this doesn't work when there are changes in multiple repositories Does anyone have any good suggestion given the above? We are tight on budget, and Jira integration is a big plus. We also have multiple commits per issue, and would like to have the option of viewing individual commits in the review. It might also be worth noting that we have a separate reviewer and tester for each issue.


Best practices for documenting ASP.NET code

Any preferences for Asp.Net programmers on how to document their code? I read XML with Sandcastle is a good way to go. What do you use?


What is this domain of study?

Suppose I have a situation where I'm designing a website for a shoe reseller. They have different brands and kinds of shoes and of course, they want a really good search function. So there are different properties that shoes can have. They can have exclusive properties, such as size, width, gender, and children's/adults'. Or they can have non-exclusive properties such as color (there could be two or more colors on a shoe). Some categories might conflict with certain others, such as 'dress' and 'casual' (a shoe cannot be both a dress shoe and a sneaker (ignoring "comfort" dress shoes for this example)), whereas they don't conflict with yet others, such as 'dress' and 'boot' (a shoe can be a dress boot). The exclusive properties are easy to model, but how about potentially conflicting properties? Would this be a problem for set theory? What would this kind of applied computer science be called, in general? Data modelling, or something more specific? I want to get into the more abstract philosophical principles, such as exclusive and non-exclusive properties, and see how those principles are implemented in code, data structures, and database schemas. A good example of what I'm talking about would be the modified preorder tree traversal algorithm. It's a great way to make a nested hierarchical categorization system. So you have a real-life organizational problem: categories, and then you have a data structure that models that problem. Where can I learn more about this type of stuff?


Logical Operators

A typical curly brace programming lang has two types of AND and OR: logical and bitwise. `&&` and `||` for logical ops and `&` and `|` for bitwise ops. Logical ops are more commonly used than bitwise ops, why logical ops are longer to type? Do you think they should be switched?


Any other guides out there like Why's Guide to Ruby and Learn You Haskell?

I was looking for some guides to start programming with, I'm a college student and I'm learning Ruby as my first language (Side-question, is that something good to start with?). I found _Why's guide to Ruby and I also found Learn You Haskell (which is of course not Ruby) and I was curious if there were any more guides/books like these, free and fun to read? Just for future reads and to know about. Will reading a book or guide actually teach me programming, do I just have to hop from one book to another until I understand the concepts because I feel like most books focus on theoretical stuff and I don't actually pick up much programming from them. Are there any "just do it" ways of learning programming? Like do I just sit here and start writing bad code until I get better or do I go out there and find some code and edit it? Because ultimately I want to write my own code but I want to see some good examples.


Math underpinnings of software testing?

In my software engineering course, we recently (briefly) covered testing. Over the course of the discussion some topics came up that made me wonder about the math underlying software testing (such as finer vs. coarser test sets, using equivalence classes to partition infinite input spaces into "testable" sets, etc). Are there any resources available exploring the math behind software testing?


docker-izing a classical db-based webapp - single or multiple containers?

I have a classic Java webapp. It is composed of a database (PostgreSQL), a servlet container (Tomcat) and my code (deployed on Tomcat as a *.war file). I want to package/deploy it using Docker (mostly for testing for now), but I'm unsure what would be the best way to "map" it. My initial idea was to have an app-in-a-box - define a container that has Java, Postgres and Tomcat on it, exposing just the http port. Further reading of the Docker docs shows that this, although possible (install and run supervisord as the single foreground process, have it start both Postgres and Tomcat) is probably not the intended usage. Going by the spirit of the tutorials I should probably create a container for Postgres, another for Tomcat, and a data-container to hold the application code (my *.war) and database files. This would mean 3+ containers (should the db files and *.war share the same data container?) What's the common practice here? Since I have no previous experience with Docker, what pitfalls can I expect from each approach? Is there some other approach I'm missing?


In PHP, should I delete objects immediately after use?

I've read in _PHP Advanced and Object Oriented Programming_ by Larry Ullman that it is good programming practice to delete object immediately after use but reason is given nowhere. I am a student web developer and objects in web applications are deleted automatically as soon as the script finishes. So, there seems no good reason to delete them manually. So, my question is what are the good reasons to delete unnecessary objects after use other that blindly following a convention?


How come verification does not include actual testing?

Having read a lot about this topic --- such as on this Software Testing Fundamentals site on verification and validation and Software Testing and Quality Assurance: Theory and Practice by Naik and Tripathy \--- I still do not get it. Verification should prove that you are building the product right, while validation proves that you built the right product. But only static techniques (code reviews, requirements checks...) are mentioned as being verification methods. How can you say if its implemented correctly if you do not test it? It is said that verification ensures that the product meet specified requirements. Again, if the function is specified to work somehow, only by testing I can say that it does. Could anyone explain this to me please?


Is there industry demand for developers who have no GUI experience?

Is there still demand for developers who crate software without GUI's in the industry? Are jobs still in demand? I only ask because I write a lot of software for myself in C. I mainly use FreeBSD without a GUI. My software is for data mining, automation and marketing purposes most of the time as this is the field I work in. I find that a GUI is not needed and I feel comfortable working within a console. I've never worked for a company as a programmer, but in the industry do you have dedicated programmers who work exclusively on the GUI's and other who write the logic?


Should lookup tables enumerating strings have an integer primary key?

When I learned relational databases, the prof said that one would "almost always" want an artificial int as the primary key in a table, but did not specify what the exceptions are. At some time I stopped using them for junction tables, and never had a problem. Now I am making a database with a lot of lookup tables, and wonder whether this is a case where leaving artificial keys out wouldn't make for a cleaner design and simple programming. A toy example: assume that this is a mockup of the UI I want to achieve. ![example for a UI view](http://i.stack.imgur.com/wkZCW.png) The design option with artificial IDs would be (Type is a foreign key):               LiteraryWork     Title                           Type     Winnie The Pooh                 1      The Nightingale and the Rose    2      Snowwhite                       2          LiteraryWorkType      ID TypeName      1  Novel      2  Fairy Tale      And the option without them uses the Type name itself as the key (again, the column Type is properly declared as a foreign key):               LiteraryWork     Title                           Type     Winnie The Pooh                 Novel      The Nightingale and the Rose    Fairy Tale      Snowwhite                       Fairy Tale           LiteraryWorkType      TypeName      Novel      Fairy Tale      I tend towards using the second option, because I would need one less join when showing data on the screen. (I don't want to get rid of the lookup table entirely because I want to be able to restrict the values users may enter, for example by giving them a drop-down list bound to the lookup table). The only disadvantage I can think of is that, when a stakeholder says "but I want my UI to say 'story', not 'fairy tale'", I would have to update all data rows in the `LiteraryWork` table. I can live with this, as I don't expect it to happen often in my case. Does the first design have any other advantages I am missing? Which of the two options is considered best practice, and why? **Edit2** As I understand it, the existing answers are afraid that I am trying to break normalization, as in               LiteraryWork     Title                           Type        LiteraryWorkTypeIsFiction     Winnie The Pooh                 Novel       Yes     The Nightingale and the Rose    Fairy Tale  Yes     Snowwhite                       Fairy Tale  Yes      To make it clear: the above is **not** what I am trying to do. Instead, if there really was more information pertaining to LiteraryWorkType, and I was using string IDs, I would record it this way:               LiteraryWork     Title                           Type     Winnie The Pooh                 Novel      The Nightingale and the Rose    Fairy Tale      Snowwhite                       Fairy Tale           LiteraryWorkType      TypeName         IsFiction     Novel            Yes     Fairy Tale       Yes     Conference paper No      The only difference to the "typical" database design would be that the ID is a nvarchar, not an integer. Which certainly has its drawbacks in storage needed, as pointed out, but I don't see which normalization rule it is supposed to hurt. But this example aside, I am not trying to use string IDs when there actually is more information to be recorded about a LiteraryWorkType (so that LiteraryWorkType should be considered an entity in its own right). I am speaking about cases as simple as the toy example I gave at the beginning: the whole second table exists only because SQL has no "enum" type, and each data record in it consists of nothing but a single word, unique between records.


How web-servers identify a client

I have seen on some sites which say ,for-example, multiple votes/views from same computer will be neglected/penalized etc. For-example liking a facebook page, or youtube video from same computer(different accounts) will not increase its worth(according to my knowledge). How do these sites identify bogus votes? I just need a direction.


Any performance advantage in copying the session to a variable?

I have a fair number of items in a session, and I am wondering if there are any advantages to copying the session variable to a normal php variable (in order to close the session file as quickly as possible) and then do any calls from there. Something like:               session_start();     $copiedSession = $_SESSION;     session_write_close();     if (isset($copiedSessionData['foo'])){         ...     }     ...        1. I am looking for ways to test performance on this.   2. Does it make sense to do so?   3. Is there a break-even point where it helps / doesn't help?


Are there standard style guides for PHP?

I've been working in a very small team for PHP development and we've been using an ad-hoc, "Invented Here" style guide. Now that our team and codebase is growing, we would like to use a more broadly-used style guide that would be, if not an official standard, a de facto standards used in many PHP communities. Does such a thing exist as it exists in the C/C++/Java/Javascript/etc. circles ?


Why Open-Source Code?

What reasons to companies have for open-sourcing libraries and applications? Doing this may allow a developer to better understand the code, but could doing this allow people to find and exploit vulnerabilities in the library or application?


Why would I use ElasticSearch if I already use a graph database?

I don't find any deep explanation on the web about a comparison between ElasticSearch and the graph databases. Both are optimized to traverse data.   ElasticSearch seems to be optimized for analytics.   However Neo4j is also based on Lucene to manage indexes and some fulltext features. Why would I use ElasticSearch if I already use a graph database ? In my case, I'm using Neo4j to build a social network.   What real benefit may ElasticSearch bring? **UPDATE ----------** I've just found this paragraph: > There are myriad cases in which elasticsearch is useful. Some use cases more > clearly call for it than others. Listed below are some tasks which for which > elasticsearch is particularly well suited. > > Searching a large number of product descriptions for the best match for a > specific phrase (say “chef’s knife”) and returning the best results Given > the previous example, breaking down the various departments where “chef’s > knife” appears (see Faceting later in this book) Searching text for words > that sound like “season” Auto-completing a search box based on partially > typed words based on previously issued searches while accounting for mis- > spellings Storing a large quantity of semi-structured (JSON) data in a > distributed fashion, with a specified level of redundancy across a cluster > of machines It should be noted, however, that while elasticsearch is great > at solving the aforementioned problems, it’s not the best choice for others. > It’s especially bad at solving problems for which relational databases are > optimized. Problems such as those listed below. > > Calculating how many items are left in the inventory Figuring out the sum of > all line-items on all the invoices sent out in a given month Executing two > operations transactionally with rollback support Creating records that are > guaranteed to be unique across multiple given terms, for instance a phone > number and extension Elasticsearch is generally fantastic at providing > approximate answers from data, such as scoring the results by quality. While > elasticsearch can perform exact matching and statistical calculations, its > primary task of search is an inherently approximate task. Finding > approximate answers is a property that separates elasticsearch from more > traditional databases. That being said, traditional relational databases > excel at precision and data integrity, for which elasticsearch and Lucene > have few provisions. Can I assert that if I don't need approximate answers, then ElasticSearch would be useless compared to an already used graph database?


How and where do I publish my open standard?

I have been writing an open standard for a protocol I am developing. As far as writing concerns I have it under control. But the main question is where can I publish such document. I have been searching on the internet and didn't find such site where I could upload a TXT or PDF file. I have no intention of keeping secrets and I would like people to read this and if possible make protocol better.


Is there something special about the number 65535?

2¹⁶-1 & 2⁵ = 2⁵ (or? obviously ?) A developer asked me today what is bitwise 65535 & 32 i.e. 2¹⁶-1 & 2⁵ = ? I thought at first spontaneously 32 but it seemed to easy whereupon I thought for several minutes and then answered 32. 32 seems to have been the correct answer but how? 65535=2¹⁶-1=1111111111111111 (but it doesn't seem right since this binary number all ones should be -1(?)), 32 = 100000 but I could not convert that in my head whereupon I anyway answered 32 since I had to answer something. Is the answer 32 in fact trivial? Is in the same way 2¹⁶-1 & 2⁵-1 =31? Why did the developer ask me about exactly 65535? Binary what I was asked to evaluate was 1111111111111111 & 100000 but I don't understand why 1111111111111111 is not -1. Shouldn't it be -1? Is 65535 a number that gives overflow and how do I know that?


What are the advantages of separating 'result' from 'status'

Let's say you have some automated processes that generally go through the following states; scheduled - initiated - validating - executing - completed On top of that these processes can prematurely end because of an error or explicit user cancellation. My first impulse is to simply add _error_ and _cancelled_ to the list of possible status values, but I was wondering about the (conceptual) advantages of separating _result_ from _status_ (even though it seems to me that one might argue that error and cancelled are also simply different states than the _completed_ state).


How much of your time at work is actually devoted to working?

A friend of mine told me that at a **very** big company, the programmers were told they are expected to actually work about 60% of the time **Added:** She meant 60% of the time they were at work, they are supposed to work, the rest if spent on surfing the web playing pool or ping pong or whatever, chatting, etc. I think I'm at about 70% How much do you?


Aging vs. Coding Skills

A little background, since it can be part of my point fo view. I'm a C#/Java programmer with age of 23, coding since my 18's. I started studying C and working with Cobol, and after 1 year I quickly moved to C#/Java Web Development, and have worked with it in about 3/4 companies. (I've just moved again) In my (brief) professional career I encountered some older programmers, all the times it was very hard to work with them, since I was way better programmer than they. And it is not about just the language skills, some of them had seriously problems understanding basic logic. Now I wonder how theese programmer get jobs on the market since (I imagine) they have more expenses, and thus have to make more money, and are really counter-productives. In theese examples, others project member have to constantly keep stoping for helping them out. All the times, they eventually quit... So I wonder...   1. May the aging process slow down the learning rate and logic thinking?   2. Does the programmer has to, or at least should, move to a management area before getting old? **Please, my intention is not to be disrespectful with older persons. I am fully aware that this is NOT the case of all older programmers, I often see around very good old programmers on the net, I just never met them for close.**


Is it possible to effectively develop PHP applications on Windows that will be deployed on servers running Linux?

Is it fine to code PHP on Windows and host it later on a server running Linux? Can there be any problems in the migration of such a project? I would think that there really can't be any problems, especially since I am a beginner in PHP and I won't use any of the advanced functions that may be OS- specific. However, I would like to make sure since I really don't like Linux at all.


Recommend Stanford Online Database Class?

I am taking the Stanford Online Machine Learning class which is outstanding. http://ml-class.org Is anyone taking the Stanford Online Database class: http://www.db-class.org? Does it seem useful if you have a few years of fairly simple database experience, but no formal education in the area? Or is it mostly academic and not relevant to developing and maintaining databases in the "real world"?


Do else blocks increase code complexity?

Here is a **_very_ simplified example**. This isn't necessarily a language- specific question, and **I ask that you ignore the many other ways the function can be written, and changes that can be made to it.**. Color is of a unique type               string CanLeaveWithoutUmbrella()     {         if(sky.Color.Equals(Color.Blue))         {             return "Yes you can";         }         else         {             return "No you can't";         }     }      A lot of people I've met, ReSharper, and this guy (whose comment reminded me I've been looking to ask this for a while) would recommend refactoring the code to remove the `else` block leaving this: (I can't recall what the majority have said, I might not have asked this otherwise)               string CanLeaveWithoutUmbrella()     {         if(sky.Color.Equals(Color.Blue))         {             return "Yes you can";         }         return "No you can't";     }      **Question:** Is there an increase in complexity introduced by not including the `else` block? I'm under the impression the `else` more directly states intent, by stating the fact that the code in both blocks is directly related. Additionally I find that I can prevent subtle mistakes in logic, especially after modifications to code at a later date. Take this variation of my simplified example (Ignoring the fact the `or` operator since this is a purposely simplified example):               bool CanLeaveWithoutUmbrella()     {         if(sky.Color != Color.Blue)         {             return false;         }         return true;     }      Someone can now add a new `if` block based on a condition after the first example without immediately correctly recognizing the first condition is placing a constraint on their own condition. If an `else` block were present, whoever added the new condition would be forced to go move the contents of the `else` block (and if somehow they gloss over it heuristics will show the code is unreachable, which it does not in the case of one `if` constraining another). Of course there are other ways the specific example should be defined anyways, all of which prevent that situation, but it's just an example. The length of the example I gave may skew the visual aspect of this, so assume that space taken up to the brackets is relatively insignificant to the rest of the method. I forgot to mention a case in which I agree with the omission of an else block, and is when using an `if` block to apply a constraint that **must be** logically satisfied for **all** following code, such as a null-check (or any other guards).


Video documentary on the open source culture?

I'm looking for some videos on these subjects:   1. A movie/documentary detailing the origin, history, and current state of open source culture    2. A movie/documentary on how open source software actually gets developed. What are the technical workflows. How do people create projects, recruit contributors, build a community, assign roles, track issues, assimilate new comers ... etc etc. Could someone suggest a title?


Why aren't there other programming languages that compile to Python bytecode?

In Java, there are multiple languages that compile to Java bytecode and can run on the JVM -- Clojure, Groovy, and Scala being the main ones I can remember off the top of my head. However, Python also turns into bytecode (.pyc files) before being run by the Python interpreter. I might just be ignorant, but why aren't there any other programming languages that compile to python bytecode? Is it just because nobody bothered to, or is there some kind of inherent restriction or barrier in place that makes doing so difficult?


How to build a .Net app which runs on desktop and as a Windows Service

Ok, I hope this is not too much confusing (with my poor English). I want to build a small .Net 4.0 app which monitors several other applications on a Windows Server OR on a regular Windows PC. It will have a WPF GUI with a variety of graphical controls. The app will be used in the following scenarios:   1. If installed on a PC it should run as a “normal” single Windows desktop app   2. If installed on a Server, it should run as a Windows Service. To use/manage the app it must have the same WPF GUI as in scenario 1 and the GUI should be run on the Server or on a remote PC At the moment I consider to write the application logic and connect it to the WPF GUI using a self-hosted WCF Data Service IN BOTH SCENARIOS. Since I’m not a pro developer I suppose it’s possible that I've missed something ;-) Will this work? Are there other/better solutions? Any answer or comment is highly appreciated.


How much should app iphone or ipad development cost?

I'm an iOS developer (freelancer) and i want to know how much cost to build an app? and how should i do to estimate the price? like this app http://www.finalcad.fr/en/index.html


Why do a lot of logging frameworks provide individual methods instead of a enum 'level'?

I see some of the more preferred logging frameworks like log4j, log4net etc all use 'trace, debug' etc methods. Why do they use these instead of methods that take something like a enum level?


Does it make sense to use Kanban if all steps are done by the same person?

In our team all task's steps are always done by the same developer. I.e for task 1, person A does design, development, and testing; for task 2, person B does does design, development, and testing, etc. Does it make sense to use Kanban in this case?


How to unit test a class which is just an adapter that logs input and output to a third-party library?

I have the following (in C#, but the question could also apply to Java):               public interface ILibraryAdapter     {         string Property1 { get; }         string Method1(string param1);         ...     }          public class ThirdPartyLibrary : ILibraryAdapter     {         private readonly ThirdPartyClass thirdPartyClass;         private readonly ILog log;              public ThirdPartyLibrary(ThirdPartyClass thirdPartyClass, ILog log)         {             this.thirdPartyClass = thirdPartyClass;             this.log = log;         }              public string Property1         {             get             {                 log.Trace("ThirdPartyClass.get_Property1()");                 var result = thirdPartyClass.Property1;                 log.Trace(string.Format("ThirdPartyClass.get_Property1() returned {0}", result));                 return result;             }         }              public string Method1(string param1)         {             log.Trace(string.Format("ThirdPartyClass.Method1({0})", param1));             var result = thirdPartyClass.Method1(param1);             log.Trace(string.Format("ThirdPartyClass.Method1({0}) returned {1}", param1, result));             return result;         }              ...     }      where the `...` represents more of properties and methods being wrapped and logged (about two dozen total). The separate calls to the logger in each method are part of the requirements. How should I unit test this class? **Note:** The names of the properties and methods of the third-party class do not always match the names of the properties and methods of ILibraryAdapter.


How to avoid "DO YOU HAZ TEH CODEZ" situations?

I have a strange situation at work, where a colleague of mine often asks me and other co-workers for working code. I would like to help him, but this constant request of trivial snippets interrupts my thoughts and sometimes makes it hard to concentrate. Plus, I have the impression (...) that this requests are generated by lack of competence, more than by laziness. In fact, he often asks things pretending to know the answer, since when I solve the problem he usually says things like "Sure", "Yes, that's what I thought", giving me the impression that my answer isn't worth it. How can I solve this embarrassing situation?   Should I show more explicitly in front of other colleagues his lack of knowledge (by saying things like: "do it yourself if you can, please") or continue giving him what he wants? I think that he should aggregate all his questions in one, so that I can give him a portion of my time and he can work all by himself on his things. There is no hierarchy in the team, I must say we both have a similar seniority of five years, more or less. For the same reason I believe I cannot report to management, since trivial questions are often ignored. I discussed with other two members and they agree with me: in fact he often ask things cycling through colleagues.


Pros and cons of using HTML5 vs frameworks for cross-platform mobile development

I'm going to start developing an app for my job, and I would like to know what is the best approach. The app will be a basic tracker for some application that we have, and since our employers uses both Android and Apple phones I don't want to develop the app twice just so it could work on both platforms. Is it worth developing an HTML5 app that could work on all the devices or should I use some the frameworks like appcelerator? Are there strong pros and cons for either approach?


Is there any benefit to just artificially reducing WIP in a Kanban system?

So imagine this scenario: There is only 1 developer, who also is the bottleneck (testers, etc are busy on other contracts). There is a nontrivial backlog of tickets, most of which are blocked for not being reproducible, unintelligible requirements, unsolvable (with current ideas, staff and technologies). Is there any particular benefit to creating a system that parcels out the tickets to the sole developer one or two at a time? The system so far has immediately created slack on account of delays in assigning new tickets after current tickets are worked. When blocked tickets are assigned, they now sit on the developer's desk blocked until they are moved back to unassigned tickets. Are there any benefits to this "artificial low-WIP" system and how could/should it have been implemented?