Is it plausible to use a filesystem-based configuration format rather than an INI file?

After having had endless issues with INI-style configuration files and parsing them correctly (let along getting binary data right), a crazy idea crossed my mind recently: What if an INI file like               # settings.ini     [Windows]     DirectorySeparator='\\'     PathSeparator=';'          [Linux]     DirectorySeparator='/'     PathSeparator=':'      Would rather be stored in the file system; each group is a directory, each key/value pair is a file, so               settings/Windows/DirectorySeparator (contains just `\`)     settings/Windows/PathSeparator      (contains just ';')     ... you get the idea ...      Disadvantages:   * Possibly slow due to IO work, but maybe file system caches help?   * Running low of inodes on some file systems?   * Group/Key names may only consists of characters which are also valid for directory/filenames, may be rather restrictive depending on the FS. Advantages:   * Arbitrarily deeply nested groups   * No worries about escaping, binary data is easy. Just have each file contain the raw data.   * Automatic locking, access control and whatever the filesystem provides   * Easy to access with most programming languages, even by hand I'm very tempted to try this in my next project, I wonder whether anybody else has experience with this approach already?


Choose C++ or Java for applications requiring huge amounts of RAM?

I'm thinking of scientific applications that are mostly processor-bound and heavy on heap usage (at least several gigabytes). Any other time of the year I would happily go with C++, but in this case I wonder if the fragmentation natural to the C++ memory manager can be a serious issue versus the advantage of Java's compacting collectors. Can anybody point to real-world examples related to this?


Approach to statically analyze a Python code base

What approach should I use to statically analyze a Python code base? In particular, I am looking for ways to:   * extract and display the class hierarchy,   * extract and display class relationships,   * include a cross-reference of all functions, modules and variables The specific application that I am dealing with is not well documented which is why I am looking to automate the process.


Why must the burden of proof rest with the caller and not the method of the class that is being called?

Michael Perry states in his Pluralsight course on Provable Code (transcript subscription only) that: > [T]he burden of proof rests with the caller In a code contract, why must the burden of proof rest with the caller and not the method of the class that is being called? Is this a preferred convention or does it have a more solid basis? At the moment it just like a dogma to me as the class being called could make its own safety checks, which would reduce calling code duplication.


How To Build An iPhone App With A Web Server?

I have an iPhone app out that stores data on the device. I want to create an app with user accounts like Instagram, Path, Foursquare, Gowalla, etc. What would you recommend for the quickest and easiest way to get an app of this nature (social, iPhone) going? I'm deciding between RoR or PHP still. Will the final stack come down to: iPhone --> RestKit --> RoR/PHP --> MYSQL? I have a solid background in iOS development, but not the rest.


Google App Engine, what are the advantages and limitations?

First, does anyone know a specific advantage of Google App Engine for Python Apps? Is there some advantage over Heruko or Appfog? And about the database API? Now, what about the limitations? Are there any factors that make you think twice about using GAE?


Why is the Unit of Work pattern considered fast and efficient when working with an ORM?

In working with Doctrine 2 I came across the following paragraph. > In fact, since Doctrine is aware of all your managed entities, when you call > theflush() method, it calculates an overall changeset and executes the most > efficient query/queries possible. For example, if you persist a total of 100 > Product objects and then subsequently call flush(), Doctrine will create a > single prepared statement and re-use it for each insert. This pattern is > called Unit of Work, and it's used because it's fast and efficient I am not up to speed on relational databases and ORM theory so I was wondering why is the Unit Of Work pattern  considered fast and efficient?


Orthogonal design for product pricing and production planning with a NoSQL database

I am in the process of developing extensible software for the company I am working with for product pricing and production planning. **The Present Scenario** There are basically two types of products: manufactured and traded (simple buy and sell with no conversion). Manufactured can be regular or made-to-order with made-to-order mostly being a deviant of the regular model. There is only a finite number of products (around 2000) but each product has got multiple attributes such as size, color, shade and more. Presently, there is software for order management with inventory and a decent accounting package. Costing and pricing is now done on an arbitary basis via sampling a few models and adding overhead and margin percentages. **Required**   * To calculate product cost per unit   * Convert them into a valid pricing model (pricing may differ upon quantity and other factors),   * Calculate exact cost and profitability per product,   * Proactively plan production for regular models and made-to-order units, based on existing order management system and inventory **Proposed Design** I have proposed the following design.   * Store product information for each unique product in document-style based on the 5M's of production (Man, Material, Machines, Methods and Money)   * A separate module of each of the four M's - Men, Machine, Material and Methods in terms of Money with primitive building blocks for each module that can be merged and combined into a compound block    * Store metadata and result set required along with each document   * A separate layer to parse metadata, act upon data based on metadata and return result set as defined (similar to a DSL with both metadata and result set redefined at runtime)   * A separate pricing model that works on the cost of the product   * A separate production planning module that works on the data of the order management system and the product information   * Using MapReduce to aggregate data and analyze it   * Technologies: MongoDB, Python, Django, and NumPy All data to be stored in JSON format with all business logic written to parse a JSON file (technically, in my case a Python dictionary) and produce output based on keys and values. **So why am I here?** The present software company has recommended a traditional out-of-the-box RDBMS system that could be customized. The main problem I find with the system is the duplication of data for products with varying attributes, lack of analytical tools, tight coupling with products and prices and too many joins for complex queries, but it is recommended for better robustness and better aggregate analysis and the XXXX always told market runs this approach. Since the entire software is not to be used in real-time and most of the real-time sytem links to unique products only.   * Does my proposed design is truly orthogonal?   * Does loose-coupling product, cost and pricing work?   * What is the general approach for this kind of problem?   * Do MapReduce provide a better way to analyze data for this kind of problems (along with NumPy) than the traditional SQL approach Basically I work with numbers, and I am thinking of a generic model which I could extend in the future.


Which is the most permissive open-source license?

Which is the most permissive open-source license available? "Permissive" would be defined as "the minimal requirements about how the software can be redistributed".


Need advise for porting linux script to Win command line

I am creating app(script) that is used similar to RSS reader for specific webpage that doesn't have RSS. So my app downloads that html page in defined intervals, checks new items and parses them into messages that are sent over network. But my app prototype is written in Bash (Linux is my primary OS), and I was asked that this app will be needed on Windows also - luckily WinXP 32bit only. So I am deciding how rewrite it easily and without testing various scripting languages and technologies. Currently my app is working with Bash, and calls for unix utilities like sed, wget and curl. I checked that these utilities are for win32 also. So my question is about Windows commandline capabilities compared to linux bash. Does wincmd have similar capabilities like bash? In e.g. manipulating strings, cycles or something that might be a problem? I also found Cygwin, but don't know if it works reliable and this is important in this case of app.


Performance vs. Laziness: Why use setters from within a class?

I notice that web related code uses setter methods to set class fields instead of setting them directly since they are in scope. I find this to be a bit odd. Using setters is certainly safer, but if unit tests are implemented then bugs will be found. And it's not worth the extra stack call, imo. Does any production code do this or is this just what you see in sample code online? Edit: I have to make clear that I'm only talking about the case whereby the setter consists solely of a single assignment expression and nothing more.


Web design standards

While designing web pages using php, are there standards that should be followed? For example suppose there are two pages. First page looks like this:               <body>     <div>     <?php include 'page2.php';?>      `page2.php` file looks like this:               <?php print 'some text';?>     </div>     </body>      Is such designing a standard practice? Does it affect search engine results?


Will experience suffice for a Computer Science degree

I am debating on a career in programming. The problem for me is that I don't think college is right for me. I am planning on joining the Air Force as a Computer Systems Programmer will they will train me and I will gain some college credits. From what I can understand there is a large amount of people taking a major in Computer Science because they hear computers make money. Most drop out but some do graduate but find they don't really know anything about programming. Ive always heard the issue being that these students often get good grades but don't push themselves to learn beyond the course. I'm a very self motivated learner and I am having a blast learning C++ as well as I love computers and have since before I could even read or write. So learning the actual trade isn't the issue. I could go to college for free or nearly free. I will most likely enlist for 6 years. But when (or if I decide to make a career out of it) I get out of the military will I be able to find a job with 6 years of experience in lieu of a degree. I would assume i would because said employer would know if I could do the work rather then having to deal with some college kid who there not even sure if he knows how to program.


Is it a priority for a web developer to be familiar with the source code of a web browser?

