title: Inheritance vs containment while extending a large legacy project

text: I have got a legacy Java project with a lot of code. The code uses MVC pattern and is well structured and well written. It also has a lot of unit tests and it is still actively maintained (bug fixing, minor features adding). Therefore I want to preserve the original structure and code style as much as possible. I aim to inject a new behavior into an existing class. Like a Duck that was trained to jump. Then I ask all my Ducks to jump. Those who can - jump. Those who cannot do nothing which is perfectly OK with me. The new feature I am going to add is a conceptual one, so I have to make my changes all over the code. In order to minimize changes I decided not to extend existing classes but to use containment:               class ExistingClass     {        // .... existing code                  //  my code adding new functionality        private ExistingClassExtension extension = new ExistingClassExtension();        public ExistingClassExtension getExtension() {return extension;}     }           ...     // somewhere in code     ExistingClass instance = new ExistingClass();          ...     // when I need a new functionality     instance.getExtension().newMethod1();      All functionality that I am adding is inside a new ExistingClassExtension class. Actually I am adding only these 2 lines to each class that needs to be extended. By doing so I also do not need to instantiate new, extended classes all over the code and I may use existing tests to make sure there is no regression. However my colleagues argue that in this situation doing so isn't a proper OOP approach, and I need to inherit from `ExistingClass` in order to add a new functionality. What do you think? I am aware of numerous inheritance/containment questions here, but I think my question is different. EDIT: Most of people replying to my question presume that a containment relationship looks like that:               class NewClass     {        OldClass instanceOfOldClass;        void oldFunctionality() { instanceOfOldClass.oldFunctionality();}             void newFunctionality() { // new code here }     }      But isn't this a kind of a containment relationship too?               class OldClass     {        void OldFunctionality();        NewClass instanceOfNewClass;             void NewFunctionality {instanceOfNewClass.NewFunctionality();}     }


title: Wrong encoding in DataReceivedEventArgs

text: I start cmd.exe process and redirect stdin to pass script to it and redirect stdout and stderr to read cmd's output. Here is the code of my DataReceivedEventHandler:               (o, a) => {         if(!String.IsNullOrEmpty(a.Data)) {             bw.Write(a.Data.ToUTF8());             bw.Write((byte)'\n');         }     }      In the code `bw` is instance of BinaryWriter, `ToUTF8` is string extension method, that converts a string to UTF8 encoded byte array. When I use this code in a separate process it works well, however when I use this code as a shared library inside some other process a.Data doesn't contain valid localized characters (like russian characters for example). So how should I convert characters? How to get cmd's OEM encoding? Why does the code works well in a separate process and doesn't work as a shared library inside some other process?


title: Programming Language vs Markup Language vs Scripting Language

text: Up until now I don't know the **KEY** differences between these three. When someone asks me about this, I only tell them that C# is a programming language, HTML and XML are Markup Languages, and JavaScript and VBScript are scripting languages. But what are the key differences that distinguish them from one another?


title: Is backing up a MySQL database in Git a good idea?

text: I am trying to improve the backup situation for my application. I have a Django application and MySQL database. I read an article suggesting backing up the database in Git. On the one hand I like it, as it will keep a copy of the data and the code in sync. But Git is designed for code, not for data. As such it will be doing a lot of extra work diffing the MySQL dump every commit, which is not really necessary. If I compress the file before storing it, will git still diff the files? (The dump file is currently 100MB uncompressed, 5.7MB when bzipped.) Edit: the code and database schema definitions are already in Git, it is really the data I am concerned about backing up now.


title: After HTML and CSS

text: I want to create dynamic professional websites. I have finished learning HTML and CSS, but as I understand, those two technologies allow to create static websites only. I heard about PHP and JavaScript as something which enables to create dynamic websites. Is that true? What is the difference between both? Are there other languages?


title: Placing images into Git for a CRM

text: I have built this CMS that has the option to add entries to the database. Each entry that is created has about 5 to 10 new images showing the product for sale. Each image is about 150Kb in size. I already know that images should always be stored in Git however my problem is that the sales team users that add new entries in the CMS are obviously working on the production server using the master branch. Our normal development is development code in your "dev environment" on a branch, then push those changes to the "staging environment" for QA and lastly if all the tests pass, push those changes to "production/live server". What will be the best way to get those new images that are uploaded on a daily basis into our repository seeing as those images are already on the live server?


title: Is using the new System.Tuple class bad design?

text: I like the concept of System.Tuple in that it allows me to return multiple parameters in a single function call without instantiating a new class, however does this defy any good programming practices such as Microsoft Patterns & Practices, SOLID Principles, etc. I'm just trying to gauge how liberally I should use this feature or if I should only use it in edge case scenarios when necessary.


title: Code base migration - old versioning system to modern

text: Our current code base is contained in a versioning system that is old and outdated (Visual Sourcesafe 5.0, mid 1990's), and contains a mix of packages that are no longer used, ones that are being used but no longer updated, and newer code. It is also a mix of 4 languages, and includes libraries for some of our systems (Such as Dialogic, Sun Tzu {clipper}) implementations. This breaks down into the following categories:   1. Legacy code - No longer used (Systems that have been retired or replaced, etc)   2. Legacy code - In current use (No intentions for upgrades or minor bug fixes, only major fixes if needed)   3. Current code - In current use, and will be used for future versions/development   4. Support libraries - For both legacy and current code (Some of the legacy libraries are no longer available as well) We would like to migrate this to a newer versioning system as we will be adding more developers, and expanding the reach to include remote programmers. When migrating, how do you structure it? Do you just perform a dump of all the data and then import it into the new system, or do you segregate according to type before you bring it into the new system? Do you set up a separate area for libraries, or keep them with the relevant packages? Do you separate by language, system, both? A general outline and methodology is fine, it doesn't need to be broken down to individual program level.


title: What should be included on an About page/form?

text: I was looking to add a simple form that states my project's build number on a form to quick identify what version I am running. Then I realized I'm not sure what fits on an about page. In my highschool projects I would make silly splash screens with this info, with images and other unnecessary information. What are standard/appropriate elements to include on an "About" page in an application?


title: Is this a good way to compare two numbers?

text: If we have double numbers, let's say I want to see if some double parameter is equal to zero that is passed as double:               public bool AlmostEqual(double x, double y)     {         double epsilon = Math.Max(Math.Abs(x), Math.Abs(y)) * 1E-15;         return Math.Abs(x - y) <= epsilon;     }      considering double shows 15 accurate digits. So do you think what I wrote is good? or it has issues? well then I just wrote a simple method like this:               public bool ReallyEqual(double x, double y)     {         return (x == y);     }      and then I couldn't find a case that return values of those two methods are different. they were always returning the same result. :(


title: Introduce the work of a software developer to school children using a social network

text: I often represent my software development company at conferences and other events. However this time I got assigned to introduce school children (12-18) years to the job of a software developer. Now the problem is that our PR guys told me to use Facebook ("use the cool stuff kids know") to leave a good impression. Now I'm stumped and have no idea how to bridge the gap between presenting the role of a software developer, requirements engineers, and programming in general to Facebook. I intend to give a 5 minute talk and then let them "do something" that invovles Facebook. Has anyone got an idea how to do something like that? Is it possible to let them develop a simple facebook app?


title: What is the best way to access multiple child properties?

text: I have a situation where I have to access several "sub-properties" of an object and find it quite appalling to write such code. I was wondering how best to deal with this situation:               void Main()     {         MyAClass aClass = new MyAClass();         aClass.BClass.CClass.DoSomething();     }      In addition to it being an eyesore, there are no null checks, and if one were to do them, the code would look even more cluttered. At the moment I create shortcuts, but they are a bit of a code smell too:               public class MyAClass     {         public MyBClass BClass { get; set; }              public void DoSomething()         {             if (BClass == null || BClass.CClass == null)                 throw new Exception();                  BClass.CClass.DoSomething();         }     }      What's the best way to access multiple properties like this?


title: Should I pass an object into a constructor, or instantiate in class?

text: Consider these two examples: ### Passing an object to a constructor               class ExampleA     {       private $config;       public function __construct($config)       {          $this->config = $config;       }     }     $config = new Config;     $exampleA = new ExampleA($config);      ### Instantiating a class               class ExampleB     {       private $config;       public function __construct()       {          $this->config = new Config;       }     }     $exampleA = new ExampleA();      Which is the correct way to handle adding an object as a property? When should I use one over the other? Does unit testing affect what I should use?


title: Can I market an application I wrote at work?

text: I work at a bank and I developed an in-house web application that helps keep track of past due loans and all the interaction between the bank and the customers. I was recently told by an outside consultant, who frequents many different banks, that each one of these banks would die to have a loss mitigation system like the one I built. I just read Joel's response to a similar question about copyright ownership. In his example he said that even though **_Joe was hired to write the code, he still owns the copyright._** So, do I own the copyright to this app and can I resell it to other banks? ### Update 05/20/2011: Thank you all for your honest feedback on this issue. I have always understood that software written at work by an employee as belonging to the employer. I was stunned when I read scenario described by Joel, and thought I would ask your opinions. It's nice to know that I have always held the same beliefs as you... the code belongs to the employer.


title: Help deciding on the appropriate software license type

text: I'm working on a piece of software which i'd like to sell; however i'd like to keep the source 'open' in the sense that I see no reason why people should be not able to browse it for educational purposes. Most of my personal learning process involves looking at similar examples of other people's work. I'd like to protect my intellectual property, but also give something useful to the programming community (without which many of us wouldn't have gotten too far). I'm not super worried about theft of my 'algorithm' since what i'm doing isn't all that profound. I'd likely wait until the software was ready for release before publishing the source anywhere. Are there any licenses which are appropriate for this sort of thing? Alternatively, are there better resources than this site that I should direct my search toward? Thanks, brian


title: Allow Administrator users to login as other users

text: Do you think it's a good practice to implement a possibilty to allow an administrator user to login in as another user, by-passing password? This could by implemented by a master password or a function inside the user administration, "Login as this user". Administrators are asking for a such function to be able to try to reproduce a reported problem or to check if grants are ok, for example.


title: Suggestions for search methodology requested

text: I am throwing this question out to the 'greater creativity' for some suggestions on search methodology that might solve this problem. I have come up with a somewhat contrived example to attempt to explain the problem well enough that some solution(s) might be recommended. The problem: We are using a relational DB (MSSQL), and need to search across products with the following constraints:   * Availability   * Market   * Price We also need to group and sort on price, market, and larger entity roll-up. Let me see if I can explain using semi-real world entities: Think of an application that allows users to search for hotel rooms that they can book. The following criteria might be available for the search: days that the rooms would be booked for, the market in which they want a hotel room (e.g. NYC, Boston), amenities that the hotel room(s) might have (hot tub, fireplace, number of beds, suite or not). In all cases, the search criteria above may or may not be selected. So, a very broad search is possible (on these dates, I don't care which market), or varying the levels of specificity (in NYC, 2 beds, with fireplace). To add complexity, we also need to return the prices of the hotel rooms for the selected criteria. Obviously, special pricing, different prices for the different days of the stay (one price on Thursday night and a different price on Friday and Saturday nights for a weekend stay). Some of the things we've played around with are: Solr, Endeca, SQL querying, implementing in C# code and optimizing when/where necessary (think of the decorator pattern). What I'm looking for here is some suggestions from the community on: which of the above is NOT suited for this problem, which might be well suited for this problem, which other technology might work better that we haven't thought about, techniques that others have used on similar problems that worked well (non-technology specific).


title: How do Java tests by IKM compare to Sun certifications?

text: Is the IKM test more difficult when compared to Sun certifications? Can you share your experience taking the test for Java/J2EE? What types of questions are asked?


title: Is there real value in a portable language targeting very different runtimes?

text: Another question over on SO introduced me to Oxygene, formerly Chrome before the browser of the same name came to prominence. It's in the Pascal syntax family, but brings in a lot of object-oriented grammar and elements from the C family, notably Java/C#. One of its big advertised strengths is that the language is implemented as runtime-independent; programs written in Oxygene can target .NET, J2EE, Android, or Cocoa, making it a memory-managed language almost as portable as C/C++ is in unmanaged-land. However, my question is whether that kind of independence is really useful, given that the frameworks and environments it targets are so different (and incompatible). There are a host of problems inherent in writing one program that can be compiled as-is to target all three of these runtimes, and a common language is only the tip of the iceberg. Java doesn't have a System.Windows.Forms namespace; it has java.swing, and the classes underneath are totally different. Similarly, Java's database interop is via JDBC, while .NET has the ADO.NET sub-framework. While having a common language is nice, being fluent in a "language" is as much (more, IMO) about being fluent in the targeted libraries as it is with the syntax of the language. Does anyone have a common example of where runtime-independent languages have been leveraged to create truly portable programs across all supported runtimes?


title: Can a GPLv2 program rely on Apache-licensed libraries?

text: Can a software program licensed GPL (version 2) rely upon libraries licensed under APLv2 without running afoul of the GPL? The language here suggests to me perhaps not. In my specific case I'm looking at a daemon that uses some APLv2-licensed external libraries. **UPDATE** (In response to answers/comments.)   1. For the purpose of this question, I cannot relicense the main program (the daemon)   2. The main program has been extended with functionality that uses `apr-util` and perhaps other APLv2 components My question is, can I release the extended daemon under the GPLv2, or is this something I need to keep to myself (no distribution) and/or re-implement without APLv2 if I am committed to **(a)** releasing this extension, and, **(b)** keeping the daemon GPL'd?


title: Realtime (almost) bidrectional communication in Java

text: I will explain the context of the problem first. For a University project I'm going to implement an Android application. The Android application (and others) will be able to send data to a remote source, that remote source will also be able to send messages to the Android applications. For example the messages may be "apply configuration x", "what is your status". I want the remote source to be able to send these messages to:   1. Reduce overhead. I don't want the Android devices sending data when its not necessary. This uses data and power.   2. So that I can scale it, for example version 1 might allow you to check what value x is on the Android applications, version 2 might let you check what y is etc. I have looked at implementing this using Sockets in Java. Having the Android application talk to the remote source is easy. I configure the router (port forward) and everything is OK. The problem is having the remote source to talk to the Android application. They may be using public WiFi hotspots, have their 3G on etc, I wouldn't be able to address the device directly via sockets right? The approach to solving the problem is not that common I believe, which makes me believe I'm trying to do something that shouldn't be done. Can anyone shed some light on this and offer me some guidance? Many thanks.


title: Write to stdout and redirect or write directly to file?

text: I can see two ways to fill an empty file with data:               $ run_program arg1 > data_file      or, specifically write code that manages a file and write to it? ie. a file stream? **Which is better to implement?**


title: Web App vs Portal Platform - convincing the customer

text: We're evaluating a set of requirements for a customer who wants Liferay which mainly has AAA and Web CMS requirements, and allowing user to upload their own content. Also all inetgration is via web services. However there is no need for other features such as actual "portlets", i18n, mashups, skins, themes, tagging, social presence, no collaboration etc So we feel we can do this as a standard JEE web app and not use Liferay (or any other portal product) since these are overheads we dont need. The customer feels the **Web CMS requirements + user upload justify the "portal" product.** Can anyone help me with some points to convince the customer? Assuming our point of view is right.


title: Session serialization in JavaEE environment

text: Please consider the following scenario: We are working on a JavaEE project for which the scalability starts to become an issue. Up until now, we were able to scale up but this is no longer an option. Therefore we need to consider scaling out and preparing the App for a clustered environment. Our main concern right now is serializing the user sessions. Sadly, we did not consider from the beginning the issue and we are encountering the following excetion:               java.io.WriteAbortedException: writing aborted; java.io.NotSerializableException: org.apache.catalina.session.StandardSessionFacade      I did some research and this exception is thrown because there are objects stored on the session which does not implement the `Serializable` interface. Considering that all over the app there are quite a few custom objects which are stored on the session without implementing this interface, it would require a lot of tedious work and dedication to fix all these classes declaration. We will fix all this declarations but the main concern is that, in the future, there may be a developer which will add a non `Serializable` object on the session and break the session serialization & replication over multiple nodes. As a quick overview of the project, we are developing using a home grown framework based on Struts 1 with the Servlet 3.0 API. This means that at this point, we are using the standard `session.getAttribute()` and `session.setAttribute()` to work with the session and the session handling is scattered all over the code base. Besides updating the classes of the objects stored on session and making sure that they implement the `Serializable` interface, what other measures of precaution should we take in order to ensure a reliable Session replication capability on the Application layer? I know it is a little bit late to consider this but what would be the best practice in this case? Furthermore, are there any other issues we should consider regarding this transition? Thank you in advance!


title: Can you choose your tools or do you take what you get?

text: I often see questions about what tools to use for a particular problem, or suggesting that one tool is preferable over another, and that it says something about the quality of the programmer who uses the subpar tool. Some of that is religious arguements, but some tools generally are considered less than ideal. In every job I've had, the environment and tools are already bought and in use. I start using what they have, and while I might have some small say in a future direction, have no say in the current environment. Is it common for a company to allow the programmer to choose the tools they will use? Or is it more common that a programmer is dropped into an existing environment, and they make use of what they are given? I'm guessing a contract programmer has more say than a FT programmer -- true? (For an example, at my previous job we used Access for a database, Visual C++ for a programming language, and Visual Studio for an IDE, with WinXP for an OS. We also had Source Safe and Test Track. So, that's what I used. In my current job I get SQL Server and Oracle instead of Access, more ColdFusion than C#.net and VB.net, and we're moving from XP to Win7.)


title: Why are C++ template error messages so horrific?

text: C++ templates are notorious for generating long, unreadable error messages. I have a general idea of why template error messages in C++ are so bad. Essentially, the problem is that the error isn't triggered until the compiler encounters syntax that is not supported by a certain type in a template. For example:               template <class T>     void dosomething(T& x) { x += 5; }      If `T` doesn't support the `+=` operator, the compiler will generate an error message. And if this happens deep within a library somewhere, the error message might be thousands of lines long. But C++ templates are essentially just a mechanism for compile-time duck typing. A C++ template error is conceptually very similar to a runtime type error that might occur in a dynamic language like Python. For example, consider the following Python code:               def dosomething(x):        x.foo()      Here, if `x` doesn't have a `foo()` method, the Python interpreter throws an exception, and displays a stack trace along with a pretty clear error message indicating the problem. Even if the error isn't triggered until the interpreter is deep inside some library function, the runtime-error message still isn't anywhere near as bad as the unreadable vomit spewed by a typical C++ compiler. So why can't a C++ compiler be more clear about what went wrong? Why do some C++ template error messages literally cause my console window to scroll for over 5 seconds?


title: Could I learn more about programming from deconstructing drupal rather than continuing with ZF?

text: When I was deciding how to go about learning to design PHP web applications, it made sense to sort of shoot toward the middle and go with Zend Framework so that I could be closer to the lower level, but I would be able to get down to business fairly easily, too, while learning about design patterns, etc. That seemed to work out pretty well, but now I'm wondering if I wouldn't have learned more about design from a more top-down approach, like creating a drupal site and deconstructing it. I realize that the degree of topness vs. bottomness in this context is pretty negligible in the spectrum of all programming experiences, but I think it matters very much where you start, especially at the very beginning, because your world is small; it's home base, and how you develop your personality there "at home" can determine how you approach other problems in the future--I believe people tend to try to repeat their successes, which often means adopting a preference for what's familiar to them. I didn't want to "learn myself into a corner," so to speak, so I tried to aim for a level that would prepare me for the greatest amount of other experiences. LAMP with ZF seemed like a well-rounded, holistic choice, because I'd be learning about database design, patterns, web app development, server configuration, and a C-based programming language all at once. Okay, great, but I haven't really progressed as far as I had hoped I would, honestly. And now I'm starting to wonder if I've done myself a disservice for wanting to start nearer to the bottom vs. learning to produce as much as possible right away. My instincts at the time were that, "sure, a CMS will get you up and running, producing stuff right away, but you'll eventually hit a wall and need to learn the lower-level stuff anyway, and you'll probably hit it sooner than later so you might as well start there. Don't eat dessert first." But now I'm thinking "what would have stopped me from digging into the gears of a CMS?" Maybe I would have learned more from seeing a more complete implementation and deconstructing it rather than reinventing the wheel. Or, I could be exactly where I should be having only started in December? And I just don't know the answer. I want to start a new project (redoing my website--I'm actually a composer (of music)). I know the basics of Zend Framework, and I'm fairly sure I could code a simple CMS for myself for my purposes, but would I learn more from deconstructing an out of the box CMS like drupal?


title: If we only know that a video is 720P, 480P or 240P can that unambiguously tell us of the resolution?

text: The main issue I have here is are the 720P, 480P, 240P... classes for defining video quality or do they unambiguously define the resolution of the video? For example, the wikipedia article about 240P refers to a family of resolutions.


title: Open source and updates

text: I have found an open source library that can work fine with my project, but I have noted that It's not frequently updated and I'm afraid of not having the necessary support. Is the frequency of updates a proper criterion for choosing an open source library rather than another?


title: c++ exceptions vs. preliminary error condition checks

text: ## Preamble One of the concepts used in writing Python code is "Easier to ask for forgiveness than permission", aka _EAFP_. Literally this means that instead of doing checks, whether an operation is possible, you do the operation and "ask forgiveness" if what you do fails. Technically this means (just an example with no particular meaning):               try:         obj.x = 10         obj.y = 20     except AttributeError:         pass      This technique is oftenly used when the code in `try..except` block is known to run without any errors in most cases, or if the code is rearly executed. The same code with preliminary checks would look as follows:               if hasattr(obj, 'x'):         obj.x = 10          if hasattr(obj, 'y'):         obj.y = 20      ## C++ practices While generally not an issue in Python, C++ has a "heritage" flame war of "function returning error status" vs. "throwing exceptions". This has been discussed a lot, but I can't find any good source of information which describes whether the Pyhton-like EAFP is applicable in Python. E.g. consider the following:               if (node.has_element('x')) {         node['x'] = 10;     }      versus               try {         node['x'] = 10;     }     catch(ElementNotFoundException e) {         // pass     }      Which approach is generally used in C++ code? If performance is not the issue, would you write EAFP-fashioned code? Thank you.


title: Finding developers for collaboration in enterprise open-source project

text: I am a founder and only developer of an open-source software designed for a small subset of enterprises. It was originally developed for and now runs at one of businesses of the type it was designed for. It's my biggest project and I wanted to make something even bigger of it. Creating a software developing company and selling the product is not an option to me, so I decided to make the project open-source and sell the deployment and support services to enterprises in my area. The problem I faced is that I can't find developers to contribute to the project. Most articles and books on growing open-source community state that developer arrive from the users base, however my project's users base is small and is not related to IT. So it's really unlikely that one of my customers will happen to be an opensource enthusiast who happen to know the stack of technologies I use. I have been thinking about it for a long time, and seems like the only way to attract someone to collaboration is to look for programmers in my area and offer them to cooperate in both development and commercialization of the project. No one else would be interested in contributing to my project. _Is that correct and no other option exists?_ The generalized question is: **How do opensource projects with small, non-IT users base (like enterprise software projects) find developers to collaborate?**


title: Use Windows Store controls in a Windows 8 desktop app?

text: Is it possible to use the Windows 8 Store controls in a Windows 8 desktop app? Controls like the FlipView and SemanticZoom would be useful. I haven't found any information about this and would presume the answer is no, but thought someone would have a more definitive answer.


title: Best and safest API for a function which fills a buffer with variable-length data

text: I have a function which receives a buffer and returns some data in the buffer. The data can be smaller than the buffer capacity. Which is the best and safest API for this?   * `int fn(void *buffer, size_t buffer_len)`: the size of the data written to `buffer` is returned by the function. Downside: the return value must also have a way to indicate that some error occurred (in-band error indicator).   * `errno_t fn(void *buffer, size_t *buffer_len)`: in this case, `buffer_len` works both as input (the buffer capacity) and output (the data size). The function can return an error code. I think this is OK, but somewhat awkward.   * `errno_t fn(void *buffer, size_t *data_len, size_t buffer_len)`: like the previous, but with input/output separated in two arguments. Also returns error code, but is also awkward due to too many arguments. (Any other options?)


title: Would using a hash table in garbage collection solve the stop the world problem of mark and sweep?

text: In mark-sweep-compact garbage collection algorithm you have to stop-the-world when relocating objects because reference graph becomes inconsistent and you have to replace values of all references pointing to the object. But what if you had a hash table with object ID as a key and pointer as value, and references would point to said ID instead of object address... then fixing references would only require changing one value and pause would only be needed if object is tried to be written into during copying... Is there a mistake in my line of thought?


title: Ideal "intermediate" file format to use for structured/styled text?

text: I have files that I want to make available in an variety of formats:   * HTML   * PDF   * EPUB   * Plain Text (maybe) Most of the files will be _sourced_ in doc, docx, or rtf format, so that needs to be considered. So I need some kind of format that converts well from docx, doc, and rtf and has plenty of libraries for converting into PDF, EPUB, HTML etc. Ideally libraries in Python, but Java is also okay.


title: What is the best/most standard way to measure server load?

text: I'm a bit green to web applications although I am in the final phases of developing one for a client. I'm using Django with Gunicorn/Nginx on an AWS m1.medium. The database (MongoDB) is on a separate instance. The client is paranoid about scaling and so I threw together a crude monitoring server which has the ability to spin up new AWS instances, install the app code and load balance (I know, I know, I could have used ELB. I said I was green, and it was fun writing it anyway). The question is, I don't really know what metrics I should be aware of. How will I know when my app server is under 'high load'? CPU? RAM? Request latency? All of the above? Any guidance in this area would be appreciated.


Are there new API's in Windows Phone 7 (Mango) which need new phone hardware? Gyroscope stuff? BTW, is AppHub the only Microsoft's official forum for WP7? Registration page is asking for 'Publisher name', website and payment? I just want to ask questions in the forum.


title: why the terms used in Scrum are so strange?

text: I'm not a native English speaker, currently I'm reading some articles about Scrum. I was wondering if the English terms used in Scrum seem strange to you? For example, backlog instead of todo; artifact instead of element; retrospective instead of review; even the name of Scrum, it make no sense to me as a process name. Can anyone give some hint to me? For example, I don't see the relationship between a scrum in football and iteration process. Fei


title: Non-lvalues as function parameters in C++

text: I'm reading Accelerated C++ and in Chapter 4 they bring up the concept of lvalues. There's an example of something that _shouldn't_ work, but after trying it myself I found that it does indeed work. Specifically they state that, given these functions:               // return an empty vector     vector<double> emptyvec()     {       vector<double> v;       return v;     }          // read things from an input stream into a vector<double>     // (I'm leaving out the function body here because it's irrelevant)     istream &read_things(istream& in, vector<double>& hw);      This should not be allowed:               read_stuff( cin, emptyvec() );      Because emptyvec() is an expression and returns a temporary object (a _non- lvalue_ as they called it in the book). However, this not only compiles but actually runs (Windows 7/VisualStudio 2010). So, what's going on? Was this just a bad example on the authors' part, or is there something else happening that I don't understand. Thanks.


title: How can we make a certain thing inbuilt in c language with our own header file?

text: I want to make the basic trigonometric functions in maths inbuilt functions using my own header file . so as the users can do trigonometry in c language compilers.


title: Designing a list class with filtering and sorting

text: The app I'm developing needs to display lists of items. Simple enough, but there are a number of things which can change based on user input:   * Items can be added to/removed from the list.   * The items in the list can be updated. Multiple items can be updated simultaneously!   * The filters can be updated. Multiple filters can be updated simultaneously!   * The sort order of the items can change. Possibly relevant info:   * It's a multiplatform Java app.    * One of the platforms we distribute on is MIDP, so that limits which language features/libraries/etc we can use.   * The implementation is currently split into a model class (in the common code) and device-specific view/controller classes. I've tried a couple of approaches to designing a suitable list implementation, but both have drawbacks: **Approach 1:** The platform-specific controller implementations are responsible for calling a `refresh()` method whenever anything happens which could change the list. This approach keeps the list class (model) implementation fairly straightforward, but leaves much of the responsibility up to the platform- specific controller implementations. The more logic there is in these classes, the greater the chance of bugs creeping in. It also encourages the controllers to directly notifying the view of updates, which feels like poor design. **Approach 2:** The model is entirely responsible for raising events to notify the platform- specific views of changes. The list items, filter, and sorters notify the model when they change, which then notifies the views of changes. This keeps the platform-specific classes much simpler, and feels like a stronger design (less coupling between the classes, etc). However, the list class implementation becomes much more complicated. My main problem with this approach is dealing with a proliferation of events when multiple items/filters are updated in a single operation. **My questions:**   1. Is there other approaches I could/should be trying?   2. Is there a recognised way to manage/avoid the explosion of events in approach #2?


title: Should developers do their own software releases (if there is a prod support team in place)?

text: I know there are going to always be differences depending on the particular size, staff etc, but i wanted to get feedback in general around: **In an environment where you have a production support team doing first line support and release management, is it better to simply have developers manage their own releases instead? In this case, its internal software at an insurance company but the question should be valid at any company, size, etc I think.** Currently, we have our production team do releases but there is an argument that its inefficient and that if you allowed developers the ability to do it, they will focus more on making it simple and efficient and avoid basically passing on scripts, etc to run to another team. The counter argument is that if you don't have a check and balance, you could get a software team (or an individual) that doesn't a very hacky job about getting their software out there (making on the fly changes, not documenting the process, etc) and that by forcing the prod support team to do the actual release, it enforces consistency and proper checks and balances. I know this is not a black or white issue but I wanted to see what folks thought on this so the discipline and consistency is there but without the feeling that an inefficient process is in place.


title: How to deal with asynchronous functions when you really just want things synchronized

text: I am fairly new to NodeJS and I'm having a hard time wrapping my head around the asynchronous nature of functions when I really want one call to follow the other in a synchronized way. Say for instance I am calling web service methods. Every method has a callback function. But what if I want to call 10 of them in a specific sequence? Do I really need to chain / embed all the functions in the first callback? What if the second time the chain is slightly different? Are there any elegant patterns to deal with situations where you actually do want things to be synchronous? Or should I really let go of this kind of programming get used to a different way of thinking? If that's true maybe someone can point me to a clean example of a longer chain of functions using callbacks...


title: hiring a web designer: design task

text: I need to hire a web designer. How do I test his creativity and skills before I hire him. Ideally I'd like to give him a fairly open-ended task i.e. I give him a problem statement and ask him to design a PSD file. Any suggestions on the problem statement I might give him? Also, is there a better way to hire /test a web designer?


title: How to properly validate your code?

text: I have about 4000 lines of code for a web-application in JavaScript / PHP / CSS / HTML. How can I test it properly? I only support the latest version of IE and Safari. I've worked out all the bugs. Is there a good way to test it so that I could go so far as to call the code robust? I've considered using perl Mechanize to auto fill in forms or do something similar. I also have a PHP test class to test the inner working of my PHP classes. However is there some sort of standard or conformance guidelines to be met? Is there a way to say this code passes IEEE xxx foo standards for code robsustness etc.? I have validated my HTML using W3 validators and I've validated my JavaScript using jslint.com. Here is list of dilligence items:   1. HTML / CSS passes W3 validation   2. JavaScript passes jslint   3. PHP passes internal PHP Test Class User Testing   1. Create a set of User Actions and Implement using perl mechanize or similar. Are there standards or procedures for releasing code to the web?


title: Testing Facades, Is it a good idea?

text: I stumbled across a need to create a thin I/O Layer interface to abstract away a class from the need to know about I/O               public interface IFileIOProvider {         Task WriteFileAsync(String contents, String path);         Task<String> ReadFileAsync(String path);     }      Is it a good idea to test a default implementation that _only_ falls back to standard .Net System.IO classes, no logic attached?. I think it might be overkill, but just want to get my strategy checked out by more experienced programmers


title: How does the concept of a class change when passing data to the constructor instead of method parameters?

text: Let's say we're making a parser. One implementation could be:               public sealed class Parser1     {         public string Parse(string text)         {            ...         }     }      Or we could pass the text to the constructor instead:               public sealed class Parser2     {         public Parser2(string text)         {            this.text = text;         }              public string Parse()         {            ...         }     }      Usage is simple in both cases, but what does it _mean_ to enable parameter input to `Parser1`, compared to the other? What message have I sent to a fellow programmer, when they look at the API? Also, are there any technical advantages/disadvantages in certain cases? Another question comes up when I realize that an interface would be quite meaningless in the second implementation:               public interface IParser     {         string Parse();     }      ...where an interface on the first one could serve at least some purpose. Does that signify anything in particular, that a class is "interfaceable" or not?


title: If Instance is for Class, what's for Template?

text: I am not able to find the right technical term to mention child or instance of a template.   What's the right one, child or instance or something else I am not aware of? Sorry for my unclear original question.   Its not related to any language. The Template I am talking about is a business concept in my application. Say for example, I have a "chair" template. I would set a few property values to it to create it's usable instances. I need this for naming and documentation stuff.   Shortlisted 3 terms: Instance, Definition, Child. Whats suits better?


title: Is it okay to make coding style changes on an open source project that doesn't follow best practices?

text: Recently, I came across a number of open source Ruby (or majority of it was Ruby) projects on GitHub that when checked with a code analyzing tool like Rubocop, create a lot of offenses. Now, most of these offenses include using double quotation marks instead of single quotes (when not interpolation), not following the 2 spaces per level rule, exceeding the 80 character line length rule, or using `{` and `}` for multi-line blocks. > [The] Ruby style guide recommends best practices so that real-world Ruby > programmers can write code that can be maintained by other real-world Ruby > programmers. ~ Source: Ruby Style Guide Although they are small and easy to fix, is it appropriate to change the coding style of an open source project by fixing the offenses and making a Pull Request? I acknowledge that some projects, like Rails, do not accept cosmetic changes and some are just too large to "fix" all at once (Rails for example generates over 80,000 offenses when Rubocop is run - regardless, they have their own small set of coding conventions to follow when contributing). After all, the Ruby Style Guide is there for a reason together with tools like Rubocop. People appreciate consistency so making these kinds of changes is kind of doing a good thing for the Ruby community in general, right? > [The author(s) of the Ruby Style Guide] didn't come up with all the rules > out of nowhere - they are mostly based on my extensive career as a > professional software engineer, feedback and suggestions from members of the > Ruby community and various highly regarded Ruby programming resources, such > as "Programming Ruby 1.9" and "The Ruby Programming Language". ~ Source: > Ruby Style Guide Isn't not following community coding style conventions and best practices basically encouraging _bad_ practices?


title: How does a program process concurrent executions

text: I have a console application that is run by taking the input parameters. It can be configured by passing report name parameter, for e.g. `reportgen.exe sales.xml`. It hits the database and retrieves the data into xml file and sends to sftp site. Whole of this process is logged and the `xml files` are being saved in a directory. This `exe` needs to be scheduled on daily basis, so what happens if the exe is scheduled at same time with different parameters. Is it thread safe and can be considered as independent execution doing what it supposed to do? **Edit:** It uses log4net for logging the debug info. into a file. So, how does it write log statements into single file for concurrent executions.


title: FRC Robotics Laptop? Windows 7 or 8?

text: I’m mentoring FRC Robotics team and we’re buying a new computer. I’m looking at Lenovo Thinkpad W540. We’ll be using C++/WPILIB and SolidWorks for design. Anyone out there have experience with this laptop? Should we stick with Windows 7-64bit or go to Windows 8? I’m also curious to know whether anti-virus software interferes with performance … errr ... should that be separate discussion? Thanks!


title: How much should we spend on improving software security?

text: Is there a "scientific" method to determine how much resources/money should be spent on improving the security of a piece of software? I work in a team where our work is prioritized by a product owner (ala Scrum). The product owner is kind of sales driven and focuses on new functionality requested by customers and less on the infrastructure. I think I need a way to convince him that we need to spend more time on improving the security. Of course I don't want to convince him by spreading fear and I'm not sure myself how much money we should spend on improving security. Of course, the security of our software is improved all the time but I suspect - without knowing for sure - that it would be sane to double the efforts in the area. I have a weak memory reading about this, where something like the following was suggested:   1. Think about a weak point in the security in the system   2. Estimate what a succesfull attack would cost in terms of lost/dis-satisifed customers (X)   3. Estimate how likely that it is that this would occur in a given year. (Y)   4. Calculate how much should be spend on fixing the weak points, based on X and Y. We don't have to solve the issue immediately, but we should spend Z percent on it.


title: How to handle assumptions while designing any system?

text: I have been going through various system design examples to understand how we approach any system design question. Here is what I have understood till now.   1. Know the system first and find out how it works.   2. Think of all use case.   3. Identify key components and their responsibilities.   4. Connect all the components so that they can communicate to each other.   5. Use all standard practices while integrating components and if possible use standard design patterns. Sometimes we make assumptions about the system, so those assumptions should be used to remove one use case or to add a variation. I will put this question in context of Parking Lot design. If I assume that Parking Lot is not commercial, and it is free parking lot, then design of parking lot should handle free parking lot as one of use cases , and it should be generic. OR Simply design parking lot which will never work for Commercial parking lot. Main idea is that if someone asks you to design a parking lot and that is free parking lot, then design should be generic or specific?


title: How do you make the node_modules folder read/write in WebStorm

text: I'm using WebStorm on a Node.js project and want to edit the files in the node_modules folder but WebStorm won't allow this. I found the padlock at the bottom right on the IDE but switching that between lock/unlock makes no difference. Any ideas?


title: What is the best computer programming content that an aspiring technical cofounder (for a 2-person team) can consume?

text: **My background is as follows:** I have almost no programming experience to speak of (I programmed a game mod in Jr. High and have since been dormant for 15 years). I'm quite comfortable with both vim and emacs (having used them general purpose text editing in the past). I have a graduate degree in mathematics with research experience in logic. I've read from cover to cover _The C Programming Language_ (doing about 1/4 of the exercises) and _The Pragmatic Programmer_. I felt that the concepts discussed in these books came quite natural to me, although I suspect _reading_ about programming is akin to reading about how to have sex (i.e., next to worthless in practice). **My primary programming goal is to be able to construct rough software prototypes as rapidly as possible.** I'd also like to understand the big picture of how things are operating at the software level. Unfortunately, I don't yet know if our first prototype is going to involve an iOS application or a web app. With this in mind, what's the best technical content I can consume in the short-run (with an eye towards rapid prototyping) before I know what it is I'm actually trying to build and test?


title: Is video game programming usually physics related?

text: I know this is obviously not true for some games, minesweeper, card games, etc. But what about any game involving simulating the real world environment. Obviously these games have some form of a physics engineer powering the graphics. For someone like me who personally did not enjoy physics but loves video games, do I have a chance at ever getting involved in the development cycle of a video game such as this while disliking physics?


title: What are some best practices for minimizing code?

text: While maintaining the sites our development team has created, we have come across include files and plugins that have proven to be very useful to more then one part of our applications. Most of these modules have come with two different files, a normal source file and a min file. Seeing that the performance and speed of a page can be increased by minimizing the size of the file, we're looking into doing that to our pages as well. The problem that we run into is a lot of our normal pages (written in ASP classic) is a mix of HTML, ASP, Javascript, CSS, and include files. We have some pages that have their JS both in include files and in the page, depending on if the function is only really used in that page or if it's used in many other pages. For example, we have a common.js and an ajax.js file, both are used in a lot of pages, but not all of them. As well as having some functions in a page that doesn't really make sense to put into one master page. What I have seen a few other people do online is use one master JS file and place all of their javascript into that, minify it, gzip it, and only use that on their production server. Again, this would be great, but I don't know if that fully works for our purposes. What I'm looking for is some direction to go with on this. I'm in favor of taking all of our JS and putting it in one include file, and just having it included in every page that is hit. However, not every page we have needs every bit of JS. So would it be worth the compilation and minifying of the files into one master file and include it everywhere, or would it be better to minify all other files and still include them on a need-to-use basis?


title: PHP Simplest XML tokenizer for string processing?

text:
I need to do some _text processing tasks_ with _short XML fragments_. The section "details" shows an example... My solution is to use a _tokenizer_ based on _regular expresions_ , but it is not elegant and not uses any build- in function. The candidate build-in functions (that others indicates to me) are strtok and SimpleXML. So, my question have two parts:   1. **My assumptions are correct?** There are no other "candidates", only strtok and SimpleXML? Is correct to think DomDocument as an "elephant" (with big CPU overhead) for a simple _text processing task_?   2. **How to use SimpleXML to do the same (illustred) task?** PS: I not need all algorithm or implementation, only some clues. * * * # Details PHP offers a tokenizer, strtok, very simple, and I not see how to use it with XML string. The option, SimpleXML, is perhaps heavy for tasks like ''text processing'' (see this example and the below), and is more than a tokenizer. What exactly I whant to say with "tokenizer" and "text processing"? See example below. I used a "regex parser", but **I would like an algorithm based on some built-in function like SimpleXML, if it is simpler and faster**.                $xmlFrag = '
  Hello world!

  Beautiful day today.
';           // TOKENIZING TAGS AND ENTITIES:      $reg=array();      $xmlFrag = preg_replace_callback(         '/<!\-\-.+?\-\->|<.+?>|&[a-z0-9]+;/is',          function ($m) {             global $reg; $reg[]=$m[0]; $n=count($reg)-1;             return "##$n#";         },         $xmlFrag      );      echo $xmlFrag;     // results:      //  ##0###1# Hello world!##2#  ##3###4###5# Beautiful##6# day today.##7#           // PROCESS THE TEXT: any, in one step. Example: lower, upper, change orthography, etc.      $xmlFrag = strtoupper($xmlFrag);      echo $xmlFrag;      //  ##0###1# HELLO WORLD!##2#  ##3###4###5# BEAUTIFUL##6# DAY TODAY.##7#           // EXPAND TOKENS:      $xmlFrag = preg_replace_callback(         '/##([0-9]+)#/is',          function ($m) { global $reg; return $reg[$m[1]]; },         $xmlFrag      );      echo $xmlFrag;      //
  HELLO WORLD!
       //
  BEAUTIFUL DAY TODAY.
      * * * ## Using SimpleXML How to implement a SimpleXML algorithm to resolve the illustrated problem (code above)? PROBLEMS:   * Load a XML with named entities (as ` ` in the example).   * Traverse XML to get only text nodes. With `$sx->xpath('//text()');` I can not edit the nodes. ## Using DomDocument It is out of context, because my XML fragments are short and DomDocument imposes a big CPU overhead (? is this a preconception?) for the simple text processing.


title: Should I open pull requests from a branch on the official repo or my fork?

text: I have commit access on an open source project named Foo hosted on GitHub (there are many other committers if that is relevant). I would like to make a change via pull request so that someone else reviews it before it gets committed to the master branch of the Foo codebase. To make this pull request, I can either make a branch on the official Foo repository or I could fork Foo and commit to a branch on my fork. What issues should I consider when I'm deciding whether to make my pull request on the official repo or my fork?


title: What is the best way to store configurations of shell/script code to execute later?

text: I am working on a tool (Python, may or may not be important) that will allow a user to maintain a configuration file containing arbitrary shell and/or language code to be executed on particular events and intervals. The code will potentially involve multiple statements. I understand there are potential behavioral and security risks associated with executing arbitrary code from a file, but I don't think this is a concern because the configuration file is managed only by the end user. However, let me know if I'm overlooking something major. My main question: what is the best way to store this code in a configurable way? * * * Some concepts I'm considering to store the code... In a shared config file (which many Python libraries already look for):               # setup.cfg     [my_program]     command_1 = cd /tmp && touch foobar      In a YAML file:               # my_program.yaml     command_1: cd /tmp && touch foobar      In a source file as arguments to `subprocess.call()`:               # settings.py     command_1 = [['cd', '/tmp'], ['touch', 'foobar']] # requires special handling of 'cd'      In a source file as a function:               # settings.py     import os     import subprocess     def command_1():         os.chdir('/tmp')         subprocess.call(['touch', 'foobar'])


title: Store HighRes photos in Database or as File?

text: I run a site which has a couple of million photos and gets over 1000 photos uploaded each day. Up to now, we haven't kept the original file that was uploaded to conserve on space. However, we are getting to a point that we are starting to see a need to have high-res original versions. I was wondering if its better to store these in the filesystem as an actual file or if its better to store them in a database (ie: mysql). The highres images would be rarely referenced but may be used when someone decides to download it or we decide to use it for rare processes like making a new set of thumbnails sizes/etc.


title: C++ and function pointers assessment: lack of inspiration

text: I've got an assessment to give to my students. It's about C++ and function pointers. Their skill is middle: it the first year of a programming school after bachelor. To give you something precise, here's a sample of a **solution** of one of **3** exercices they had to do in 30 minutes (the question was: " _here's a version of a code that could be written with function pointers, write down the same thing but with function pointers_ "):               typedef void (*fcPtr) (istream &);     fcPtr ArrayFct [] = { Delete , Insert, Swap, Move };          void HandleCmd (const string && Cmd)     {         string AvalaibleCommands ("DISM");         string::size_type Pos;         istringstream Flux (Cmd);              char CodeOp;         Flux >> CodeOp;              Pos = AvalaibleCommands.find (toupper (CodeOp));              if (Pos != string::npos) {             ArrayFct [Pos](Flux);         }     }      * * * Any idea where I could find some inspiration? Some of the students have understood the principles, even though it's very hard for them to write C++ code. I know them, I know they're clever, and I'm pretty sure they should be very good project managers. So, writing C++ code is not _that_ important after all. Understanding is the most important part (IMHO). I'm wondering about maybe break the habits, and give half of the questions about the principle, or even better, give some sample in _other_ language and ask them why it's better to use function pointers instead of classical programming (usually a big `switch case`). Any idea where I could look? Find some inspiration?


title: Actor based concurrency and cancellation

text: I'm reading about actor based concurrency and I appreciate the simplicity of actors sequentially processing messages on a single thread. However there is one scenario that doesn't seen possible. Suppose that actor A sends a message to actor B, who then performs some long running task and returns a completion message to actor A. How can actor A force actor B to cancel the long running task after it has started? If actor B is running the task in its message queue thread, it won't pick up the cancellation message until it had completed the task; if actor B runs the task in a background thread then it seems to be violating the principle of actors. Is there a common way that this scenario is handled with actors? Or does each actor language/framework take a different approach? Or is this not a suitable problem to tackle via actors?


title: What is a good script language for writing server administration tasks?

text: I am administering hundreds of RHEL servers. There are many daily tasks to perform. Right now I am working with bash scripting and python. I was wondering if other languages such as Erlang, Lua, Ruby, Haskell, or Clojure.


title: What are the steps involved in creating a testing process?

text: I've been asked this question as part of an assignment. The question is a bit vague, and after searching the Internet, I cannot seem to find any particular set of steps related to this question. The best I could find are the following:   1. Design test cases   2. Prepare test data   3. Run program with test data   4. Compare results to test data Are these valid steps which can be done to create a test process? Or am I misinterpreting the question?


title: Can initial inefficient solutions INSPIRE better ones and thus lead to faster problem solving?

text: When faced with writing an algorithm to solve a small project/problem is it better to come up with pseudo code that isn't efficient/optimum but solves the problem and then try to use the inefficient code to **inspire** a better/good solution? The solution must be acceptable, not necessarily "super-amazing-out- of-this-world" type. The answer is subjective, but I am looking for a general opinion or consensus from experienced programmers in order to develop a better algorithm generation/problem solving process. _The reason I ask this is that I often start composing the most intuitive algorithm but then get derailed thinking about how inefficient it is and if I should be using a better data structures etc etc._


title: How to find siblings of a tree?

text: On my interview for an internship, I was asked following question: > On a whiteboard write the simplest algorithm with use of recursion which > would take a root of a so called binary tree (so called because it is not > strictly speaking binary tree) and make every child in this tree connected > with its sibling. So if I have:                      1           /   \            2     3           / \     \          4   5     6         /           \      7             8      then the sibling to 2 would be 3, to four five, to five six and to seven eight. I didn't do this, although I was heading in the right direction. Later (next day) at home I did it, but with the use of a debugger. It took me better part of two hours and 50 lines of code. I personally think that this was very difficult question, almost impossible to do correctly on a whiteboard. How would you solve it on a whiteboard? How to apprehend this question without using a debugger?


title: Is this a correct situation to use a constant?

text: So my professor was giving back some feedback on a project I've been working on. He docked a few marks for this code:               if (comboVendor.SelectedIndex == 0) {       createVendor cv = new createVendor();       cv.ShowDialog();       loadVendors();     }      This is in a combobox "index changed" handler. It's used when the user wants to create a new vendor, my top option (index 0, that never changes) opens the "Create a new Vendor" dialog. So the content of my combo box ends up looking like this:               Create New Vendor...     Existing Vendor     Existing Vendor 2     Existing Vendor 3      His problem is with the first line code:               if (comboVendor.SelectedIndex == 0)      He claims that the 0 should be a constant, and actually docked me marks because of that. He claims I shouldn't use literals in my code at all. The thing is, I don't understand why I would want to make that code in that situation a constant. That index will never change, nor is it something that you would need to tweak. It seems like a waste of memory to keep a single 0 in memory that's used for a very specific situation and never changes.


title: How can I test a parser for a bespoke XML schema?

text: I'm parsing a bespoke XML format into an object graph using .NET 4.0. My parser is using the `System.XML` namespace internally, I'm then interrogating the relevant properties of XmlNodes to create my object graph. I've got a first cut of the parser working on a basic input file and I want to put some unit tests around this before I progress on to more complex input files. **Is there a pattern for how to test a parser such as this?** When I started looking at this, my first move was to new up and XmlDocument, XmlNamespaceManager and create an XmlElement. But it occurs to me that this is quite lengthy and prone to human error. My parser is quite recursive as you can imagine and this might lead to testing the full system rather than the individual units (methods) of the system. So a second question might be **What refactoring might make a recursive parser more testable?**


title: Instantiating a class implementing an interface

text: I have an interface called `Cell`. In the start of the code, I read input data from which I can come to know the implementing class (not as a class object but I can know for example the string). And after that I need to call the constructor for the implementing class to initialize an object. What would be the best way to implement that. The first thing in my mind is to do something like this (`Cell` is an interface, `Sphere` and `Rectangle` implements `Cell`. I can set a boolean flag called `sphere` after reading the input data):               Cell startcell;     if (sphere)         startcell = new Sphere(0);     else         startcell = new Rectangle(0);      But is this good design?


title: Parallel Threading in Multi-Language Software?

text: I'm developing a software that contain many modules/Daemon running in parallel manner, what i'm looking for is how to implement that, i cannot use Thread because some of those modules/Daemon are perhaps implemented in other languages (C,java,C#...). For example I'm using C for Hooking Messages exchanged between Windows kernel and top level applications, Java/C# to use some free library to simply parse XML(for example) or to accept and execute commands over the network..this can be done by C Language but just to improve productivity... Finally for GUI I'm using Ultimate++ (c++) that is like the main process that call and monitor(activate/deactivate/get state) of all other modules/Daemon through an interface. I admit that the development of each module/Daemon in a separate language greatly facilitates maintenance, but especially I am obliged to do that.. What is the best practice way to do that ? All helps will be appreciated.


title: What is preferred for file I/O in Java?

text: Of the three   * BufferedReader/Writer  * Binary Streams  * Channels     which is more preferred **in real life** for file I/O in Java and why?   I prefer channels for binary data to be put into file or read from and BufferedReader/Writer for String data


title: Does Dart have any useful features for web programmers?

text: http://www.dartlang.org/ I've checked out the site very briefly, and got curious. Is there any advantages of using Dart? Is it just a replacement for JavaScript? It looks like simpler Java. Writing quite a lot of C# at work, the language feels very much like what I'm used to, so learning the syntax looks like a breeze to learn. Has anybody any opinions or experiences with the language? (Compared to CoffeeScript (= I'm not doing Ruby syntax) the syntax looks more familiar to me).


I just read a question asking how Facebook blocks console-based script attacks. The reason for this block was to prevent a recently famous "hack" where one would trick a user to inject a malicious script through the console with the promise of something (instant likes, who viewed me etc). And then I wonder: _Why do browsers these days ship with dev tools anyways?_ Now, some thoughts:   * Not everyone is a developer, and one wouldn't have any need for these tools just to surf the web and read some email.    * If one really would want to debug a page, they could have just shipped it as a separate add-on, much like how Firefox had Firebug before it also had its own dev tools.   * If troubleshooting was the concern, then wouldn't an error console, like in Firefox 3, suffice? And browsers in the older days didn't have debugging tools, only some interface to show the errors (IE had the status bar. Firefox had an error console).   * Wouldn't it be an additional weight to the browser if it had those tools tucked in? So why is this the trend in browsers these days? Is there something I missed that makes vendors push with shipping the tools along with the browser.


title: How did programmers implement Linked list ideas before the object oriented paradigm?

text: Linked lists, as far as I have seen, are largely implemented using object- oriented ideas. (having an object that holds some information and the address of the next link). How were Linked-lists implemented before the object- oriented paradigm came out? Were they only invented(?) once the OOP was developed?


title: How to make consistent progress towards the goal of becoming better, as opposed to just coding for fun?

text: I'm in senior year in high school. I enjoy programming (Java) very much and aspire to do it as a career in the future. However this isn't the topic of this question. My question is: how can I start making **consistent progress towards the goal** of becoming a great programmer? What I mean is this: I work on my own projects, enjoy doing so and feel like I'm slightly improving with every project I finish. However, I don't feel like I'm consistently moving towards 'the goal of becoming a great programmer'. I want to have a sense of 'working towards the goal'. What I feel right now is more like "I'm coding stuff which is a lot of fun and I'm improving, but I don't feel like I'm **'making progress towards my goal'** ". "Slightly improving over time because I'm coding stuff" doesn't really feel like "making progress towards a goal". To those of you who are experienced developers: **what advice can you give me on making consistent progress towards the goal of becoming great at programming,** as opposed to just coding stuff for fun?


title: Localizing an app whose data is tied to one language

text: I develop a mobile app that displays information about the bus system in one U.S. city. The de facto official language is English, but there are many students from other countries—China and South Korea, especially—and I’d like to internationalize and localize my app, both to make it more appealing to non-native English speakers and because I want the experience of localizing an app. I’m a little hazy on where I should draw the line between strings that should be localized and those that should stay in English. The bus system itself uses only English names. It was easy for me to decide not to localize the stop names: there are thousands of them, meaning that translations would be expensive, and moreover most of the stop names are proper nouns that wouldn’t necessarily _have_ Chinese translations (for example), making localization pointless. Since the stops will only ever be displayed in English, is it reasonable that the app’s list of all stops should only ever use English collation? The bus system uses colors to name most of its routes. It _would_ be possible to translate these, but should I? The sign on the front of the bus is only ever going to display the English name of the route. With that in mind, is there any benefit to my app displaying a translated name that the user will just have to mentally convert back into English anyway? (I’m leaning toward “no”.)


title: Why is asynchronization so popular in Javascript?

text: Asynchronized programming seems to be natural in Javascript - it is the "first choice" to do many things. But in most other programming languages, asynchronization is more like a second choice rather than first choice. What makes asynchronizated programming so popular and natural to Javascript?


title: Code checking role

text: Consider there is a manager and a programmer in a project. A manager crates a task which a programmer performs. In this situation who should check that a programmer didn't make some non- testable mistakes like using non thread-safe map in a singleton service? And who checks the overall project code structure?


title: Need recommendation for transferring ASP.NET MVC skills to PHP

text: I am looking to translate my skills in .NET to PHP - specifically in regards to ASP.NET MVC. At work I am currently using .NET MVC 2.0 on a variety of projects and thoroughly enjoy the platform. Specifically I enjoy the very minimal configuration required to get a project up and running (just create the project, define routes, and start coding), as well as the ability for controller actions to return different items (i.e. `ActionResult`, `JsonResult`). Another piece I really like is the way the view/model interaction can be handled. For example I like being able to call return View(model) and having a view page (.aspx) load and having the full model object available to the view, regardless of the model type. I'm looking for a PHP implementation of MVC that is the most similiar to what I am already familiar with. I don't anything apart from the MVC functionality. I've looked at Zend, Symfony, CodeIgniter, etc. and, while they look like they'll be fun to play with in the future, they provide much more functionality than I need. I'd prefer to write my own DAL, form helpers, delegate handlers, authentication/ACL pieces, etc. In short, I just need something to handle the routing and view interactions and will worry about the model implementation myself. Can someone please point me to some lightweight code that accomplishes or comes close to accomplishing my objectives above. Or, can someone identify just the portions of a larger framework that do the same (again, I'm not currently interested in implementing something on a big framework, just the MVC portion and want to implement the model portion myself as much as possible).


title: What skills should I learn in order to move into a permanent systems analysis role?

text: I have been with a software services firm for 5 years and have fallen into a "jack of all trades" role, which I am looking to move out of. I've spent about 1 year each in programming (VB/VB.NET), application support, systems analysis, and most recently, software testing, which in my current position is all manual. I've really lost interest in the programming and testing roles; I would prefer a position where I get to work more with _people_ , such as systems analysis. I even got a chance to be a trainer at the same company for a few months, a temporary position which I enjoyed very much. Given that most of my real experience is with software, support, and testing, what knowledge areas and skills should I focus on learning and mastering in order to make myself an attractive candidate for a permanent position as a business/systems analyst?


title: How to talk a client out of a Flash website?

text: I have recently been doing a bunch of web side projects through word of mouth recommendations only. Although I am much more a of a programmer than a designer by any means, my design skills are not terrible, and do not hate dealing with UI like many programmers. As a result, I find myself lured into a bunch of side projects where aside from a minimal back end for content administration, most of the programming is on front end interfaces (read javascript/css). By far the biggest frustration I have had is convincing clients that they do not want Flash. Aside the fact that I really do not enjoy Flash "development", there are many practical reasons why Flash is not desirable (lack of compatibility across devices, decreased client accessibility, plug-in requirements, increased development time, etc.). Instead of just flat out telling the clients "I will not build you a flash website", I would much rather use tactics to convince/explain to them that this is not what they actually want, ie: meet their requirements any better than standard html/css/js and distract users from their content. **What kind of first hand experience do others have with this? How do you explain to someone that javascript/css/AJAX is usually a better option for most websites? Why do people want to use Flash so bad to begin with?** This question pertains to clients who do not have any technical reasons for wanting flash, but just want it because they think it makes pretty websites.


title: Is this database design sound and fully normalised?

text: I'm creating a database to store words. The intended usage is to query the database to find a word matching a set of filters. E.g. if I wanted to find a word with < 10 letters, < 3 syllables, rhymes with 'at' and matches the tag 'animal', it would return 'cat', 'bat', 'wombat'... Unnormalised, the table would look like this: (primary key is marked by PK, contextual information is given in square brackets)               Word(         WordID PK,         Word,         AltSpelling, [another accepted variant e.g. "color"/"colour"]         Rhyme, [the rhyme part of the word, e.g. for "wombat" the rhyme is "at"]         Pronunciation, [how the word is pronounced in IPA]         SyllableCount,         Tags, [tags relate to meaning of the word, e.g. "apple" would have the tags "round", "fruit", "plant" etc.]         Categories, [categories are how the word would be hierarchically categorised, e.g. cat comes under the category "animal"]         WordClasses [the word class that a word can be used as, e.g. "rest" can be Noun and Verb]     )      This is the Entity-Relationship diagram to describe how the database should work: ![Word database Entity-Relationship diagram](http://i.stack.imgur.com/isopb.png) And finally, this is the solution I've come up with for a normalised database design. FK indicates foreign key, CPK is Composite Primary Key.               Word(WordID PK, Word, OtherSpelling, RhymeID FK, SyllableCount)     Rhyme(RhymeID PK, Rhyme)     Pronunciation(PronID PK, WordID FK, Pron, DialectApplicable [the dialect in which the pronunciation is used, e.g. RP, SE, BrE, AmE])     Tag(TagID PK, TagName, TagReferentCount [the number of words to which the tag applies])     WordTag(WordID CPK FK, TagID CPK FK)     Category(CategoryID PK, CategoryName, CategoryReferentCount [cf. TagReferentCount for categories])     WordCategory(WordID CPK FK, CategoryID CPK FK)     Class(ClassID PK, ClassName, ClassReferentCount [cf. TagReferentCount for word classes])     WordClass(WordID CPK FK, ClassID CPK FK)      The question is twofold: is this database design fully normalised? And more importantly, is it sound? I have no practical experience with databases, so I'd like to know if I've made any mistakes, or if the design can be improved/optimised.


title: Development Cost of Google Chrome

text: How much money did Google throw at the development of Chrome ? The actual figure is probably not public knowledge. An educated guess would be fine. _Bonus points_ for time-series data :D


title: Combining source files, like header files

text: I have a project where my files have gotten out of hand because of the volume of them. I have started to combine classes of similar types in single header files because you can, and it still is good practice, now can i do the them same for those classes functions, that are declared in the source files. Is it a good idea to combine several classes functions in a single source file, if the classes are say all sub classes of the same super class?


title: Should I develop a product with minimal use so I can say I developed it?

text: I appear to have done something wrong here, so let me try to rephrase this more simply so I stop giving the wrong impression. I'm in the planning stages of a project right now, on my own time; I'm currently defining the scope of the project. I can see this application also releasing an Android app; furthermore, I've long wanted to get into Android development, and being able to list an actual project on my resume seems likely to be beneficial. However, the application itself is far more useful on a PC than a tablet and almost useless on a smartphone; odds are, very few (if any) people would _want_ to use this on Android. I want to develop it, but I anticipate almost no demand. Should I do so under the idea that the experience is useful, or should I either keep it private or not do it under the idea that an app nobody uses looks bad to future employers? * * * Original Question: I'm planning out an open-source project, mostly to beef up my resume (ETA: Okay, I'm doin it mostly because I want to do it, but I'm releasing it as open-source rather than keeping it to myself so I can list it on my resume easier). I'm considering doing an Android version, intended to run on tablets. But it's not the most useful thing to have on a tablet; neither I nor my partner can really conceive of anyone wanting the product. However, adding "developed for Android" to my resume seems to be a good selling point, and I'd like to get into mobile development. Should I make an app nobody wants so I can say I made an app? Or should I hold off until I have a better idea? Edit: I must have phrased things badly, some of the answers seem to have the wrong idea. I'm doing the entire project for the hell of it; if I don't do an Android version of this particular project, I'll complete it sooner and plan something else and do that. It's a given that I'm always going to be doing a project and that I want to do this project. The question is, should I instead do something more useful as a "let's play with Android" project? Will making something nobody wants hurt me in the long run?


title: How to explain to my manager the importance of separation of concerns?

text:
I'm an extremely novice web programmer working at a 2 person shop building websites, and we're in the process of writing a simple website template system in PHP from scratch. My manager is entirely self taught. He has been insisting that we put our HTML directly quoted in variables, mixing our back end code with the front end stuff.               $foo = "
" . $bar . "
                          ";          echo $foo;      He claims that it is easier to work with this way. I insisted that we should at least use PHP tags in our HTML, rather than the HTML in the PHP.
<?php echo $bar; ?>
                I feel like this is a real pain in the ass to read and it just looks like a mess. I think it would be a lot easier to separate the logic from the presentation, but he is certain that his way is best. How can I explain the importance of this so that he will understand? I can't put it into words, exactly. EDIT: Think you guys could leave a comment when you're down voting me? I have no idea how to fix my question if you just down vote it and leave without suggesting improvements.


title: What does it mean when some technology is a "standard"?

text: I started learning Java EE 7 and I am frequently coming across this term "standard", and I don't understand what it means. So, for example, here is a quotation from this book: > Contrary to SOAP and the WS-* stack, which rely on W3C standards, REST has > no standard and is just a style of architecture with design principles. REST > applications rely heavily on many other standards: HTTP, URI, URL... I have some idea of what that might mean, but I'm not sure. The best explanation that I have come across is the definition from here.


title: Is a book about MySQL 5.1 still relevant, with the release of MySQL 5.5?

text: I am considering purchasing High Performance MySQL (2008). This book discusses MySQL 5.0 and 5.1. Is this book still relevant today, or is it too old?


title: I have an unordered list of rectangles and their neighbors on four sides with no origin. How can I efficiently convert this into a grid?

text: I am writing a GtkGrid-like container for my GUI library for Go, and I'm trying to write the actual layout part of the code. Basically, I have an unordered list of controls. Each control is a rectangle, and each list entry contains a pointer to the control to its north, south, east, and west. What I don't know is how to convert this back into a grid efficiently. At first I thought I could use "the top-left control" to mark (0, 0) on the grid. But what's the top-left of               [ ][ ][X]     [ ][X][X]     [X][X][X]      Any other solution I can think of runs in at least O(n^k) time, since I need to traverse the list multiple times to figure out what each row is, etc. So what other approach can I use? Thanks. The algorithm will need to be able to start from any control in the list. (Go programmers: the reason for this is that the list is a map.) I can say that there will be no freestanding controls (all controls must be attached to another control, but can be attached on any side at any time). (Except, of course, if there is only one control at all, but I imagine this scenario falling out of the solution.) (I hope this is in the right subdomain...)


title: Displaying Fibonacci sequence

text: wrote a program to calculate and display the first 20 fibonacci numbers, the sequence goes as follows: 1, 1, 2, 3, 5, 8, 13... (each number is the sum of the previous two numbers) The problem is that the numbers that get displayed are from 2 onwards , the first and second numbers of the sequence do not get displayed , could someone tell me what needs to be done to correct this? Code:                       private void button1_Click(object sender, EventArgs e)         {             int previousNumber = 1;             int currentNumber = 1;             int nextNumber = 1;                  while (currentNumber <= 11000)             {                 nextNumber = previousNumber + currentNumber;                 previousNumber = currentNumber;                 currentNumber = nextNumber;                 textBox1.AppendText(Convert.ToString(nextNumber) + " ");                     nextNumber++;                  }         }


title: Client / Server dependencies with Continuous Integration

text: I'm starting to use continuous integration for one of my projects and had some questions about structure and architecture. It's basically a multi-device webservice that is split into one server repository and multiple device-specific client repositories. My question is the following:   * Since clients are dependant on the server to run their tests, does it make sense to split them into another repository ? I did some builds with Travis CI as examples and it worked great but now that I want to add tests, it's raises the issue of being dependent on the server project. Server that itself also has it's own build and tests. From a project architecture side it makes sense to split server and client repositories but I have troubles looking at the big picture and the CI server integration.


title: Usefulness of "milestones" in agile development

text: A lot of issue trackers support something called "milestones". I've never found a use for them. It seems that milestones are only useful when you do big, scheduled pushes, but not if you roll out new features and bug fixes as they're completed. When/how would you use milestones to organize agile development?


title: How should I handle application settings in C#?

text: I am pretty new to the .NET framework so please bare with me. I am writing a time counter in C#, that counts the amount of time that has elapsed since a particular moment in time. That moment in time, as of right now, is hard coded. I would like that to be configurable. That and a couple of other values. So, I have created a windows form and it has two user controls on it: one that is the main screen, and another that is the config screen. The application opens on the main screen and I can then use a button to get to the config screen. What I want to do is to go into the config screen, enter my name and age in a textbox, enter a certain date (possibly with the date-time picker) and click a save button. Those values that I entered should then display in the appropriate places on the main screen, until I go back to the config screen and enter new values and save them. How would I go about doing that?


title: Java "module" size

text: Is it sensible to have micro-modules, say with only a very few (perhaps one) class in it? Or should I store things in bigger repositories? I am long-time Java developer with a software-engineering background. I try and write well encapsulated, focussed OO code. I have previously written code in large modules/projects/repositories with main module depending upon "common" modules. "Common" modules seem to be a code-smell in the same way as common/util classes - a sign that someone hasn't thought what the real, clean encapsulation is. I am now wanting to publish some articles on a blog and back them up with code on BitBucket, with 1 article with its own module & repository. I like clean dependencies, hate duplication, etc and there are natural downward dependencies from 1 module to "common" code. Java doesn't make dependency management very easy (hopefully fixed in Java 9 with Jigsaw), but interestingly Google Dart has a very nice mechanism and seems to recommend small, tight modules (and presumably repository per module). I'm thinking of small modules of Java, with Maven dependencies. Each module in its own repository. Jar's published on some maven site. EDIT: 1) I want to write some blog posts. Each post will be about a different topic. Each topic will relate to a cohesive module of code. I want readers to be able to download the module of code for the post. 2) I am using Bitbucket as my git repository. Point 1) implies (?) that I need a repository per module/blog article. 3) I'm trying to do things **reasonably** correctly: don't need perfection 4) Blog articles are only part of it: I want a good decomposition into modules for sound software engineering reasons. 5) I'm not ready to make my repositories public yet, they are incomplete, but these are the modules I currently plan: - 5a) Validation - just a single class with useful validation (I like DbC-like stuff!) 5b) HTML generator - nice module to generate HTML from Java - depends on Validation 5c) Swing "panning" component - again depends on Validation 6) Each of the modules in 5) depend upon Validation and are also discrete modules. So, should I have 6a) 3 x repositories (allowing people to easily pick and mix) 6b) 1 x repository building a single jar 6c) 1 x repository building 3 x jar, 1 per "module"