How important is it for a developer that deals with web applications (let's say writing html and js) to download a browser's source code (like Chromium) and learn how the engine works (renderer, javascript vm, network processing, etc.)?


Using requirements for a completed company project as a basis for a personal learning project

Background: I want to learn, try out new frameworks, tools, languages, but I'm terrible at coming up with something to build. The company I work for recently completed work on building a piece of software for internal use. I was not involved in the project at all. The software is purely internal, we do not sell it on. The results are not what people hoped for. Is it acceptable for me to build my own solution in my own time but use the requirement documentation for the companies project? Are there pitfalls I should watch out for with this approach, things I can do to mitigate those risks? Alternatively I could build it the way I think it should be done without referencing those docs. Is this the better approach as it definitely frees me to do what I like with the code afterwards?


Design pattern for polymorphic behaviour while allowing library separation

Let's say I have a hierarchy of `Item` classes: `Rectangle, Circle, Triangle`. I want to be able to draw them, so my first possibility is add a virtual `Draw()` method to each:               class Item {     public:        virtual ~Item();        virtual void Draw() =0;      };      However, I want to split the drawing functionality to a separate Draw library while the Core library contains only the basic representations. There's a couple of possibilities I can think of: 1 - A `DrawManager` that takes a list of `Item`s and has to use `dynamic_cast<>` to work out what to do:               class DrawManager {       void draw(ItemList& items) {         FOREACH(Item* item, items) {            if (dynamic_cast<Rectangle*>(item)) {               drawRectangle();            } else if (dynamic_cast<Circle*>(item)) {               drawCircle();            } ....         }       }     };      This isn't ideal as it relies on RTTI and forces one class to be aware of all items in the hierarchy. 2 - The other approach is to defer drawing responsibility to an `ItemDrawer` hierarchy (`RectangleDrawer`, etc):               class Item {        virtual Drawer* GetDrawer() =0;     }          class Rectangle : public Item {     public:        virtual Drawer* GetDrawer() {return new RectangleDrawer(this); }     }      This achieves the separation of concerns between the base representation of the Items and the code for drawing. The problem though is that the Item classes are dependent on the drawing classes. How can I separate out this drawing code into a separate library? Is the solution for the Items to return a factory class of some description? However, how can this be defined so that the Core library isn't dependent on the Draw library?


How to find a 'good' seed page for a web crawler?

I started building a web crawler and read somewhere that it's a very hard problem to find a good seed page for the crawler. Can anyone explain me if there is any pre-defined procedure/ guidlines of finding a good seed page? or how you say that a particular page is a good seed page?


Keeping binary search tree balanced

I am educating myself on algorithms and data structures. For that, I am doing a simple program that would read lines like this:               bdhj 168.24     dahf 42.88     dhfa 128.92      First column represents an account name (and it needn't have to be 4 characters), and second represents value to add (or remove if value is negative) to that account. I have a huge test data that I could profile different algorithms. I tried keeping this information in linked list and dynamic arrays and some mixture of that two so far. Although dynamic arrays were good at allowing binary search, inserting elements requires a call to memmove (since I am inserting sorted) and it takes a lot of time. I want to try binary search trees for this program, however, I don't have any idea how to keep search tree balanced. I tried google search, but couldn't find any explanations about a algorithm I could use, or any pointers at all. Could you give pointers and/or sources that I could check?


Changing __class__ in a factory?

I'm parsing a set of XML files of different kinds (these kinds are known in advance). These are my requirements:   * I want an object to represent each XML document (object-xml mapping)   * I'd rather have a different class for each kind, so that identifying the type of the XML file is equivalent to looking at the class of the instance   * I don't know the kind in advance   * I want some specific behaviour for each object But for the sake of simplicity, let's consider, I just need to open different numbers, of two know kinds:   * even number   * odd number In term of design pattern, I use a variation of the _factory design pattern_ , where the afctory is in the `__init__` of the top level class, and I set the correct implementaion by a changing `__class__` dynamically               class Number():         def __init__(self, val):             # common implementation (in case of XML, I do the recursion of xml imports)             self.value = val                  # This is also the point where I discover the type of my object             # Hence, the constuctor is also a factory of the appropriate type             if val % 2 == 0:                 self.__class__ = EvenNumber             elif val % 2 == 1:                 self.__class__ = OddNumber             else:                 # keep the default Number implementation                 pass               class EvenNumber(Number):         def half(self):             '''              specific behaviour for even numbers             '''             return self.value / 2               class OddNumber(Number):         def next_int(self):             return self.value          if __name__ == '__main__':         for x in (Number(2), Number(3)):             '''             In the main algorithm, the processing depends on the type of the object             '''             if isinstance(x, EvenNumber):                 print(x.half())             elif isinstance(x, OddNumber):                 print(x.next_int())      What do you think about this approach? I knew `__class__` could be read, and was very surprised it can also be written. What do you think of changing `__class__` dynamically? Is this a well-known design pattern (it is not the _factory pattern_ nor the _state pattern_ nor the _strategy pattern_ , even if it seems related to all of them) **Edit** My real use-case I want to open a XBRL taxonomy, which is made of XML linkbases. Except the generic XML Linkbase, I want to handle more precisely some of them:   * XML Label linkbase   * XML Definition linkbase   * etc. In substance, here is what I have done:               class Linkbase(etree.xml.ElementTree):         '''         Generic linkbase         '''         def __init__(self, filename):             # parse XML             if self.type == 'definition':                 self.__class__ = DefinitionLinkbase             elif self.type == 'label':                 self.__class__ = LabelLinkbase               @property          def type(self):             return self.find('//xpath/expression').tag          class LabelLinkbase(Linkbase):        @property        def labels(self):          # find all appropriate elements and returns a list of Labels          class DefintionLinkbase(Linkbase):        @property        def definitions(self):           # returns all definitions      Alternatively, I could have used a factory. I can think of something like this, but it doesn't look as elegant as the first approach.               class Linkbase(etree.xml.ElementTree):         '''         Generic linkbase         '''         def __init__(self, tree):             self.tree = tree               @property          def type(self):             return get_type(self.etree)          class LabelLinkbase(Linkbase):        @property        def labels(self):          # find all appropriate elements and returns a list of Labels          class DefintionLinkbase(Linkbase):        @property        def definitions(self):           # returns all definitions          def build_Linkbase(file):         tree = etree.parse(file)         if get_type(tree)== "defintion"            return DefintionLinkbase(tree)         elif get_type(tree) == "label":            return LabelLinkbase(tree)         else:            return Linkbase(tree)     def get_type(tree):         return tree.find('//xpath/expression').tag


URL and Controller structure for parent-child-relationship

I use an MVC web framework to create an application which contains a hierarchy:               Location <1-N> Devices <N-M> Services      I have a number of Locations. Each Locations can have several devices (represented by an 1-N relationship in the database). Each device runs services. The services (like http, ftp, etc) are defines in an extra table and are connected to the devices using an N-M relationship. So far I have a model for each of the entities and one Location-controller for CRUD operations. Since the devices somehow belong to the location all the device CRUD-functions are located in the location controller as well. The services have their own controller. The url to access the data is structured like this:               /locations/    # to get an overview of the locations     /locations/*id*/    # to view the details of one location     /locations/*id*/edit    # to edit the details of one location     /locations/*id*/device/*deviceid*/    # to view details of a device     /locations/*id*/device/*deviceid*/edit    # to view details of a device     /services/     # list of all the services     /services/*id/    # view details of a service      Note: There are also urls to create and delete entries, which are omitted. But I think you get the idea. Now to my questions: It feels wrong, and I think it is wrong to put all the functions inside the Location-controller, therefore I would like to move them so separate controllers. On the other hand, I like the URL-Structure, since it represents the hierarchy of the data pretty well. Furthermore I like when the URL structure corresponds with the Controllers. What is the "better" solution: Separate controllers with combined URLs? Separate controllers, separate URLs? Or combined controller with combined URLs?


is there a programming language designed to express data combinations?

Very often, when using the command line or just programming, you want to express some kind of combination that you end up using a `for` - which is often verbose.               for (int i = 0; i<10; ++i)         std::cout << "img_" << i << std::endl;          for f in *; do echo "$f"; done      I always wondered if there is some kind of language made to simplify this case? For example:               "mv img_[0~6] imgs"      Would translate to               mv img_0 imgs     mv img_1 imgs     mv img_2 imgs     mv img_3 imgs     mv img_4 imgs     mv img_5 imgs      `img_[0~1][0~1]` could work for `img_00, img_01, img_10, img_11` `img_[x:0~2][x]` could work for `img_00, img_11, img_22` Etc. I'm not asking for this particular syntax, just if there is any kind of language/feature ever implemented with the purpose of expressing such combinations as easy as possible?


Not sure how to study Web programming

Hello everyone and thank you for your time :) So I'm a 17 portuguese boy and I'm thinking about starting a website, but because I don't have much money I decided I'd need to learn how to do it myself. So I got several books on the main languages ([X]HTML, AJAX, JS, PHP, MySQL, CSS) but I'm not sure what to do with them. I started studying them in January and, for I thought this was hard, I decided to basically copy the books into several notebookes, and then, once I got the general picture of how these languages operate, I'd restart and starting apply the knowledge. However, this is taking too long. I've been studying this for over 6 months now, wasted over $20 in notebookes, and still there are several books that remain untouched. I'm thinking: maybe it would be a better approach to simply study the books and directly apply the knowledge and keep doing that, step by step, instead of overkilling like this. Meaning: instead of taking notes as you'd do in a normal school class, simply ignore that and dive right into the action and learn from experience. Thoughts? :) Thanks again.


How can I unit test audio?

I have inherited a small project and want to extend it and stabilize it at the same time by writing Unit Tests for all the new code I am adding. The first class, `TypedAudioCreator`, creates audio files and this turned out to be very easy to test first and write code for second. However, when it came time to write `TypedAudioPlayer`, I had no idea how I could test it. It's a very small class focusing on the very basics of playing sound:               public class TypedAudioFilePlayer     {         public event StartedPlayingHandler StartedPlaying;         public event StoppedPlayingHandler StoppedPlaying;              public readonly int TimeBetweenPlays;              private Queue<TypedAudioFile> _playlist = new Queue<TypedAudioFile>();               public TypedAudioFilePlayer(int timeBetweenPlays)         {             TimeBetweenPlays = timeBetweenPlays;         }              public void AddFile(TypedAudioFile file)         {             _playlist.Enqueue(file);         }              public void StartPlaying()         {             ThreadPool.QueueUserWorkItem(ignoredState =>             {                 while (_playlist.Count > 0)                 {                     var audioFile = _playlist.Dequeue();                          if (StartedPlaying != null)                         StartedPlaying(audioFile);                          audioFile.SoundPlayer.PlaySync();                     audioFile.SoundPlayer.Dispose();                          if (StoppedPlaying != null)                         StoppedPlaying(audioFile);                 }             });         }              public void StopPlaying()         {             if (StoppedPlaying != null)                 StoppedPlaying(null);         }     }      I'm still very new at TDD, but I realize the benefits of the practice and would like to try and get better at it. I have written Code first, no tests here, but that was just me being too lazy to properly think of the TDD way of solving it. The question I have is, how should/could I test this class?


Should I be bothered if my LOC/day ratio is too high?

I'm currently working on an indie project, so I don't exactly have the luxury of throughout human testing or external code review — however, I don't see any difficult bugs in my current code (I fix them as I see them, and most of the time they're just wrong field names and such, things that you fix in a minute or two), and I test it after implementing any feature before pushing it. Lately my LOC number was about 400 a day (for the record, it's C#), and I'm not only implementing new systems, but also rewrite things I've already written and fix some bugs. Should I be bothered? Is it the sign that I need to stop and review all the code I've been writing up to this date and refactor it?


Object Oriented Design

Suppose you have the following:                    +--------+     +------+          | Animal |     | Food |          +-+------+     +----+-+            ^                 ^            |                 |            |                 |       +------+              +-------+       | Deer |              | Grass |       +------+              +-------+      `Deer` inherits from `Animal`, and `Grass` inherits from `Food`. So far so good. `Animal` objects can eat `Food` objects. Now lets mix it up a bit. Lets add a `Lion` which inherits from `Animal`.                    +--------+     +------+          | Animal |     | Food |          +-+-----++     +----+-+            ^     ^           ^            |     |           |            |     |           |       +------+ +------+     +-------+       | Deer | | Lion |     | Grass |       +------+ +------+     +-------+      Now we have have a problem because `Lion` can eat both `Deer` and `Grass`, but `Deer` is not `Food` it is `Animal`. With out using multiple inheritance, and using object oriented design, how do you solve this problem? FYI: I used http://www.asciiflow.com to create the ASCII diagrams.


Introducing Scala to a Technical Manager

I've been promoting Scala at work as something we should try out for things like testing with Specs http://code.google.com/p/specs/ and rapid prototyping of web services with tools like Scalatra https://github.com/scalatra/scalatra and Lift http://liftweb.net. A technical manager is interested in hearing more about Scala, and has no experience with the language. I've pointed out how Scala prototypes could be written quickly and deployed into our existing Java infrastructure as well as use our existing Java libraries. He is largely interested in the specific benefits of using Scala over Java and will be interested in concrete examples. I'd like to hear any thoughts or experiences people have introducing Scala to technical management. Thoughts on good code, clear, concise examples that demonstrate a big win over the Java equivalent, would be greatly appreciated. Some examples areas for discussion I have been thinking about are: **REPL**   A big win over Java, and I use it every day to test the Java code I am writing. **Basic Collection Iteration**   One of the first areas I think Java programmers can see immediate benefit. **Type Inference**   We use a lot of Python at work - I think less type boilerplate in a strongly typed language will be appealing. **Java Integration**   Given our Java investment, this will be a biggie. **Concurrency**   A brief run through of Akka actors and the new parallel collections. I'd love to see any small, focused examples anyone has here. **Specs**   I've been finding BDD with Specs excellent for testing Java applications. **Web development**   I've found Scalatra ideal for rapid development of REST services. Please share any other areas you think might be of interest as well as any focused code examples in these or other areas you think demonstrate advantages of Scala over the Java equivalent. **EDIT:** To be perfectly clear I am primarily interested in **concise concrete code examples** appropriate to this situation. Not at all interested in another "Java vs Scala" thread. I hope that was clear. Something like: **Java:**                 Foo theFoo = null;     for(Foo aFoo: allTheFoos) {       if (aFoo.getId().equals(theIdIWant)) {         theFoo = aFoo;         break;       }     }      **Scala:**                 val thefoo = allTheFoos.find(aFoo.id == theIdIWant)


exception for string literal conventions

If I'm used to use ' for string literals in PHP, would it be better if I'll stick to it in any situation or can there be exceptions when it would increase readability? example: `$foo = "bar'baz"; // this may be easier to read $foo = 'bar\'baz'; // but this would stick to the convention`


What to call objects that may delete cached data to meet memory constraints?

I'm developing some cross-platform software which is intended to run on mobile devices. Both iOS and Android provide low memory warnings. I plan to make a wrapper class that will free cached resources (like textures) when low memory warnings are issued (assuming the resource is not in use). If the resource returns to use, it'll re-cache it, etc... I'm trying to think of what this is called. In .Net, it's similar to a "weak reference" but that only really makes sense when dealing with garbage collection, and since I'm using c++ and shared_ptr, a weak reference already has a meaning which is distinct from the one I'm thinking of. There's also the difference that this class will be able to rebuild the cache when needed. What is this pattern/whatever is called? Edit: Feel free to recommend tags for this question.


How can I secure a request handler so I only respond to the correct clients?

Here's the scenario... I have a web site that has a generic handler written in asp.net (.ashx file) that accepts http requests, gets relevant data, converts the result into xml and then passes that back via the response. This will eventually be used so that a windows application can make data requests to this web site. My concern is that anyone who knows how to put together the request can then access potentially personal data. The data isn't anything as sensitive as financial information, but it will have names and addresses so I obviously need to think about securing it. My initial thought was to encrypt the information before responding, and maybe even encrypt the request as well, and I'm happy to do this, but I just wanted to ask some other boffins for their opinion on the matter. Is this something that has a "standard" way of doing it, or is it simply a case of thinking of something suitable and implementing it. Incidentally, the windows app will be distributed all over the country so the requests will come from many places. Using the IP address is not only a laborious way of doing it, but it also doesn't help as you could obviously send the message from an IP without using the application. TL;DR How do I make sure that it was my windows app that asked my web app for information?


What do I need to know about Data Structures and Algorithms in the "real" world

I just finished the data structures and algorithms course in school , I took it during the summer so 6wks course vs a 16 wk course during the regular semester. So not only was the course hard but it was really really really fast. My question is what do I need to know about data structures in the real world? I understand what they do and how they work, for the most part, but I had a real tough time coding them , I wouldn't be able to write the code for a binary tree class or a balanced tree class from scratch .... Is that bad? should I retake it , or is knowledge of how they work sufficient, without being able to write the classes from scratch?


What are some ramifications of open source software turning into closed source software?

If a company takes a permissively licensed open source application and then develops a closed source application from that by reworking extensive parts of the application, adding new features and applying bug fixes... Ignoring any license requirements...   * How does the transition happen and what can be done to prevent it beyond choosing a difference license?   * What are the (ethical or social) responsibilities for the company? (For example: Giving back to the open source project would be the ethical thing to do)   * If the open source version and closed source version are both available, how does the competition affect either product? Are there any examples of companies or products that have done this (either successfully or unsuccessfully) in the past? What was the community attitude toward those projects?


Assembly as a First Programming Language?

How good of an idea do you think it would be to teach people Assembly (some variant) as a first programming language? It would take a lot more effort than learning for instance Java or Python, but one would have good understanding of the machine more or less from "programming day one" (compared to many higher level languages, at least). What do you think? Is it a realistic idea, at least to those who are ready to make the extra effort? Advantages and disadvantages? _Note: I'm no teacher, just curious_


Eclipse RCP - Programming or configuring?

when I develop a RCP application I always ask myself should I do it 'by hand' or should I use the XML configuration? Is it only a matter of taste, what benefits am I missing when I don't use the configuration approach. Is there anything to think of when converting an RCP app to e4 in the future? Thanks for sharing your thoughts! Thomas


Inheritance vs mixins in dynamic languages?

**When should you prefer inheritance patterns over mixins in dynamic languages?** By mixins, I mean actual proper mixing in, as in inserting functions and data members into an object in runtime. When would you use, for example, prototypal inheritance instead of mixins? To illustrate more clearly what I mean by mixin, some pseudocode:               asCircle(obj) {       obj.radius = 0       obj.area = function() {         return this.radius * this.radius * 3.14       }          myObject = {}     asCircle(myObject)     myObject.area() // -> 0


Visual Studio's Developer License duals as a personal license?

I can be completely wrong but I vaguely remember hearing from a podcast that according to Visual Studio's license, a developer who works with Visual Studio professionally at their work place automatically has the license to use it in their personal life. That means a developer may not have to pay for Visual Studio to legally use/own it. Again, I can be completely wrong but if I'm right, can someone confirm with a source?


Is there any "real" reason multiple inheritance is hated?

I've always liked the idea of having multiple inheritance supported in a language. Most often though it's intentionally forgone, and the supposed "replacement" is interfaces. Interfaces simply do not cover all the same ground multiple inheritance does, and this restriction can occasionally lead to more boilerplate code. The only basic reason I have ever heard for this is the diamond problem with base classes. I just can't accept that. To me, it comes off an awful lot like, "Well, it's _possible_ to screw it up, so it's automatically a bad idea." You can screw up anything in a programming language though, and I mean anything. I just cannot take this seriously, at least not without a more thorough explanation. Just being aware of this problem is 90% of the battle. Furthermore I think I heard something years ago about a general-purpose work-around involving an "envelope" algorithm or something like that (does this ring a bell, anyone?). Concerning the diamond problem, the only potentially genuine problem I can think of is if you're trying to use a third-party library and can't see that two seemingly unrelated classes in that library have a common base class, but in addition to documentation, a simple language feature could, let's say, require that you specifically declare your intent to create a diamond before it'll actually compile one for you. With such a feature, any creation of a diamond is either intentional, reckless, or because one is unaware of this pitfall. So that all being said...Is there any **real** reason most people hate multiple inheritance, or is it all just a bunch of hysteria that causes more harm than good? Is there something that I am not seeing here? Thank you. **Example** Car extends WheeledVehicle, KIASpectra extends Car and Electronic, KIASpectra contains Radio. Why doesn't KIASpectra contain Electronic?   1. Because it _is_ an Electronic. Inheritance vs. composition should always be an is-a relationship vs. a has-a relationship.   2. Because it _is_ an Electronic. There are wires, circuit boards, switches, etc. all up and down that thing.   3. Because it _is_ an Electronic. If your battery goes dead in the winter, _you're in just as much trouble as if all your wheels suddenly went missing._ Why not use interfaces? Take #3, for instance. I don't want to write this over and over again, and I _really_ don't want to create some bizarre proxy helper class to do this either:               private void runOrDont()     {         if (this.battery)         {             if (this.battery.working && this.switchedOn)             {                 this.run();                 return;             }         }         this.dontRun();     }      (We're not getting into whether that implementation is good or bad.) You can imagine how there may be _several_ of these functions associated with Electronic that are not related to anything in WheeledVehicle, and vice-versa. **Edit** I wasn't sure whether to settle down on that example or not, since there is room for interpretation there. You could also think in terms of Plane extending Vehicle and FlyingObject and Bird extending Animal and FlyingObject, or in terms of a much purer example.


Connecting a native iOS app to backend and database

I have a good amount of experience working with objective-C and making iOS apps that work locally and with BaaS providers (Parse.com). However, I'd like to take my mobile development to the next level and I'd like tips on the order in which to do things and tips on which services/technologies to use. So, I need a database, and a place to host my database. I've used Amazon AWS for some things, and I can easily set up a mySQL DB on an EC2 instance there. Alternatively, I've heard that GAE is very useful. I don't really know if I have to write any back-end code. It seems to me that objective-C can take the place of my back-end code. Is that secure? Should I be making an entire service that is simply called from the iPhone? So, I know that it's a loaded question, and it may require a few different opinions to really round out a good answer. Sorry about that. But, assuming that I am proficient enough with Obj-C to make anything happen client side, and that I'm sentient enough to learn other languages that I might not know and follow tutorials and examples online - What are the steps (and the best technologies/services at each step) to making a native iOS app that does not use a BaaS provider like Parse.com or Stackmob.com. Thanks!


Common diagnostics which VisualVM is used for

There's a lot of documentation out there on how to _use_ the 'jvisualvm' profiler, but very little (if any) real-life advice on how to _analyze_ all those charts and dumps. I'm just a little overwhelmed by all the graphs and having trouble making sense of it all. I know this is sort of a monolithic-type question, but there _has_ to be a way to condense its _typical_ uses into a fairly concise list - finding memory leaks, zombie threads and such. What specifically are some of the common analyses for VisualVM?


Should I force users to update an application?

I'm writing an application for a medium sized company that will be used by about 90% of our employees and our clients. In planning for the future we decided to add functionality that will verify that the version of the program that is running is a version that we still support. Currently the application will forcequit if the version is not among our supported versions. Here is my concern. Hypothetically, in version 2.0.0.1 method "A" crashes and burns in glorious fashion and method "B" works just fine. We release 2.0.0.2 to fix method A and deprecate version 0.1. Now if someone is running 0.1 to use method B they will be forced to update to fix something that isn't an issue for them right now. My question is, will the time saved not troubleshooting old, unsupported versions outweigh the cost in usability?


How would you answer this job-interview question?

One of the five people who interviewed me asked a question that resulted in an hour-long discussion: **"Explain how you would develop a frequency-sorted list of the ten thousand most-used words in the English language."** My initial response was to assail the assumptions underlying the problem. Language is a fluid thing, I argued. It changes in real time. Vocabulary and usage patterns shift day-to-day. To develop a list of words and their frequencies means taking a snapshot of a moving target. Whatever snapshot you take today isn't going to look like the snapshot you take tomorrow or even five minutes from now. Thanking you advance for your answers and consideration.


How should I deal with external data sinks?

I recently took on a contract job that will largely involve generating data feeds from my client's data and sending it to external partners, via feeds and API invocations. I've always found this particular kind of coding to be frustrating, for a number of reasons:   * You have to rely on specs, which often diverge from the actual implementation or simply don't go into sufficient detail   * You have little to no ability to see into the external system, to ensure that your data has been accepted and interpreted properly   * If there's any kind of problem with data you've generated, it's not always straightforward to back out the changes and try again   * External testing and staging environments frequently diverge from production logic and the production database What are some best practices for doing this kind of work? Creating mocks and stubs won't necessarily resolve my problems, as my real concern is: do my feeds have the correct effect on another system, which is basically a black box? Mocks simply duplicate my assumptions.


Source/Version control for application used by multiple companies

Do you find it easier to keep a branch for each company that uses software you support/develop? Each company will want "customizations" and I am just trying to figure out the best way to handle those changes. A branch for each company makes sense in the short term but I could see how this could cause issues with upgrades when a new version is developed. Is better to have a branch for each company or to setup customizations so that they are always merged to a main branch to minimize issues with future releases?


Difficulty understanding difference between Project Manager (Business Analyst) and Software Architect and Scrum Master

From what I've gathered: **Project Manager (PM)(or Business Analyst (BA))** : Decides EVERYTHING. Capable of solving problems. This means he or she will have the skills necessary to look at data and other relevant information in order to determine where the losses are within a company. He or she must be skilled in negotiation, listening, motivational speaking and will also be a good team leader.   * Responsible writing the BRD, where contained are all the Business Requirements of the users/customers.   * BAs serve as a communication conduit between the stakeholders and the team **Software Architect** : The Architect is the interface between the dev team and the stakeholders. They need to be able to understand the business side and the technical details. Architects see what you need now, what you mean when you say what you need, and design a software strategy that will give you what you need today, and a home that you can grow into (and from) in the future. **Scrum Master** : Priority # 1 is to remove impediments as reported by team. He should also constantly look out for potential impediments.. and more importantly impediments that are there but not yet identified. Impediments are opportunities. So scrum-master should avail these opportunities all day long to bring his team(s) to hyper productivity. (avail = use or take advantage of) It appears several of these roles overlap one another. Please help clarify this issue. Some kind of story that strings together all these people would really help! Thanks much.


xaml schedule control how to cope with items of vastly differing durations

I have to create a schedule control using WPF XAML for displaying items with duration as little as 1 seconds and potentially as large as couple of hours. First thing which seems clear is that I will need some kind of zoom capability, for drilling into the items with very short durations and zooming out to view the items with very large durations. I have a UI style in mind where by when the control is zoomed to view the large items, any small duration items which generally occur between the large duration items are some how collected in to a 'bucket' which has a height >= a minimum display height. So that I can perhaps hover a mouse over this bucket and get a tool tip which renders the contained items into a time ordered list view. I am at a loss as to where to begin. I feel that I could perhaps achieve something in the Measure/Arrange overrides of a custom Panel. But I think this could adversely affect render performance. If I were to do it this way, I guess I would need to inject a 'bucket' view into the panels children collection, but that would break the use of ItemTemplate in my Custom Items Control? My second though is that I create a custom observable collection which has a bindable Scale property which then organises the collection into 'buckets' of a duration large enough to be displayable. Does anyone have any thoughts on how I should best approach this problem?


Should I really need to implement event sourcing is this case?

An example of use case when event sourcing is applicable here whose excerpt is: > Say, something went wrong in your app and as a result, a user gets blocked > for abuse but that user claims to not have done anything to break rules. Now > you can go back to your staging environment and play the events leading up > to the block in that system and see what happens first hand. > > What’s needed for this is a comprehensive log of events for basically any > interaction that happens around your app and a staging system to replay > events to. Based on the sensitivity of your data you may want to anonymize > some details before hand but that’s about it. IMO, event sourcing has a real benefit when we are asking for "why" was there this state rather than "what" was the state. My application is designed following CQRS principle, but I don't use Event Sourcing yet. If my application is really focus on the "what" rather than the "why" (since operations are really simple, meaning there are no different ways to end up the same result), is it similar to use the Temporal Pattern as introduced here (persisting object's versions/revisions in database) rather than implementing event sourcing? Especially for tracking user abuses (like posting some insults) that were temporary (so hidden), a simple query asking for the version where the abuse was commit could be enough and quickly made, rather than having a "script" in staging environment replaying the events to get the right snapshot showing the abuse.