title: Understanding Arithmetic In C

text: I have an embarrassingly simple question, but I need to make sure I understand this correctly. I have a *.c file with the following line:                   CSRConstant = 2*macroParticleCharge*particleCharge/pow(3*rho0*rho0, 1./3.)/(4*PI*epsilon_o*particleMass*sqr(c_mks));      Is this interpreted as: ![enter image description here](http://i.stack.imgur.com/yT3MG.png)


title: How to ideally calculate profit margin with zero sales

text: How do you handle the following scenario without null? You have this problem (In Java):               BigDecimal sales = ...;     BigDecimal cost = ...;     BigDecimal profit = sales.subtract(cost);     // Profit Margin = profit / sales     BigDecimal profitMargin = profit.divide(sales, 20, RoundingMode.HALF_UP);      Because `sales` is sometimes zero, we turn the last line into:               BigDecimal profitMargin = sales.compareTo(BigDecimal.ZERO) == 0 ? null : profit.divide(sales, 20, RoundingMode.HALF_UP);      In which case if `profitMargin == null`, then we know what that means. If you make `profitMargin` = 0, that isn't really correct, nor is `infinity` a good value either. It seems best that it would remain **undefined**. Yet, it is an "unexploded bomb." So, what's the best way to handle this? This questions as originally asked on Stack Overflow, and also referred me to the question Are null references really a bad thing?


title: Best techniques for an AI of a card game

text: I’m trying to develop an AI for a card game and I’m a bit stuck about the technique/algorithm I should use. Here are a few assumptions about the game:   * After the cards are distributed to players, there is no randomness. I mean here that every player can choose which cards he plays but no random process occurs as when distributing the cards at the beginning of the game.   * There is restriction about the cards which can be played when a card was already played.   * The player which wins the trick, plays then first. E.g. Player 1 plays a card, Player 2 plays a card and wins. Then Player 2 plays a card and then Player 1 plays. I know a lot of hints/rules (e.g. if I know the player has cards A, B, C then I should play D) which helps me to win to the game. Thus I first wanted to use a Bayesian network to describes those rules. The problem is that I don’t know any probabilities to assign, but I could compute an heuristic using the history of played games (against a human). Second problems, it is very likely that I don’t know all rules and that there is some implicit rules which are needed by the AI to find the optimal play. I’m unsure if this would be a good way to develop an AI for such a card game? I am also wondering if there is others techniques which would best fit to the problem. For instance, I had a look at minimax (maybe with a pruning algorithm), but would be a good option for this problem? I’m quite unsure since the most important plays are at the beginning of the game when there is the highest unknown parameters (most of cards are not played yet).


title: Pass structure as an argument in c# method

text: I want to know if it is possible to pass a Structure as a parameter in c# method and if possible, is it a good practice to do so? I have a c# method which is taking six arguments, i really hate that. I could create a carrier class for that and pass it as an argument, but i want to know if structure could do the job. I want to mention here that few arguments to that method are of ref type and few are of value type.


title: When should we use weak entities when modelling a database?

text: This is basically a question about what are weak entities? When should we use them? How should they be modeled? What is the main difference between normal entities and weak entities? Does weak entities correspond to value objects when doing Domain Driven Design? To help keep the question on topic here is an example taken from Wikipedia that people can use to answer these question: ![enter image description here](http://i.stack.imgur.com/KTj4v.png) In this example `OrderItem` was modeled as a weak entity, but I can't understand why it can't be modeled as a normal entity.   Another question is what if I want to track the order history (i.e. the changes in it status) would that be a normal or weak entity?


title: How important is to be able to write code like you would write prose

text: Recently I heard of a company that, for interviews, asks potential employees to stand up and write out code on a whiteboard. Apparently that freaked alot of interviewees out. This got me thinking and even though I consider myself a reasonable programmer, I would be hard pressed to write lengthy code out without referring to previous code I had written or doing a quick Google search. How many programmers could safely say "Yes I could write all my code out just like I was writing an email"?


title: Future of desktop applications on Windows 8

text: There are a lot of threads discussing existence of WPF/Silverlight/HTML5 on Windows 8, I just need to clarify the picture about desktop applications only, I have following queries to the experts   1. What are the technologies available for developing desktop applications on Windows 8?   2. What are the technologies I can use for creating rich multimedia applications. Currently I have an application with DirectX 9 and WPF. If I am to develop something like that for Windows 8 then what options are available to me, and what are the pros and cons of these.   3. Is it a good idea to continue with the same DirectX 9 code on Windows 8 as well? What is the best option equivalent to DirectX, Is it XNA or is it DirectX 11 or something else? Performance an extensibility are critical points to me. All suggestions are welcome. Thanks in Advance.


title: Resources for Internationalisation

text: We're looking at internationalisation for our application and are looking for any good resources please can recommend to help us out. Books, blog posts, articles, you name it, I'd be interested. The application is Java / SQL Server / Oracle with both web (HTML / JavaScript) and Java forms user interfaces. Internals include XML / XSL-T. Anything from high level "these are things to think about" pieces to detailed assessments of character sets, sort orders and date formats would be appreciated.