Representing timezone list

I have a web application that allows the user to choose the timezone from the list. The list is very long (pretty much all CLDR-supported timezones). So the question is - how should I represent it? How should it be sorted - alphabetically or by timezone offset? What information should each item contain - offset, location, long name (like Europe/Zurich) or short name (like CET)? Should I display information about DST or only current offset? Let's say I can't right now do something like fancy maps OS configuration dialogs display, so the list is the only option. However I want to make the list look nice. Any best practices how it's done?


How to ramp up my data structures skills after a long hibernation

I was pretty good with algorithms and data structures once, a long long time ago. Since then, I programmed professionally, and then went to manage a small team, which totally shot my tech skills in this field back. I've decided I want to be a developer again, and work for Google. The thing is, I'm so out of practice, that if I were to be interviewed right now I would surely flunk out in 10 minutes. What training program would you recommend for me to get back into shape? I already started this weekend by going back to the absolute basics and implementing a few sort algorithms, linked list, and hash table. Next, I think I'll read through the entire course material on the other basic data structures and graph algorithms. I want to find a focused set of practical exercises I can do in a relatively short amount of time, to juggle the old brain cells. I know this stuff - I just need to remind myself that I know it.


Defensive Programming Techniques

I was attempting to identify an element of software engineering that I think is overlooked, not emphasized or not taught in typical undergraduate course work for CS or SE. What I came up is the concept of defensive programming. I would like to hear the community's options on defensive program and/or specific techniques that you use on a regular basis. Also, I would to know if there are any language specific techniques. Edit: Just to more clear. I am not looking for a lesson in defensive program. I understand what it is. I was hoping this would be more of discussion about different method members of the community employ or find valuable. Here are some techniques that I use. Keep in mind that I use C almost exclusively. Coding standard. You not might initially think that this has anything to do with defensive programming, but it does. To illustrate, suppose your coding standard requires you to prepend variable names with the type of variable it is such as IntValue or UIntValue. The convention allows you to easily spot potential promotion rule issues like (IntX = IntValue * UIntValue) Use preprocessor macros for constants. Personally, I think this also make your program more readable and maintainable, but it also provided a safety net. You can be sure that all areas of the code that use the macro will be updated when you change the value. Other uses of preprocessor macros can also provided defensive attributes in your code. Some technique are built right into the language such as static variables or function declarations or in c++ data encapsulation. Of course there are more obvious ones including validating all your input and output.


Lecture-like CS videos

I have no formal education in computer science (I am a mathematician), and I recently discovered that well-made videos make for decent substitutes of actual lectures. I'm looking for advice about some nice video lectures, but I have a more specific requirement than this question. Namely, many videos I found online do not make use of the blackboard and use a still camera. In these videos you just see the teacher talking and pointing at something that may be projected on the overhead, but you have no way to tell. Often there are slides to follow, but these are not a great help. Instead lectures like SICP or this course on Channel 9 make use of blackboards and have undergone a proper video editing, which ensures that you always see the relevant slides. This makes an enormous difference with respect to still camera lectures, which I find mostly unuseful. I can easily Google for lectures, but I need the help from people that actually followed them to find the relevant ones. I am mostly interested in the following topic, in descending order:   1. Compilers and interpreters   2. Operating systems   3. (Advanced) data structures and algorithms   4. Networks and protocols I don't really mind for the language used for the course, but in case I speak (at various levels) PHP, Javascript, Python, Scheme, C and Haskell. Even better if the courses proceed at a high pace. I generally learn rather quickly, but I do not have much spare time.


Best design pattern for library with data model

I am refactoring an old Codeigniter library to be php framework agnostic. There are these core parts:   * the connection object - this will come from the "user"; ie, the framework's connection, or their own connection library. My library will not want to "know about it" except that (at first) it will be a PDO conn object (but things should be written to handle a native driver type)   * the model object - runs the queries & returns results array (or error array) to the main lib. As it is now, it is very "thin" and only has transactions, query building & the actual db query   * the model interface - I'm a big fan of interfaces, and I see this model as being swappable for a NoSQL model, for example   * the main library - in my current CI library, this 1) receives the function request, 2) validates the params passed to it, 3) requests from the model, 4) creates a response array that includes the data & error codes and messages (multilingual configurable, but not really part of this question)  So, in summary, the way it works NOW is in your controller or calling page: 1) call main lib function 2) main lib calls model 3) model returns to main lib 4) main lib returns to controller * * * NOW starts my real design pattern question: I would like to pass my conn object via DI to my main library, but I'd also like to pass my model via DI to the main library to keep things flexible. The flexibility goal I'm after would be to allow people to create their own Native DB or NoSQL models & pass non-PDO conns into this, so keeping them decoupled seems optimal. BUT to do this, the only thing I can think of would end up as: (controller - where I might actually execute the query in the lib, not model)               $conn //from the user     $model = new MyModel();     $lib = new MyLib($conn, $model);      or               $conn //from the user     $model = new MyModel($conn);     $lib = new MyLib($model);      which feels more "natural" since the query & conn tend to work together Either case feels pretty clumsy for the user, and I can't help but wonder if I'm not either overdoing this whole DI thing or just have picked the wrong design pattern to go about this. Any guidance as to how to best set this up would be greatly appreciated - spent more time thinking about this than it will take me to refactor the actual code! TIA


Project organization with professionals and students

I am working as a PhD student developing scientific/engineering simulations and algorithms to be tested in these simulations. These days the first student started to work on my project (for his Bachelor thesis) and I am wondering: how should I organize the project now? I think I have some good C++ knowledge (although I still want to improve everyday!) and the code contains some design patterns, lots of templated classes etc. These techniques are new to the student and I wonder if it's a good idea to have him work directly in the trunk of the project. Do you have any experiences what happens if programming newbies and more experienced programmers are mixed? Does the code get messed up or do the newbies learn more by this? Is it wise to have a branch for the student to test his algorithms and maybe merge them into the trunk later? Should I first give him a book like The Pragmatic Programmer for reading (better suggestions?)? Thanks for every answer! PLEASE NOTE: I asked this question on Stackoverflow. The answer was about code reviews and I think this is a good way, but I was also advised that this site might be the more correct one, so I wanted to see if there are more things that might help or other opinions?


How to choose a language, when taking in account the community it includes?

I was reading the following article: Great Hackers The following part grabbed my attention: > "When you choose a language, you're also choosing a community. The > programmers you'll be able to hire to work on a Java project won't be as > smart as the ones you could get to work on a project written in Python. And > the quality of your hackers probably matters more than the language you > choose. Though, frankly, the fact that good hackers prefer Python to Java > should tell you something about the relative merits of those languages." I would like to apply his advice on a commercial web application I am building (I am a strong believer in culture and community), yet this article was written in 2004, and python has increased in popularity in the recent years. How can I decided a language when taking in consideration its community, rather than the popularity? Any recommendations? Is there any language community that show dedication and passion for developing, rather than learning a language to get a Job and a paycheck?


Window Position on Startup

Here's a question for me that really makes me wonder every time I start designing and developing a thick-client desktop application. I'm a .NET developer, and with my forms (WinForms mostly, but the platform should be unimportant) I also choose the startup position to be **Center**. The reason I do this is because I can't stand randomness, and as a user myself I don't like when windows jump all over my monitor. So my question for you, is what is the best way to go about this? Center an application startup window or have it randomly placed? And why?


Definition of mixing programming idioms?

Say I have class that is partially implemented as a static class and partially implemented as a singleton. Besides "kludge" and "code-smell" (imo this is both) is there a more appropriate term for this type of mixing programming idioms?


Static Tables vs Dynamic Entity Attributes Storage Configurations

I am trying to figure out a better way to decide table storage configurations whether it will use **static configurations using tables** or **dynamic configurations using EAV** (entity-attribute-value) When creating database tables, forms, and reports, when do you decide that a program should use a normal database (wherein everything is statically configured, possibly final) or use entity-attribute-values (wherein all of the data are dynamic and can be customized)? Does it all depend on the client/people using it? Is static-table-customized- programs only applicable for small and medium businesses? and dynamic-eav- customizable-field-programs (like Quickbooks) only for the general public or big businesses wherein they don't want another programmer to tamper again with their software?


Why is there no 'subclasses-only' access modifier in Java?

In Java, there are four available access modifiers for methods: `public` - any class can use this method. `protected` - classes in the same package and subclasses in any package can use this method. `private` - only this class can use this method. `no modifier` ("package private") - only classes in the same package can use this method. What happens often is that I want to have useful methods in a superclass, that all subclasses can use. But it wouldn't make sense for other classes to access this method, and in a sense it would break encapsulation. So I have to declare these useful methods in the superclass `public` or `protected`, which exposes them to all other classes at least in the package. Even though they're only meant to be used by the subclasses. Is there a reason why there isn't a `subclasses-only` access modifier in Java? It seems very odd to me. Am I missing something? _Also, a`subclasses-only` access modifier would also be useful for when you want to expose variables only to subclasses. Which to me happens a lot._


What does a Technology Analyst do at a banking company?

I just graduated from college and I got a job as a _Technology Analyst_ in a banking company. I was told that I would be working on .Net or Java. What kind of work will I be doing? What is the need of a programmer in a banking company?


How should I program with dynamic typing language even no type is noted on documentation?

I lived long time on static typed language world. All types were explicitly noted on each variables and arguments. Now I have to use some kind of dynamic typing language. (Smalltalk) The problem is there is no type noted on any message argument, and even on documentation. So, how can I know what should be passed to the each argument? Why the people didn't note type on message arguments? Really isn't it need?


MBA versus MSIS

I am considering going back to school for my masters and I've been looking at several avenues I can take. I've been considering either an MBA or an MSIS degree. Overall I know that an MBA is going to give me a solid skill set that can help me become an executive. However they seem to be a dime a dozen these days and the University I can get into is good, but it's not exactly in the top 100 anything. My undergrad MINOR was in Business Information Systems. I'm rusty as hell, considering I haven't touched it, but an MSIS would be more in the direction of my past academic experience and seems to touch both on business management and IT. Question... With an MSIS will I just be a middleman? Will I really be an important person with a real skill set or will I merely be someone who isn't quite cut out to be a manager and who is clueless about the tech side? Is an MSIS degree going to give me a real chance to move up the pay scale quickly or am I better off learning programming, networking through another BS degree? What will give me more upward mobility career wise? An MBA or an MSIS?


Gathering all data in single iteration vs using functions for readable code

Say I have an array of runners with which I need to find the tallest runner, the fastest runner, and the lightest runner. It seems like the most readable solution would be:               runners = getRunners();     tallestRunner = getTallestRunner(runners);     fastestRunner = getFastestRunner(runners);     lightestRunner = getLightestRunner(runners);      ..where each function iterates over the runners and keeps track of the largest height, greatest speed, and lowest weight. Iterating over the array three times, however, doesn't seem like a very good idea. It would instead be better to do:               int greatestHeght, greatestSpeed, leastWeight;     Runner tallestRunner, fastestRunner, lightestRunner;     for(runner in runners){         if(runner.height > greatestHeight) { greatestHeight = runner.height; tallestRunner = runner; }         if(runner.speed > ...     }      While this isn't too unreadable, it can get messy when there is more logic for each piece of information being extracted in the iteration. What's the middle ground here? How can I use only a single iteration while still keeping the code divided into logical units?


clarification about amortized analysis

I was going through an article here In the section named Aggregate Method ,the author says > Then summing over the entire sequence, all the 1's sum to O(n), and all the > di also sum to O(n). That is, and then gives this               Σ1≤i≤n ci   ≤   n + Σ0≤j≤m 2j−1      I can understand how summing 1's to get n , But I am not very clear how the second term becomes `Σ0≤j≤m 2j−1` and thereby O(n) Sorry about the formatting..I am not sure how the math notations are to be printed here.. Will you please see the original article ?


An ideal way to decode JSON documents in C?

Assuming I have an API to consume that uses JSON as a data transmission method, what is an ideal way to decode the JSON returned by each API resource? For example, in Java I'd create a class for each API resource then initiate an object of that class and consume data from it. for example:               class UserJson extends JsonParser     {         public function UserJson(String document) {         /*Initial document parsing goes here...*/         }     //A bunch of getter methods . . . .     }      The probably do something like this:               UserJson userJson = new UserJson(jsonString);//Initial parsing goes in the constructor     String username = userJson.getName();//Parse JSON name property then return it as a String.        Or when using a programming language with associative arrays(i.e., hash table) the decoding process doesn't require creating a class: _(PHP)_               $userJson = json_decode($jsonString);//Decode JSON as key=>value       $username = $userJson['name'];      But, when I'm programming in procedural programming languages (C), I can't go with either method, since C is neither OOP nor supports associative arrays(by default, at least). What is the "correct" method of parsing pre-defined JSON strings(i.e., JSON documents specified by the API provider via examples or documentation)? The method I'm currently using is creating a file for each API resource to parse, the problem with this method is that it's basically a lousy version of the OOP method, as it looks exactly like the OOP method but doesn't provide any OOP benefits(e.g., can't pass an object of the parser, etc.). I've been thinking about encapsulating each API resource parser file in a **publicly accessed** structure(pointing all functions/publicly usable variables to the structure) then accessing the parser file code from within the structure(`parser.parse()`, `parser.getName()`, etc.). As this way looks a bit better than the my current method, it still just a rip off the OOP way, isn't it? Any suggestions for methods to parse JSON documents on procedural programming lanauges? Any comments on the methods I'm _currently_ using(either 3 of them)?


Examples of Finite State Machines

I'm looking for good examples of finite state machines, language isn't particularly important, just good examples. Code implementations are useful (generalized pseudo-code), but it's also very useful to gather the various uses of FSM's. Examples don't necessarily need to be computer based, for example Mike Dunlavey's Railroad networks example, is very useful.


Why do programmers use `Acme` as a package, namespace or directory name

This may or may not be a silly question, but I really would like to know the answer to something which has been bothering me for a while. I quite often see programming examples/conventions where the programmer has created a directory called `acme` to put stuff in. What does `Acme` mean? Why Acme and not Emca or other? Is Acme like a generic folder name to group miscellaneous OOP classes? Where did the term come from in terms of the programming convention. As far as I can see, it has nothing to do with a programmer UI http://plan9.bell- labs.com/sys/doc/acme.html


One Event Sent to Multiple Listeners, Want to Log Notification Once

![System Layout](http://i.stack.imgur.com/jc40i.png) I have a system in place where a Cache is made up of many Cache Nodes. When one is added, a CacheNodeAdded event is raised by the Cache. The Cache has a redundant set of Monitors listening for this event. Monitors are responsible for notifying on Cache events. Since I have multiple Monitors, but only want to be notified once, **Step 3** is what I am looking to implement. Solutions I can't use:   * Cache notifying directly. Monitors must be used.   * Have each Monitor check the log to see if the notification has been sent. Since they all run separately, they could all access the list of notifications at the same time, see the notification hasn't been sent, and notify multiple times as a result. Solution I'm toying with:   * When event is received, get a list of all Monitor IDs (GUID), order the list, and the first Monitor in the list gets to send the notification. This is a simple solution but it seems a little inelegant. Are there any other simple solutions that I may be overlooking?


Are project managers useful in Scrum?

There are three roles defined in Scrum: Team, Product Owner and Scrum Master. There is no project manager, instead the **project manager job is spread across the three roles**. For instance:   * **The Scrum Master:** Responsible for the process. Removes impediments.   * **The Product Owner:** Manages and prioritizes the list of work to be done to maximize ROI. Represents all interested parties (customers, stakeholders).   * **The Team:** Self manage its work by estimating and distributing it among themselves. Responsible for meeting their own commitments. So in Scrum, there is no longer a single person responsible for project success. There is no command-and-control structure in place. That seems to baffle a lot of people, specifically those not used to agile methods, and of course, PM's. I'm really interested in this and what your experiences are, as I think this is one of the things that can make or break a Scrum implementation. _**Do you agree with Scrum that a project manager is not needed? Do you think such a role is still required? Why?_**


How to evaluate Secure Authorization for server to client

I have a customer that wants me to build a web portal (Asp.net 4.0) that will communicate with a desktop client, tablet and/or smart phone (e.g. iOS and/or Android). I was thinking of using oAuth 2.0. But I'm not familiar with any potential cons to using OAuth. And I don't know how to compare OAuth to other Secure Authorization method/protocols that would be appropriate for this situation. How should I evaluate OAuth to see if it's right for my project or if I should use a different protocol?


How do you evaluate learning C# from videos for a beginner?

I have an idea about programming in general so I know what a variable and a method is but I didn't program before. I liked C# because of Visual Studio and I only tried Hello word program in it. I still don't know much about OOP. Now, I have videos to learn from which I found on (LearnVisualStudio.net). However, I'm not sure about the author of the videos in that site if he is a professional or just a hobbyist because I want someone to teach me with a good practice habits, I want to learn the right way! I also have some books but I found most of them don't explain the principles in a clear way. So they start with a 'hello world' program and after that you find yourself lost with a lot of concepts which are explained randomly. Please let me know if you know anything about the site mentioned above if it is good or not to start with and let me know if learning from videos considered good for learning programming and OOP?


How would you architect an application which is largely a collection of flowcharts?

I am working with a history teacher on a history app. He has like 200 flowcharts that he wants to put into the app (among other things). The two likeliest-looking ways to do it:   1. HTML/CSS. The big minus here is that neither one of us is a big HTML/CSS person. Though I do know a bit about them.   2. Adobe Illustrator. The interface makes it easy to draw stuff, and we can make vector graphics files and work from those. The drawback is that the text of a box, the graphical box, and the corresponding hyperlink would be different entities, where as if the HTML/CSS is done right, they might all be a single thing. There are some flowchart-drawing websites out there. But the ones I have looked at have some problems:   1. In the ones I have looked at, the HTML is big and messy. We need ours to be short and simple.   2. Often a large amount of JavaScript is involved. We could do that, but it adds to the complexity of our mobile app, as well as the risk of failures. We are starting on iOS but may add other platforms later.


Code design: is this specific case of monkeypatching in python acceptable?

I'm using python to do some research tasks. I have a class hierarchy for "tools", where each object is an instance of a particular tool. They all share some functionality and have many similarities in their states. Some of these tools can use one of several methods based on the tool object's current state. The specific tool I'm going to ask about actually calls functions from external modules instead of methods written in the class directly. The underlying reason for this is to break up the code into multiple files, i.e. not have any huge monster file that has all the various methods and helper functions those methods use, when all it needs at any given time is a particular very-targeted subset. I.e. when the mode of the tool is "clean_house", I would only functions like "wash_windows", "vacuum_carpet", and "ask_girlfriend_for_help", while when the mode is "do_work", I use functions like "write_code", "debug_code", and "ask_SO_question". The subsets don't intersect in any way, i.e. "write_code" would never call "ask_girlfriend_for_help", etc. Instead of calling these functions from module scope within the class methods, it seems to me that it's a better idea to monkeypatch them to the tool's class, since there are instance methods they need to call that go further up the class hierarchy and modify some (protected) part object's state that is used later in the destructor. I know monkeypatching is often considered poor design or last-resort practice when hot-fixes are in order (Programmer's SE post here), but is it justified in this case? Any alternative code design suggestions?


Grouping conceptual algorithms into one class or associate with their object models

If I have a number of classes, lets say a variety of buildings of some sort. Each of these buildings have various properties and do some stuff etc Now there is a set of operations I need to do on these buildings that are all conceptually the same. Lets call this conceptual group of operations _Move building effluent_. This functionality is essentially responsible for performing methods based on the information of each Building and then setting properties in other areas of the code as well as setting information on the building itself (can't help the need to set properties in other areas at the moment due to current system design limitations). It's important to note that although these methods are conceptually the same and they set many of the same properties in various classes the way they calculate and get to these values are different (they do share some code however). My question is should I put the code to do this into one class called say _EffluentBuildingDistribution_ or should I put it into each buildings own class with appropriate methods to perform essentially the same code. So either something like:               public class EffluentBuildingDistribution      {         public void DistributeEffluent()         {            // parameters example only            DistributeBuildingHouse(var param1, var param2);            DistributeBuildingDogHouse(var param1, var param2);            DistributeBuildingSecondHouse(var param1, var param2);         }              // and various private methods to help work with the 3 methods some shared         // others not         }      or               public class HouseBuilding    {        public void DistributeEffluent(var param1, var param2)        {           // do stuff        }     }          public class DogHouseBuilding    {        public void DistributeEffluent(var param1, var param2)        {           // do stuff        }     }      Or perhaps neither of these options!. I'm not sure if putting the code on the objects they are working on is the way to go, or putting it in a class that represents conceptually what we are trying to do. This is an example of my current dilemma however it's also a general responsibility question on where to proportion methods and actions etc If it's not specific enough or needs more explanation etc let me know and I'll try to explain more of my issue. EDIT: Due to some understandable confusion with my usage of the term _Structure_ in my example, I since changed it to _Building_. Some of the answers below refer to Structure but they are still valid as I have not changed the core of the question.


Easy To Use Collaborative Editing Software?

My friend and I usually don't have time to meet up in person to do some real pair programming. Since we want to program together anyway, we turned to the world of collaborative software editing. Sadly, most of the solutions we have tried are either lackluster or don't work at all. Cloud9 (fusion of Mozilla Skywriter, ACE) is tossing errors like there's no tomorrow and makes developing a project impossible. Notepad++'s plugin seems to be broken. CollabEdit allows only for one file at the time. Granted, you can open multiple windows, but that makes editing a bunch of files really, really awkward and clumsy. Is there any online or offline software to enable sane collaborative editing? We tried Skyping with a shared screen, and while it's truer to pair- programming than two people coding at once, we don't want to be limited that way.


Python sorted iterable set, modifiable during iteration

I am looking for a datastructure to handle cycling through a large number of ordered subroutines, some of which are active, most of which are not. I am thinking I need an implementation of a python set like object which remains ordered when modified, can be easily iterated over (I don't care if an actual for loop works, as long as there is a simple and efficient way to read each element in order). And most notably can be modified while being iterated over. This is to allow an implementation of a very specific form of subroutine program (unfortunately I cannot use the built in subroutine modules as my python program is emulating the behaviour of a legacy system precisely so I need finer control.) Effectively I have a list of subroutines which are referenced by an index number in a dictionary, the subroutines are iterated over in ascending order until the last is reached at which point we return to the lowest number one. However there are a large number of subroutines and only a few at any time will be 'active' and ones which are not active are skipped in the order for running. I considered simply giving each routine an active flag which would be tested before running however the enormous number of potential routines compared to the tiny number of active ones makes this method much to slow. Subroutines are only occasionally activated or deactivated but running them must be very fast. As such I have been looking to keep a list of the keys of the active ones and iterate through that, adding or removing them as they are activated or deactivated but am looking for a reasonably efficient way of maintaining this list. The main two systems which seem feasible to me are blist sorted sets, however I am not sure if they support being modified while iterated over, and using two heapq and shifting the items between them in order, this will definitely support modification at any time but would require a lot more manual work, and would probably be slower. However somebody may have a much better answer than either of those so I will appreciate any ideas on how to achieve this with reasonable efficiency and ideally in a 'pythonic' way, though I can deal with it being a little ugly if it does the job.


Is it appropriate to go around your boss to receive an answer? If so how?

If you have a project and there are questions that need answered regarding a specific part of it but answers are not coming back to you because of a reason such as: "The project is not in scope and as a side project we are not going to push for answers," is it appropriate to go outside/around your boss to get those answers. If so how? If not why? My situation: In the next month we have a lot of projects slated for our team but currently we have a lot of down time and some side projects that I really want to participate in are coming to a screeching halt because of the lack of answers I have received regarding some of the specifications. My boss won't press for answers because he said since this is a side project we are not "supposed" to really be investing out full efforts into it, however, I go crazy at work with down time unless I find something constructive to do. Ie. learn a new language, take on a side project like this one. How can I elicit the answers I need to start working on this project because chartered projects come up that require my full time and I have to toss this side project off to a student developer? Additionally, how can I do so without pissing off anyone above me?


Duplicate code in DCI model and use case

I'm just coming in to an application that's already built with a DCI architecture. I've discovered in trying to implement a feature that there is duplicate code in a use case and a model. This is not general utility code, but domain specific code about pulling data back from a service. As I understand DCI right now, I don't see an obvious good way to factor this out so I can call the same code from both places. What is the recommended way to deal with a problem like this in DCI?


Looking for a specific type of artificial intelligence

I am looking to create a challenging AI project. There is an online card game that allows you to build a deck to play with out of randomly presented cards. You have to choose one each time out of a couple of cards. I want to build an AI that picks the cards as I would pick them myself using my knowledge of the game. My guess is that I would have to create a system that can be trained based on "experience" (taught by training) and adapts its choices based on which previous cards it has already selected. I am looking for the specific name for this type of AI so I can start finding some resources for it or similar projects if you know any.


How Challenging is it to Mix Pure JS with CoffeeScript on a Team?

I keep running into Senior JS positions where they want CoffeeScript. The reason I don't use CoffeeScript is that my first impression of it was that it puts limitations on JS OOP features that I find valuable. I've seen claims that the two can inter-mix freely but that sounds dubious to me. Should I even bother applying to these positions if CoffeeScript-only is a dealbreaker for me?


Is it appropriate to only release the GPL-licensed part of the code as open source?

Is it appropriate to release incomplete open-source firmware, or in other words, to release only GPL software but not proprietary software source code? How are non-open-source programs, in compiled firmware for a router/embedded device, allowed with the open-source, Linux-based operating system and other GPL software? For example: If a company releases compiled firmware and source code for a router but only releases the source code for GPL software within the firmware, is it okay, according to the GPL, that the firmware source code would be uncompilable because it is incomplete and is missing the proprietary part of the software?


GPL modify code

If I take GPL code and modify it, does it have to still be under GPL?


Customized Computer Science Degree - What other field would mesh well with computer science?

So here's my situation: I have seven years of experience with web development. I can do PHP, MySQL, OOP, all of that stuff. I would like to make the argument that I have enough technical experience to go out in the real world and get a well-paying, full-time job if I were to drop out right now (I've had a number of job offers recently, and I have already gotten a lot of actual job experience), but I would like to stay in school and get a degree for a number of reasons ranging from the social aspects to the fact that I just want to have a BS in one thing or another as it seems to be important to have one for a lot of jobs, even when it doesn't have anything to do with the job. With that said, it makes little sense for me to major in Computer Science, because that would be like studying everything I already know. I don't want to major in something COMPLETELY different, because that would be contrary to my career goals. I am considering trying to find some interdisciplinary, customized degree of sorts that allows me to combine my current skills with a new education. I'm thinking maybe buisness or even psychology (interface design?). Could I get some ideas for what to major in and tips on who I might talk to? Thanks!


Is Information Technology really Engineering?

While travelling I met a mathematician who was sitting near me. In a discussion he said: "... _there is nothing like engineering in IT or rather programming_ ". A true engineering is what Architecture is, what Electrical and Mechanical is. It made me think and I was puzzled. A percent of my brain agreed also because in Indian Army, there is no subject like Computer Engineering in the Engineering Corps. They don't consider programming as engineering. This is what I heard few years back, I don't know what Indian Army thinks now. What are your views?


Will SRS be sufficient enough for the programmers to do their work, without the additional overhead of FS?

We always make 2 documents the SRS (Software Requirement Specification) and the FS (Functional Specifications) documents for the coders aka programmers. As I have examined the SRS is more like containing both functional and non- functional requirements as compared to the FS that deals only with the functional requirements. To cut it short will the SRS be sufficient enough for the programmers to do their work? and not make any FS anymore?


Why does Java use UTF-16 for internal string representation?

I would imagine the reason was fast, array like access to the character at index, but some characters won't fit into 16 bits, so it wouldn't work... So if you have to handle special cases anyways, why not just use UTF-8?


creating object parameters in {}?

I am trying to decode a piece of code from a book:               List<Person> people = new List<Person>()     {     new Person {FirstName="Homer",LastName="Simpson",Age=47},     new Person {FirstName="Marge",LastName="Simpson",Age=45}     };      Person is just a simple class they made, with a bunch of fields: Name, Last Name, etc... What I don't understand is, don't we send parameters to a constructor of Person in non-curly brackets? I tried replicating this code, but it doesn't seem to fly, any takers? Thanks for input.


Good example of a properly unit tested PHP project?

In hopes of getting myself and my coworkers to adopt automated unit testing methods in future projects, I would like to see a proper example on how it's done. Simple introductionary lessons to unit testing only cover very basic examples and they don't seem to convince anyone of the benefits unit testing can offer. What are some open source projects written in PHP that come with an extensive array of unit tests that are done "properly", and can be used as an example of how testing should be done?


What are the advantages of using bitwise operations?

Following reading the latest CodeProject newsletter, I came across this article on bitwise operations. It makes for interesting reading, and I can certainly see the benefit of checking if an integer is even or odd, but testing if the n-th bit is set? What can possibly be the advantages of this?


Is it worth writing a memory error detection tool for C++ these days?

For past 2 years, I have been writing a tool in C++, meant for C++ as my hobby project. Slowly, I realized that it can be made commercialized, as it can compete with other memory leak detectors. This tool finds:   * all kind of memory leaks   * null pointer exception   * corrupt heap   * static/dynamic array out of range   * multiple or invalid deallocations   * It also gives real time code flow, i.e. what functions are called (without any debug statements) I have written a parser (which also parses the complex syntax of template also) which replaces all the pointers in the code with my custom made smart pointers and new/delete with my wrappers. With making some primary tests, this tool seems to work fine. I still continue to work on it to complete the remaining 20%. However, I am just wondering whether will it be a good idea to work on it ? Now a days, so many programming techniques have been developed to overcome such errors. People simply don't use raw pointers (while most of the errors occur due to pointers). This kind of thoughts, sort of demoralize me. Would highly appreciate some expert opinions.


Should shopping carts be secure via SSL/TLS

So, pretty straight forward question. Somebody told me that all shopping carts should be secure. I can see in some instances where this would be beneficial... but all instances? I realize that typically carts are stored on the server via a session, but in the end the details of the cart have to be sent to the user so they can see what is in their cart. This is very difficult to google because all that comes up is ads for commercial shopping carts. Question: Is it a standard/typical to secure all shopping carts? (pages which display the shopping cart)


AVL Trees and the REAL world

in school we are taught how we can balance an AVL tree upon an insertion or deleting. How is this type of knowledge actually going to be useful in the real world? Can someone give an example on when this type of knowledge would actually be useful? From what I have seen, in the workplace such details hardly ever come up... I can see how detailed knowledge about algorithms and some data structures can be important but not such details as AVL tree rotations (and similar detailed concepts). thanks!


Front-End Business Rules / JSON

I am working on a project that now needs business rules. One design discussed is to make API calls (based on the form we are on) which responds with business rules for form input. I am unsure if this is the best way. The business rules are in JSON, but the business rules server actually has a business rules engine (so the engine crunches the rules and spits out JSON). Some background: In our web app, various forms exist, such as for logging in, registering, editing a profile, etc. Maybe 25-30 forms. They are content managed. For any of these forms, various rules exist to show or hide fields, or present error messages on the form based on logic such as a field name being too long, too short, or not meeting a regular expression. Other things such as required field validators, etc, exist. The idea was to have everything centralized in a different environment (as mentioned above...on the business rules server). I am concerned about making so many calls to a server to get simple rules like a first name being required, or showing or hiding a button based on if a person sells a certain number of widgets, etc. Perhaps a better solution would be to have this rules engine publish to our server, and we just call the local server rather than make API calls from the front end each time. What does everyone think? Is it natural to make API calls from our .net forms (using jquery) to get our rules for each form, each time? Thanks!


Object-Oriented Object Transformations

At my company, we are considering rewriting our business logic and database to have a better architecture after years of organic and unforeseen growth, leading to the inevitable maintenance nightmare. The business model is one where a, let's say, cookie flows through multiple steps, changing states along the way. It is received raw, gets cooked, and is potentially split into two or more smaller cookies depending on the order. At this point, one of two things could happen: one, the cookie or cookies are considered finished and sent out to the customer, or two, the cookies requires outside processing (adding icing, adding food coloring, cutting to a design (there is no theoretical limit to an outside processing change to a cookie but it always changes the physical properties)), from which it is sent straight to the customer or back to us for shipment. The customer can reject the cookies if they don't find them to their standards, and we can then store and attempt to resell the cookies to a less discerning customer and/or send them to outside processing again as per the customer's whim. The way our system currently works is initially assigning it a Raw Cookie number, then baking and/or cutting it and assigning the resulting cookie(s) a Finished Cookie number, one for each cookie. However, there is no common ground between any types of Cookies, resulting in a lot of extra code. I'm trying to propose an object-oriented approach. I am fresh out of college while my coworkers are close to 30 or more years older than me; they know little about it and some are hesitant to change, so my model has to be pretty solid. I have worked with it academically, but never practically, and especially not when monitoring the form of a flow of a specific object. I may be a bit off in my understanding, but I believe OO is the best choice for this problem. I have a UML diagram showing my proposed class hierarchy. Each kind of cookie that can be instantiated has access to a function that turns it into the next step's cookie. Is this a correct way of doing it? Would it be better to have these toCookie() functions accessed through the static abstract Cookie class? ![](https://www.dropbox.com/s/663zilppijft8uq/cookies.png) Don't worry too much about inherited method placement, I'm just trying to understand how objects transform here.


TDD and Version Control

I am currently learning about TDD and trying to put it into practice in my personal projects. I have also used version control extensively on many of these projects. I am interested in the interplay of these two tools in a typical work flow, especially when it comes to the maxim to keep commits small. Here are some examples that come to mind:   1. I start a new project and write a simple test to create an as-yet-nonexistent class. Should I commit the test before writing the class even though the test doesn't even compile? Or should I stub out the minimum amount of code that is needed to get the test to compile before committing?   2. I find a bug and write a test to recreate it. Should I commit the failing test or implement the bug fix and then commit? These are the two examples that come immediately to mind. Feel free to provide additional examples in your answer. **Edit:** I made an assumption in both examples that immediately after writing the test I will write code to make the test pass. Another situation might also arise: I work on a project using TDD for several hours without committing. When I finally make commits, I want to break up my work into small chunks. (Git makes this relatively easy even if you want to want to commit only some of the changes in a single file.) This means that my question is as much about as _what_ to commit as it is about _when_ to commit.


Quicksort and don't bother?

Especially when writing 'standard' (non-HPC) applications, do you consider what sorting algorithm to pick, or just settle with quicksort (which is what most libraries just call sort)? To some extent it may be profitable in specific situations, but on the other hand proper optimization requires some time to analyse the problem and make benchmarks.


Unit testing - one test is partly a "superset" of another, is this wrong?

Wasn't sure how to phrase that title, sorry! I've just come across this in our code base, and was wondering what the consensus was about how to unit test it: **C#** (-ish, sorry, this is paraphrased from memory)               class DateCalculator     {        public static DateTime CalculateLeadTime(DateTime deliveryDate)        {           //return the result of some determinate calculation involving deliveryDate        }     }          //New example     class OrderController     {         public ActionResult GetLeadTime(WidgetOrder order)         {             var leadTime = DateCalculator.CalculateLeadTime(order.GetDeliveryDate() );             return Json(leadTime.Value.Date.ToString("dd/MM/yyyy") );         }     }          //Old, incorrect example     class OrderService     {        public DateTime GetLeadTime(WidgetOrder order)        {           return DateCalculator.CalculateLeadTime(order.GetDeliveryDate() );        }     }      We've then got two unit tests, one to verify that CalculateLeadTime works (this is very easy, you can put in several test values and predict what comes out), and one that GetLeadtime works (still easy, but...). My question is: what would you test here, and where? It makes sense to me to test CalculateLeadTime in isolation, because it could be a complicated calculation, and it's already a nice small predictable unit. But would you then go on to test some of the same stuff (maybe a single representative input and output?) in your GetLeadTime method? Or would you simply test that _any_ DateTime value is returned, and assume that the calculation is correct because you're testing that somewhere else? Or would you not test the Calculate method on its own, because you know that you're going to test it when you use it, and you don't like the duplication? EDIT: to muddy the waters a bit, I can see the code now, and rather than a Service, the calling class is an MVC Controller, and the Action under scrutiny is an AJAX method so returns the result of the calculation wrapped in JSON. The current test verifies that JSON is returned, but not the contents of it. Does this change anything?