title: How to avoid overhead while still implementing null object pattern?

text: I am implementing a binary search tree in java. Inside the BST class I have a protected class Node (in case I want to extend to an AVL tree). The code is below. I had a problem, both conceptually and aesthetically, implementing empty nodes as null pointers. So instead I opted for the null object pattern and created an EmptyNode object, the code for which is also below. However, even though this gives me prettier code and something more conceptually pleasing (to me), I now have the problem that when I'm working with a tree of height n, I can have as many as 2^{n+1} - 2^{n} instances of this EmptyNode class floating around, which takes up space for no good reason. How should I fix this code to avoid this overhead while still implementing the null object pattern? I feel like the EmptyNode should be something conceptually similar to a constant field of Node, but I can't implement that. I also feel like there should be only one copy of EmptyNode being referenced anywhere, but I can't figure out how to implement that either. Any help or recommendations are appreciated.               protected class Node<Key,E>{         protected Key key;         protected E value;         protected Node<Key,E> left;         protected Node<Key,E> right;         protected int height;         protected int balanceFactor;         public Node(){}         public Node(Key k, E v){             key = k;             value = v;             left = new EmptyNode<Key,E>();             right = new EmptyNode<Key,E>();             height = 0;             balanceFactor = 0;         }         public Node(Key k, E v, Node<Key,E> l, Node<Key,E> r){             key = k;             value = v;             left = l;             right = r;             height = Math.max(l.height(), r.height())+1;             balanceFactor = l.height() - r.height();         }         public Key getKey(){return key;}         public E getValue(){return value;}         public Node<Key,E> getLeft(){return left;}         public Node<Key,E> getRight(){return right;}         public int height(){return height;}         public int balanceFactor(){return balanceFactor;}         public void setKey(Key k){key = k;}         public void setValue(E v){value = v;}         public void setLeft(Node<Key,E> l){             left = l;             height = Math.max(l.height(), this.right.height())+1;             balanceFactor = left.height() - this.right.height();         }         public void setRight(Node<Key,E> r){             right = r;             height = Math.max(this.left.height(), r.height())+1;             balanceFactor = this.left.height() - right.height();         }         public boolean isEmpty(){return false;}         public boolean isLeaf(){             return (left.isEmpty()) && (right.isEmpty());         }         public boolean hasLeft(){             return !left.isEmpty();         }         public boolean hasRight(){             return !right.isEmpty();         }     }     protected final class EmptyNode<Key,E> extends Node<Key,E>{         public EmptyNode(){             key = null;             value = null;             left = right = null;             height = -1;             balanceFactor = 0;         }         @Override         public void setKey(Key k){}         @Override         public void setValue(E v){}         @Override         public void setLeft(Node<Key,E> l){}         @Override         public void setRight(Node<Key,E> r){}         @Override         public boolean isEmpty(){return true;}         @Override         public boolean isLeaf(){return false;}         @Override         public boolean hasLeft(){return false;}         @Override         public boolean hasRight(){return false;}     }


title: Why HTML select is not searchable by default?

text: I was wondering why the default select tag of HTML, for example:               <select name="company_name">         <option value=""></option>         <option value="1">Company 1</option>         <option value="2">Company 2</option>         <option value="3">Company 3</option>         <option value="4">Company 4</option>         <option value="5">Company 5</option>         <option value="6">Company 6</option>     </select>      is not searchable by default. Of course this is a browser feature, but it is just really weird that none browser (as far as I know) doesn't have it. Am I missing something here? Is there any browser that actually have as default a searchable select tag? Is it so complicated to achieve it, or is it just that people doesn't want it? Is this a problem with OS? I know that I can achieve that easily with JavaScript (e.g. Jquery Chosen plugin... e.t.c.) but I was wondering if there is any plan for popular browsers like firefox and chrome to have it as default. The result that I am expecting is like the below image on Windows: ![enter image description here](http://i.stack.imgur.com/wyzpv.png)


title: What do you consider the 1st principle(s) of programming?

text: I always liked to ask myself "what's the first principle(s) of this?" after I learned the basic stuff of something (e.g. programming). It's an inspiring question, IMO, that can force you to think about the most important principle(s) behind something, especially a skill such as programming. So, what do you think is the first principle(s) of programming? I'll give my answer below a little later.


title: Frustrated where I am, but not sure where to go with my career

text: I work (3 years now) as a lead developer for a team developing internal tools and websites for a customer account within large outsourcing company. I'm a self taught programmer and my previous incarnation was a 3rd line support guy, so I have a solid infrastructure knowledge. We use VB.Net/MSSQL/SSIS/SSRS ASP.NET (nTier) in house and I have about 8 years coding experience. Without going into too much detail, my boss is very ambitious and uses our team as his footing to get up the ladder. I've been in the team from the start and the only new dev's we have brought in have been people with a bit of VBA/VBScript experience, much to my chagrin, to bolster his empire. It's been a lot of hard work to bring them up to a standard, but there's still a lot for them to learn. This makes my life stressful as I always get the high profile/complex project work to do as other's simply cannot do it, or it'd take them twice/three times longer to do it. My boss is always seeking stuff for us to build for people who haven't asked for it, which usually get's thrown to me as I have the most experience and can pick new API's (etc) up quicker. He doesn't give us proper requirements, we don't get time to design properly before we code, he wants us to throw something (quick and dirty as he calls it) together so we can get it out ASAP. I take pride in my work so I like to do it properly, make my code clean, maintainable etc, and I train the other guys in the team to do the same. But, we always fall on our faces. The customer we drop the apps on say it doesn't do what they need (due to few requirements), or my boss doesn't like it/changes the spec, so we have to rework it, it get's drawn out, and it makes us and me look and feel like fools. We then get accused by boss of not being reactive enough to change. I've had enough. In order to get my skills and knowledge gap's filled, I've been reading Code Complete 2nd Ed (McConnell) and the Head First Design Patterns books. I'm forcing myself to move into C# from VB at home to broaden my horizons. I'm not sure where to go from here. I don't want to code all my life as I'd like to move into a higher level design/architects role at some point in time (I'm 35). Where do I/can I go from here?


title: How to construct a cubie representation of a rubik's cube, given an array

text: Just to get this out of the way, I have seen this, and it is not what I'm looking for. So, let's say you are programming a Rubik's Cube. (I know, very unoriginal, but bored programmers have to do something..) This Rubik's Cube is defined by an array of six 2-D arrays (one for each face,) and these 2-D arrays' sizes vary, based on the size of the cube. For instance, if I had a 3x3x3 cube, the array would be 6x3x3. That is, it would have 6 3x3 arrays. Now, let's say I wanted to get an array of the cubies which make up this cube. Each cubie is defined by two things (I think..): the colors of it and its location on the cube. For example, if you had a solved cube, one of the cubies would be the red, green, and yellow cubie, and, assuming yours is sitting in the same orientation as mine, that cubie would be the front, right, up cubie. However, none of this answers my question: how do I go about defining a set of these cubies, given an array of variable sizes. I know, for instance, that the cubie previously mentioned could be defined as cube[0][0][dimension-1], cube[2][0][0], cube[4][dimension-1][dimension-1]. (For a bit of reference, the order in which I define my faces is front, back, right, left, up, down. Hence the 0, 2, and 4, making front, right, and up.) Anyway, with that said, I'd rather not hard-code all of this and was wondering if there was a simpler way. So, what's the best way to do something like what I was just describing? **Edit:** For clarification, I am trying to get the separate, individual, smaller cubes which make up the Rubik's Cube as a whole. For instance, the piece with the red, green, and white stickers on it.


title: Java style classes in c++

text: I came across this article proposing a style of coding in c++ that looks a bit weird at first. But after reading it over and pondering for a bit I'm really considering giving it a try. The most appealing benefit is the ease of refactoring methods. I find myself constantly changing method names, parameters and so on while writing a new class and in c++ it's quite annoying having to change a method name in two files (.h, .cpp). I tried to find something wrong with this style but apart from the fact that the code will look and feel **really** strange to seasoned c++ programmers I can't spot any major flaw. But since I am quite a inexperienced c++ programmer I hope that someone here might alert me to any potential dangers. So my question is: **Are there any serious drawbacks of using this style of coding?**


title: Encapsulate bitmap (*.bmp) as C++ class

text: How would you implement / design a class which has to represent a bitmap? I'm stuck at handling the different possible color modes and I keep thinking that this should be somehow implementable using templates / design patterns in an elegant AND efficient way: Suppose you have a file.bmp. You then want to open that file to use it in your application:               Bitmap myBitmap();     myBitmap.open("file.bmp");      The bitmap you just opened could have RGB colors, or it could be a grayscale image, or even a 1 bit per pixel image (i.e. black and white). In my application, I want to operate on the image (pixel) data. For example, I need some sort of brightness filter where I black out pixels whose (Red + Blue + Green) / 3 is below some filter value (i.e. 100). So I need access to the pixels:               Pixel somePixel = myBitmap.pixelAt(10,30);      But now I face the problem of NOT knowing what type of pixel this is. Of course, I could provide subclasses of `Pixel` (which then is an abstract base class) which ALL implement methods like `getRGB()`, `getGrayScale()`, ... where each subclass gives a way of converting between those colormodes (i.e. RGB to grayscale) But this feels ... hm, "wrong". Do you know some good way to implement this? A nice feature I was thinking about is something like:               myBitmap.getMode(); // A RGBMode object, RGBMode being a subclass of Mode     myBitmap.setMode(new BlackWhiteMode()); // Converts the bitmap to a 1bpp image      Any ideas, recommendations, improvements? * * * So the really hard part is to represent the different color modes, like RGB (8bit and 4bit), HSV, Grayscale, BlackWhite, ... without messing the applications code.


title: Emacs vs. vim -- what is the difference?

text: I've been programming for years now, mainly in VBA (the _horror_ ), Python, Javascript (Node.js mainly), HTML, and SQL. Most of these languages came with environments that made sense: for VBA I used the built-in editor for Microsoft Office, HTML I could use whatever and debugged with Chrome Dev Tools, and SQL doesn't really require anything fancy. However, for Python and Javascript, I switched around a bunch between editors. History of my usage: Python - IDLE, nano, Notepad++, Sublime Text 2, JetBrains PyCharm   Javascript - Notepad++, Sublime Text 2, Node interpreter, JetBrains WebStorm Languages I plan to learn (eventually): [Clojure | Common Lisp | Scheme], [C | C++ | Objective C], Ruby, Haskell, Assembly As I'm getting more serious into programming, I'm starting to look into the most famous editors--emacs and vim. I have some idea of what they do and don't have over IDEs. I'm a really quick typer so I like the idea of not having to use the mouse. I also love the functions that Sublime Text 2 has for quick switching for funcitons and across open files, and also the multiline select. However, despite lots of research, I'm having trouble figuring out the difference between emacs and vim, and I'd like to have a good understanding of them before deciding which one to commit lots of time to. ## TL;DR **Question:** What are the key differences between emacs and vim? What are the advantages and disadvantages of each for a developer? **Please note: I am _not_ asking which is better, which is higher quality, which is more useful--I'm not trying to restart a famous debate. I just want to know what is distinct about each in terms of functionality and user interface, so I can decide based on my own needs.**


title: What factors should I consider when logging a (JSF) web-app?

text: I've recently read the article The Problem with logging and was wondering about my current logging strategy.   Usualy I use Log4J in my projects and just have to decide _which line/attributes_ I would like to log.   This strategy worked well for me in the past for all my projects without user- interaction. Now I want to set up logging for a WebApp with user-interaction like login, session-management, personalized user pages, etc. and was wondering what would be best practice. To clarify:   I don't ask you to help me decide **what** informations I have to log because that I know for myself (or find information in articles on this site or google).   I'm asking about the things connected with this topic:   * should I bind every log message to the corresponding user for traceability   * should I open up a new log file for every session   * are there other good libraries especially for logging webapps   * should I only log fatal errors in file and handle minor errors inside the view (e.g. show user)      * and how chatty should I be in those messages shown to the user I also know that this is a broad topic and that this question can easily be answered by "it's personal flavor" or "it depends" but I would highly appreciate anyone who's willing to give me some useful hints. Thanks in advance


title: Can I license a program under Apache License 2.0, if it is using/including Eclipse Link (EPL or EDL)?

text: Can I license a program under Apache License 2.0, if it is using/including EclipseLink? (EclipseLink under Eclipse Public License or Eclipse Distribution License) I did not change anything in EclipseLink. I would realy like to distribute a Version that includes the needed EclipseLink jars, so that it is working "out of the box".


title: Magic square check for N×N matrix with minimum complexity

text: Is there any algorithm that works better than `O(n²)` to verify whether a square matrix is a magic one (e.g. such as sum of all the rows, cols and diagonally are equal to each other)? I did see someone mention a `O(n)` time on a website a few days ago but could not figure out how.


title: Selective mutual exclusion in Dining Philosophers and Readers and Writers problem

text: I've been reading about selective mutual exclusion (SME). The idea I got is that if a process competes for its resources against a subset of all the other process instead of competing with all the other processes then I'm facing a SME problem. 1) Can you confirm my definition is right? Now, the dining philosophers problem is a classic example of this (SME by proximity) 2) In the distributed solution (in which each philosopher competes for both forks against two other philosophers), if instead of 5 philosophers, there were 3 of them, would it still be a SME problem? (I think not, because each philosopher will be competing with all of the others) 3) And in the centralized "conductor" solution, having 5 philosophers, would it still be a SME problem? (I think it would, because although all processes are competing to get to the waiter, each philosopher is only competing with two of the other to get both specified forks) Finally, in the readers and writers problem (SME by process type) 4) If only 1 reader and 1 writer were allowed, would it still be a SME problem? (I think not, because actually every process will be competing with all the others)


title: How to model two similar tasks with the Use-case diagram

text: I am trying to draw a use-case diagram for a software project. Two requirements for the software I am trying to model in use-case diagram are:   1. A customer (i.e. `Client`) should be able to cancel its previous request. In this case, the client must select the relevant request from their list of request.   2. A `travel agent` should be able to cancel a request. in this case, the agent must the client from the list of clients and the request from the list of request issued by that client. How should I model this two requirements in a UML user-case diagram? I've ended up to something like this: ![My use-case diagram](http://i.stack.imgur.com/VjW4B.png)


title: Branch twice for unique condition

text: Consider an application that displays only Foobars belonging to themselves to normal users, and all Foobars to admins:               -- Normal users:     SELECT * FROM Foobar WHERE user_id=:user_id;          -- Admins:     SELECT * FROM Foobar;      Currently, this how the queries are represented in the codebase:               $sql = "SELECT * FROM Foobar";          if ( $user['type']!='admin' ) {         $sql.= ' WHERE user_id=:user_id';     }          $stmt = $pdo->prepare($sql);          if ( $user['type']!='admin' ) {         $stmt->bindValue(':user_id', $user['id']);     }      I do not like this dual-branching approach from a maintainability standpoint. For instance, a bug like typing `$user['type']=='admin'` instead of `$user['type']!='admin'` would have to be found and fixed in two places instead of one. However, I also don't like the idea of separate functions for each case: admins and regular users. A third approach would be to branch once and there create the SQL to add and the values to bind:               $sql_to_add = '';     $array_to_bind = array();          if ( $user['type']!='admin' ) {         $sql_to_add = ' WHERE user_id=:user_id';         $array_to_bind = array( ':user_id'=>$user['id'] );     }          $sql = "SELECT * FROM Foobar {$sql_to_add}";     $stmt = $pdo->prepare($sql);          foreach ( $array_to_bind as $k=>$v ) {         $stmt->bindValue($k, $v);     }      However I find this approach cumbersome. **Is there a design pattern for this situation?** What is the canonical way to handle situations where the code must branch in two separate locations on the same `if` condition?


title: Further writings by Rob Pike on software complexity and design

text: in "Notes on Programming in C", in section "Complexity", Rob Pike writes: > Most programs are too complicated - that is, more complex than they need to > be to solve their problems efficiently. Why? Mostly it's because of bad > design, but I will skip that issue here because it's a big one. .../... Does anyone know whether Rob Pike has written more about software design and how to avoid complexity, and where this might be found?


title: Chained ruleset parsing and evaluation code: recommendations?

text: So I have to write a filtering system, which may apply preprocessed ruleset to data - and trigger some actions defined in the ruleset while continuing its evaluation.               <ruleset name="1">      <rule>       <conditions>        <and>         <or>          <match image="aceofspades" level="70" />          <match image="aceofdiamonds" level="66" />         </or>         <not>          <match image="aceofclubs" level="60" />         </not>        </and>       <action name="apply_ruleset" ruleset="2">      </rule>      <rule>       ...      </rule>     </ruleset>     <ruleset name="2">     </ruleset>      (Good example of what it feels to be alike: sendmail configs; some Apache configs; IPTables ruleset, with multiple tables, JOIN/ACCEPT/DROP, etc). What bothers me with every current design I can think of:   * keeping state of and-or nodes   * being able to jump between main and sub- rulesets easily   * tracking circular references   * keeping a vast set of possible conditions   * runtime speed: parsing/hashing may take time, but each data packet must be passed through dataset as fast as possible. What should I read/think of to be sure that my parser will be nice enough to work with large sets and don't mess the speed/flexibility too much? _(Not to mention iptables code)_. * * * Target language is C++ (however would like to implement a similar system in Perl later..), was reading through this \- but still not see a good solution for switching rulesets / keeping with boolean logics within rules.


title: Why doesn't CSS natively support variables and hierarchy?

text: I am new to UI development, but I feel very uncomfortable with how CSS works. My use case is that I wanted to apply some specific styles inside a particular `div` on a page. **CSS attempt:**               div.class1 {         font: normal 12px arial, helvetica, sans-serif;         font-color: #f30;     }     div.class1 div.class2 {         border: 1px solid #f30;     }      **LESS attempt:**               @red: #f30;     @font-family: arial, helvetica, sans-serif;     div.class1 {         font: normal 12px @font-family;         font-color: @red;         div.class2 {             border: 1px solid @red;         }      The CSS version can induce bugs, since it forces you to repeat `#f30` & `div.class2` every time you try to achieve hierarchy and variable re-use. **My questions:**   * Why is that CSS makes things difficult?   * LESS does nothing special - just makes obvious improvements and translates to CSS?   * What is that CSS wants to motivate in users because of which it promotes such a redundant coding style? I strongly believe CSS should be what LESS is. Definitely I am overlooking some obvious advantage of why things are done that way in CSS. I thought it was a legacy problem, but I was surprised when I saw no attempts to solve this with CSS3. Please help me understand how should I approach CSS?


title: How does const storage work? (Item 2, Scott Myers Effective C++)

text: In Item2 on page 16, (Prefer consts, enums, and inlines to #defines), Scott says: > Also, though good compilers won't set aside storage for const objects of > integer types... I don't understand this. If I define a const object, eg               const int myval = 5;      then surely the compiler must set aside some memory (of int size) to store the value 5? Or is const data stored in some special way? This is more a question of computer storage I suppose. Basically, how does the computer store const objects so that no storage is set aside?


title: What makes a successful architecture team?

text: I was recently appointed as the leader of a newly formed architecture team (most similar to systems or enterprise architecture, not explicitly software architecture). My company is medium sized, and there are ~8 different engineering groups each with their own stacks, and their own culture. As part of this re-org, many of those groups are going to be consolidated and part of my team's job is to figure out how to bring their stacks into alignment. In thinking about the new team's charter, we've struggled with:   1. How should the architecture team engage and interact with the engineering teams without stepping on toes, while remaining effective? When should architecture stand back and let engineering do its thing?   2. (related to the above) When is it appropriate for the architecture team to build something versus when should the architecture team provide guidance, and allow the engineering team to build it themselves?    3. How can an organization measure the success of an architecture group? None of the goals of architecture seem easily quantifiable. **As an example:** Should the architecture team be involved with setting coding standards? Theoretically, this is something that the engineers use day to day, and could be set by engineering leadership, but it could also be tied to architectural needs. For example, if architecture defines the directory structure of a standard project, and how the build should be set up to fit within the CI that they've mandated, shouldn't they also have a say in the documentation and coding standards in order to be consistent with their directory structure. Maybe this is an inelegant example, but I think it illustrates our line of thinking. **Another example:** It is determined that we need a new key/value store to support the needs of a particular project, but it is not clear that the requirements of that project will ever be felt in future projects -- everyone else has a k/v store that works just fine. Clearly architecture will be involved in the decision of which technology to use (and vet whether a new technology is, in fact, _really_ needed), but should the architecture team be charged with building the infrastructure for the new tech? If it is not likely (we all know that means VERY LIKELY) that it will be re-used in different projects, it seems like the answer should be "no", but given the parenthetical above, I'm inclined towards "yes". Should architecture be involved in project- level tech decisions, and to what level should they be involved? **My initial thoughts:**   * The architecture team prototypes the new technologies/systems that it espouses and then transitions to relevant teams.    * By and large, architecture tries to avoid getting involved with project-level problems (it isn't "you should use this new charting package that we think is cool", it is "we are trying to get everyone onto this uniform front-end framework, you need to use it").   * Form an architecture committee that includes engineers and business leaders to make sure engineers are part of the decision making process.    * Architecture must stay tightly linked to business needs and goals without stepping on Product's toes. A core responsibility of architecture is to inform the business of un(der)utilized tech that offers potential upside.   * Architecture should ultimately make the lives of engineers better. Our main goal should be to solve problems once, so that they don't get solved many times, which means that engineers will have more time to work on 'the fun stuff'. Sorry to be so long winded. I'd love any feedback, especially from those who have worked at organizations with impactful and effective architecture teams.


title: Tasks incorrectly categorized with online text classifiers

text: **Context: Finding company to do the job** The use case of an application I want to write is that a user will describe a task to be performed by some company, e.g., > I want to move 10 boxes (30x40x50cm) of books and clothes from London to > Bristol next week. How much would that cost? and the application will find candidate companies that could do the task. In this case it would need to categorize the task as for _removal/transportation_ companies. **Problem: incorrect categorization** I tried a number of online services for text categorization but results are discouraging. uClassify classified my text as "Home", "Games", and "Arts"; Textimate.me \--- as "Science & Environment"; Textwise returned "Business/Consumer_Goods", "Services/Clothing", and "Arts/Design/Fashion". The possible reasons for incorrect categorization:   * task description is very short and there is no evident characteristics in the text to differentiate what is more important for the user: boxes, clothes or maybe moving them,   * classifiers trained on other types of texts,   * classifiers trained with respect to a different taxonomy. How would you tackle such a problem? **Potential solution: harvest domain-specific corpus** Since the problem is quite specific to my domain I think about using supervised machine learning algorithm, that would learn with respect to already categorized corpus of such tasks. The corpus can be harvested from sites with tasks already categorized by customers (variation of e-bay). I could also pre-process text before machine learning: extract only verbs ("move") and nouns originating from verbs ("translation"), as they denote what has to be done. This requires quite a lof of work, so I'm curious whether this is the right direction.


title: Algorithm for perfect non-binary graph layout

text: I have a complex non-binary graph model.   Each tree node can have multiple children&parents (a node can also have a connection to it's "brother"). A node is represented as square on screen with lines to the connected nodes.   For that I want to use Draw2D and GEF libraries. The problem I am facing is the graph layout. I need a nice algorithm that can reposition the square nodes and the connections with minimum intersections and also make it symmetric as possible.


title: PHP and performance

text: I always hear that PHP is for medium and small websites whereas .NET and Java for enterprise applications. My question is about PHP. Why is PHP not a good option for enterprise web applications? Is it because if the web application becomes bigger then PHP will be slower as it is an interpreted language? I know that corporate world will choose .NET or J2EE because of the integration with their products and because of back end services, etc. However, if we just have PHP for building sites and web applications then how can we use it to perform well with big sites? In short, Is there a relationship between the performance of PHP and the size of the website? What are the factors that make PHP not appropriate option for big sites?


title: Shouldn't the lazy evaluation/execution be syntactically differentiated from eager evaluation/execution in C#?

text: We know about the deferred execution or lazy evaluation features introduced in C#. But at times, people become confused with them. Because there is no significant difference. You can only know if you know the internals. Shouldn't there be a syntactical difference between them to remove confusion? I think the keyword `let` of F# can be imported to C# to specify the lazy evaluations. Like-               let selectedItems = Items.Where(i => i.Count < 5);      What do you guys think? Update:   In reply to the first answer, I am not proposing that the `let` keyword is to be used in the places where the lazy evaluation is already happening according to the present compiling model. Then it will be of no use actually. I am proposing that the `let` keyword should define the type of execution. To be clear-               var selectedItems = Items.Where(i => i.Count < 5).ToList();      will be executed eagerly by present model. But my proposal is, if we use               let selectedItems = Items.Where(i => i.Count < 5).ToList();      it will be executed later, just when required. Though this is not desirable as it will return different lists of same items each time. The 'thing' defined with `let` keyword can be thought of a constant 'expression' like F#. Update 2:   Linking this SO answer as a proof of people's annoyance with deferred execution- http://stackoverflow.com/questions/215548/whats-the-hardest-or-most- misunderstood-aspect-of-linq/215562#215562


title: How to do lazy loading in a SOA fashion?

text: For example, I've got a root object exposed in a SOA service, say `Invoice` (`Invoice` has line items as children). Sometimes, I need to retrieve its detail line items. I'm thinking to make it lazy loading, because it's a traffic overhead to transfer line items every time `Invoice` is required. But in SOA fashion, it seems unlikely. Because all it can expose are `Invoice` POCOs, with contain no logic. Thus I cannot attach my lazy loading logic to `Invoice` to instruct it to load lines items when needed.


title: Am I competing with a client? is it fair?

text: I've been working as part of my service company for a client (ClientA) for a year now on building a platform. A few weeks ago another client (clientB) asked me for a quote for building a similar product. I said to clientB that we have been working on a similar product for a client and that we have a mature platform that they may use without all the hassles of doing it from scratch. So I sugested that they partner with my other client to use his platform instead. Unfortunately, the negotiation didn't went well because of many factors:   1. ClientA don't want to have a partnership with ClientB but instead want to keep owing the platform and provide it to clientB as a SAAS service: which I can understand because of the investment already made.   2. The platform doesn't have all the features that ClientB wants, so they need to invest money in developing those. However they are reluctant to invest such money in a platform they don't own. They are planning to sell it to thousands of their own clients, so basing their whole business on a product they don't have control over is not a good move for them. I've done my best to make them agree, but seems like they can't because of each one wanting to have control on the platform. Now clientB wants, as he already wanted at first, my company to build a similar platform and wants my company to partner in this. We'll share any ROI with them. It is a tough decision for me to take because I understand that we can't as a company keep working on those two platforms at the same time. The first version of the platform was obtained from a freelance website under the "work for hire" clause, so the code belongs to clientA. So we cannot reuse any part of that work. As a company manager, I'm in a dilemma because I suspect that clientA will take that move as an unfair one. What are your thoughts on that matter? Edit: There is no signed NDA and anyway would not have signed an NDA with a non competing clause.


title: Which is the most practical way to add functionality to this piece of code?

text: I'm writing an open source library which handles hexagonal grids. It mainly revolves around the `HexagonalGrid` and the `Hexagon` class. There is a `HexagonalGridBuilder` class which builds the grid which contains `Hexagon` objects. What I'm trying to achieve is to enable the user to add arbitrary data to each `Hexagon`. The interface looks like this:               public interface Hexagon extends Serializable {              // ... other methods not important in this context              <T> void setSatelliteData(T data);              <T> T getSatelliteData();     }       So far so good. I'm writing another class however named `HexagonalGridCalculator` which adds some fancy pieces of computation to the library like calculating the shortest path between two `Hexagon`s or calculating the line of sight around a `Hexagon`. My problem is that for those I need the user to supply some data for the `Hexagon` objects like the **cost** of passing through a `Hexagon`, or a `boolean` flag indicating whether the object is **transparent/passable** or not. My question is how should I implement this? My first idea was to write an interface like this:               public interface HexagonData {              void setTransparent(boolean isTransparent);              void setPassable(boolean isPassable);              void setPassageCost(int cost);     }      and make the user implement it but then it came to my mind that if I add any other functionality later all code will break for those who are using the old interface. So my next idea is to add annotations like `@PassageCost`, `@IsTransparent` and `@IsPassable` which can be added to fields and when I'm doing the computation I can look for the annotations in the `satelliteData` supplied by the user. This looks flexible enough if I take into account the possibility of later changes but it uses reflection. I have no benchmark of the costs of using annotations so I'm a bit in the dark here. I think that in 90-95% of the cases the efficiency is not important since most users wont't use a grid where this is significant but I can imagine someone trying to create a grid with a size of `5.000.000.000 X 5.000.000.000`. So which path should I start walking on? Or are there some better alternatives? _Note: These ideas are not implemented yet so I did not pay too much attention to good names._


title: How to design a website with search capabilities?

text: Suppose you want to create a web page with some search capabilities over a database. Search has to be restricted both on some categorization of data and open text given by the users. Functional and non-functional requirements pose this constraints:   * Search has to be fast   * Data representation paradigm (i.e. Relational, Object-Relational, Semistructured...) should support big modifications on every stage of software lifetime.   * Database's paradigm should permit easy refactoring for existing client code Having this into account   1. Would you recommend a relational database? How would you tackle the constraints in this scenario?   2. Would you recommend a XML database? How would you tackle the constraints in this scenario?   3. If you think above solutions to be not useful in the light of this problem... what could be a useful approach? Please give some bibliography (or some websites) supporting your answers. thanks!


title: Is PhoneGap scalable?

text: I'm a front-end developer that is looking into mobile apps development. When I'm searching for ways getting into app development PhoneGap comes as first and most familiar language stack development method. It's really sweet that I can develop an app with HTML/CSS/JavaScript using PhoneGap APIs. But is PhoneGap scalable enough? How far I can go with it in making complex apps and large scale apps? Why and why not I should start learning Objective-C to get into app development?


title: How can I let prospective employers know I'm a great developer?

text: I've recently read through Joel's guide to finding great developers, and I feel really strongly that I am _smart_ and _get things done_. The problem is, I didn't learn how to _get things done_ until about halfway through college, so my GPA is less than stellar. Additionally, I've got a few other things going against me: late into the job market (~30), no internship, state college instead of university, and when I graduated, I pretty much had to take the first job that offered. With all of these things piled together, my resume (the first step to getting a job), is not terribly impressive. What can I do to let people know that I'm a great developer and would complement the best companies in the world?


title: The idea of functionN in Scala / Functionaljava

text: From brain driven development > It turns out, that every Function you’ll ever define in Scala, will become > an instance of an Implementation which will feature a certain Function > Trait. > > There is a whole bunch of that Function Traits, ranging from Function1 up to > Function22. > > **Since Functions are Objects in Scala and Scala is a statically typed > language, it has to provide an appropriate type for every Function which > comes with a different number of arguments.** If you define a Function with > two arguments, the compiler picks Function2 as the underlying type. Also, from Michael Froh's blog > **You need to make FunctionN classes for each number of parameters that you > want?** Yes, but you define the classes once and then you use them forever, > or ideally they're already defined in a library (e.g. Functional Java > defines classes F, F2, ..., F8, and the Scala standard library defines > classes Function1, ..., Function22) So we have a list of function traits (Scala), and a list of interfaces (Functional-java) to enable us to have first class funtions. I am trying to understand exactly why this is the case. I know, in Java for example, when I write a method say,               public int add(int a, int b){         return a + b;     }      That I cannot go ahead and write               add(3,4,5);      ( error would be something like : method add cannot be applied to give types ) We simply have to define an interface/trait for functions with different parameters, because of static typing?


title: Container types in Golang

text: For a non-OOP language like google Go, is it idiomatic to go about implementing new container types using datatypes like arrays or lists so as to implement convenient functionality like `contains` method which is absent from all in built container types?


title: java framework for a web wizard

text: I'd like to create a web wizard or a wizard on/within a website. I know there are several java frameworks for wizards but there is none for the web in particular. If I search for a framework, I always get wizards to create a website, applet, servlet and what not. But never how to create such a wizard itself. So the question(s) is: What framework should I use to create a web wizard? And what frameworks are there? The wizard will be the visualisation for a BPEL Process deployment on a apache ode. I thought a webapp would be an easy way because the apache is running anyway. I'm not bound to that, perhaps someone has a better idea.


title: Is there a formal definiton of software quality

text: I am looking for a formal definition of software quality. It is my understanding that ISO 25000 is intended to provide or measure the quality of a piece of software, but it doesn't appear ready yet and I can't tell if it specifically contains such a definiton. Currently ISO 9126 did contain one such definition, but my understanding is that it is being replaced with ISO 25000. So I ask, is there are formal definition of software quality?


title: "Used with permission" reusable in a GPLv2 derivative work?

text: The LICENSE file of a GPLv2 application I am modifying contains a statement saying that certain resources used in the application were "used with permission" from 3rd parties - such as textual material from a published book and certain graphics. Question: in my derivative work based off of this application, am I required to seek permission from those 3rd parties to use those same resources? Or does the GPLv2 encompass the fact that the use of these resources was already permitted in the original work, and thus the 3rd-party permission "flows through" to my derivative work?


title: Namespaces, why are they necessary for prefixes?

text: So I've been reading about namespace on w3schools and I understand they are to uniquely identify an element. But what is the point of having namespaces if you have to have prefixes along side them. Are you always required to have prefixes with namespaces? If not are you always required to have namespaces with prefixes? If so why? For example:               <root xmlns:h="http://www.w3.org/TR/html4/" xmlns:f="http://www.w3schools.com/furniture">           <h:table>        <h:tr>        <h:td>Apples</h:td>        <h:td>Bananas</h:td>      </h:tr>                    <f:name>African Coffee Table</f:name>         <f:width>80</f:width>         <f:length>120</f:length>       </f:table>     </root>      Doesn't f and h uniquely identify the different element types? Thanks for your help. I'm really at a loss at understanding why namespaces exists.


title: State Pattern - should a state know about its context?

text: I am referring to the state pattern as described in this link. In the example class diagram, a context has numerous states. However, it does not show how does a state communicates with a context (perhaps an input in a state has impact on a setting in the context). The two examples on the page shows either passing the context to the state via a function, or storing a reference to the context. Are those advisable? Are there other ways for a state to communicate with a context? * * * Update to an edit: For instance, I am doing a remote control which can have several states. Say, the context has a setting for Volume, and I am in one of the states which allow me to tweak the volume. How should the state communicates with the context that the volume is being changed?


title: Getting from a user-story to code while using TDD (scrum)

text: I'm getting into scrum and TDD and I think I have some confusion which I'd like to get your feedback about. Let's assume I have a user-story in my backlog, in order for me to start developing it as part of TDD I need to have requirements, right so far? Is it true to say that the product manager and the QA should be responsible for taking the user-story and breaking it down to acceptance tests? I think the above is true since the acceptance tests need to be formal, so they can be used as tests, but also human readable so that the product can approve they are the requirements, right? Is it also true that I later take these acceptance tests and use them as my requirements, i.e. they are a set of use-cases which I implement (through TDD)? I hope I'm not making too much of a mess but that's the current flow I have in mind right now. **Update**   I think my initial intentions were unclear so I'll try to rephrase. I want to know more details about the scrum flow of turning a user-story into code while using TDD.   The starting point is obvious, a user surfaces a need (or the user's representative as the product) which is a short 1-2 lines description in the known format and that is added to the product backlog.   When there is a spring planning meeting user-stories are taken from the backlog and assigned to developers.   In order for a developer to write code they need requirements (especially in TDD since the requirements are what the tests are derived from).   When, by whom and to which format are the requirements compiled?   What I had in mind was that the product and QA define the requirements via acceptance tests (I'm thinking of automatic using FitNesse or the sort but that's not the core I think) which help to serve 2 purposes at the same time:   1. They define "Done" properly.   2. They give a developer something to derive tests from. I wasn't sure when these were written (before the sprint they're picked then that might be a waste since additional information will arrive or the story won't be picked, during the iteration then the developer might get stuck waiting for them...)


title: What naming convention for C# file that contains multiple classes?

text: In C# projects, we frequently group small and tightly related classes into the same `.cs` file. This practice reduces the friction of dealing with a myriad of files containing close to no actual code. Yet, is there an established practice to name the _file_ that contains multiple classes?


title: Authoritative sources for exception handling best practices

text: My work place suffers from a bad case of the Pokemon Exception Handling anti- pattern with constructs like the following splattered across the code base:               try {         ...     } catch (Exception ex) {         // Log and pretend nothing happened.         Log.LogException(ex);             }      I've found lots of answers on Stack Exchange sites that explains why the above is bad. But I haven't found any _authoritative_ sources, like books, developer journal articles or msdn pages explaining why you shouldn't write code like the above. Are there any sources like that, if so, where? **Edit** : I'd say that "famous" bloggers also count as authoritative sources. My rule for what counts as authoritative or not is not exactly set in stone.


title: Why do all <algorithm> functions take only ranges, not containers?

text: There are many useful functions in `<algorithm>`, but all of them operate on "sequences" - pairs of iterators. E.g., if I have a container and like to run `std::accumulate` on it, I need to write:               std::vector<int> myContainer = ...;     int sum = std::accumulate(myContainer.begin(), myContainer.end(), 0);      When all I intend to do is:               int sum = std::accumulate(myContainer, 0);      Which is a bit more readable and clearer, in my eyes. Now I can see that there might be cases where you'd only want to operate on parts of a container, so it's definitely useful to have the _option_ of passing ranges. But at least in my experience, that's a rare special case. I'll usually want to operate on whole containers. It's easy to write a wrapper function which takes a container and calls `begin()` and `end()` on it, but such convenience functions are not included in the standard library. I'd like to know the reasoning behind this STL design choice.


title: How would another popular language avoid having to use the factory pattern while managing similar complexity as in Java/Java EE?

text: Factory pattern (or at least the use of `FactoryFactory..`) is the butt of many jokes, like here. Apart from having verbose and "creative" names like RequestProcessorFactoryFactory.RequestProcessorFactory, is there anything fundamentally wrong with the factory pattern if you have to program in Java/C++ and there is a usecase for Abstract_factory_pattern? How would another popular language (for example, Ruby or Scala) avoid having to use it while managing similar complexity? The reason I am asking is I see mostly the criticism of factories mentioned in the context of the Java/Java EE ecosystem, but they never explain how other languages/frameworks solve them.


title: Spreading incoming batched data into a real-time stream

text: I would like to display some events in 'real-time'. However, I must fetch the data from another source. I can request the last X minutes, though the source is updated approximately every 5 minutes. This means that there will be a delay between the most recent data retrieved and the point in time that I make the request. Second, because I will be receiving a batch of data, I don't want to just fire out all the events down a socket once my fetcher has retrieved it: I would like to spread out the events so that they are both accurately spaced amongst each other and in sync with their original occurrences (e.g. an event is always displayed 6 minutes after it actually happened). My thought is to fetch the data every 5 minutes from the source, knowing that I won't get the very latest data. The original data would be then queued to be sent down the socket 7.5 minutes from its original timestamp – that is, at least ~2.5 minutes from when its batch was fetched and at most 7.5 minutes since then. My question is this: is this the best way to approach the problem? Does this problem have any standard approaches or associated literature related to implementation best-practices and edge cases? I am a bit worried that the frequency of my fetches and the frequency in which the source is updated will get out of sync, leading to points where no data will be retrieved from the source. However, since my socket delay is greater than my fetch frequency, the subsequent fetch should retrieve newer data before the socket queue is empty. Is that correct? Am I missing something? Thanks!


title: SQL string field lengths in a db having about 6 different types of addresses, with about 20 markets and environments

text: I have been advocating lately that all string fields should be ntext / nvarchar(max) - we're using MS SQL Server. The objections seem to be either "it's not a good idea" (without any reason) or "that would allow the customer to send a lot of crap". Since I believe in filtering out the crap before it hits the database, is there a _good_ reason why my idea is bad? My main argument for not limiting the string fields is that I have discovered that we have about six different types of addresses (customer, reseller and so on), with about 20 markets (each having its own database) and environments. I have spotted at least ten different lengths for say Address1 and the same thing happens for other fields. Instead of "standardizing" them and then discovering that we missed something, I suggested that we go ahead and limit the inputs and let the database handle anything. Does anyone have a pro/con I don't see? (I have seen Rule of thumb for field sizes but my focus is "is making everything max sized wrong?")


title: Word recognition in a string without spaces or punctuation marks

text: I have a small C# project that reads a file and gives me an output: a string that does not contain spaces nor any types of punctuation marks. It may also contain a few misspellings. Ex. Output:   THEQUICKBROWNFOXJUMPSOVERTHELAZYDOG **I wonder if there is a way to analyze this string by using text mining/data mining and/or regular expressions to indentify the words (preferably nounds, verbs and so forth.) in the string?** I want to read a bunch of files giving me different outputs and put them in statistical order from the one with the most found words to the one which only contain a string of mumbo jumbo. Also, if the string contain misspellings like:   THEQUICGBROWNFOSJUMPSOVERTHHLAZYDOG   I know that regular expression can calculate the "distans" from a misspelled word and find the most matching one (using a corpus and probability) but this might prove more of a challenge as the string does not have any spaces or punctuation marks. Any ideas how I can solve this?


title: How can I explain the A a = new B();?

text: Let's say we have some class structure:                    public interface IA { public void doA(); }          public class A implements IA { public void doA(){ System.out.println("A class doA");}          public class B extends A { public void doA(){ System.out.println("B class doA"); }      And now in a main I state this:                    //in a main          IA ia = new B();          ia.doA();      Am I correct in stating that the the runtime object of `ia` is a B class and it has inherited all the super classes methods and attributes? The printout from within the imaginary main is `B class doA` as the method `doA` in B will hide the same methods in its super classes?


title: What is the difference between Enumeration and Iterator?

text: What are differences between Enumeration and Iterator This question is from early ages of interview , I have not seen this question on recent interviews but it was in 2012, now days questions like implementation of HashMap, ConcurrentHashMap etc has take its place, nonetheless its very useful to know fundamental difference between Iterator and Enumeration. Some time its also asked as Iterator vs Enumeration or Enumeration vs Iterator which is same. important point to note is that both Iterator and Enumeration provides way to traverse or navigate through entire collection in java


title: Should I provide synonyms in an API?

text: I'm designing a small library and there is a strong temptation to provide synonyms to some of the exported functions.               var foldl = function(){ ... };     var reduce = foldl; //reduce is a synonym for foldl      I imagine that the multiple names might help the initial learnability of the API (since the user is more likely to stumble on the function he wants) but at the same time I worry the duplication will bring needless complexity. **What rules should I keep in mind when thinking about adding a synonym to a function in my API?** When whould I choose a "there is more then one way to do it" api and when should I incentivize there is one way to do it" instead?


title: How to measure time lost due to environment problems?

text: I'm trying to determine how we can measure how much time the developers are loosing to poorly managed environment and inefficient ways-of-working. **The goals are:**   1. Show managment how big the problem really is, in terms they can relate to. I.e $$$   2. Get a good baseline so that we can measure the progress.  **Short background:** We manage the programming environment for 500 developers. This includes IDE (mainly Eclipse and Visual Studio), version control systems (ClearCase), what programs they have available. Basically, everything related to the computer that involves programming. Examples: Not being able to work with tools they are used to due to strict security requirements. Using version control system in a bad way causing problems when working in parallell. Setting up project environment is done manually and different each time. Using homecooked frameworks, rather than what are industry standard. Building takes longer than needed due to homemade practices. Deploying takes longer than needed due to homemade practices. This does **not** include the actual coding pratices, project management or meetings. Sure, we can influence those things too, but for this questions those things are out of scope. **The question:** So, how can we determine how much time are lost due to the project environment? The only thing I can think of to get some good data are polls and questionnaires. Have anyone done something like this? What were the experiences and results? Are there other literature or reasearch where I can get ideas from or compare results with? _Other questions exists regarding programmers inefficiency (likethis), but those relate to coding practices and bugs._


title: Where should I store my Image files for an app

text: So In my app, I have a bunch of images. And in order to keep the app size down, I could store those images on my serve, and just download and cache them as needed. But my question is, will that hurt user experience? Is it likely an iOS user won't have internet access while using my app?


title: Mercurial Repository structure with heavyweight corporate comms, configuration management & test requirements

text: I am yet another Subversion user struggling to re-educate myself in the Tao of distributed version control. When using Subversion, I was a big fan of the project-minor approach, and, with most of my former employers, we would structure our repository branches; tags & trunk as follows:               branches-+              +-personal-+              |          +-alice-+              |          |       +-shinyNewFeature              |          |       +-AUTOMATED-+              |          |                   +-shinyNewFeature              |          +-bob-+              |                +-AUTOMATED-+              |                            +-bespokeCustomerProject              +-project-+                        +-shinyNewFeature                        +-fixStinkyBug     tags-+          +-m20110401_releaseCandidate_0_1          +-m20110505_release_0_1          +-m20110602_milestone     trunk      Within the actual source tree itself, we would use (something like) the following structure:                 (src)-+             +-developmentAutomation-+             |                       +-testAutomation             |                       +-deploymentAutomation             |                       +-docGeneration             |                       +-staticAnalysis             |                       +-systemTest             |                       +-performanceMeasurement             |                       +-configurationManagement             |                       +-utilities             +-libraries-+             |           +-log-+             |           |     +-build             |           |     +-doc             |           |     +-test             |           +-statistics-+             |           |            +-build             |           |            +-doc             |           |            +-test             |           +-charting-+             |           |          +-build             |           |          +-doc             |           |          +-test             |           +-distributedComputing-+             |           |                      +-build             |           |                      +-doc             |           |                      +-test             |           +-widgets-+             |                     +-build             |                     +-doc             |                     +-test             +-productLines-+             |              +-flagshipProduct-+             |              |                 +-coolFeature             |              |                 +-anotherCoolFeature             |              |                 +-build             |              |                 +-doc             |              |                 +-test             |              +-coolNewProduct             +-project-+                       +-bigImportantCustomer-+                       |                      +-bespokeProjectOne                       |                      +-bespokeProjectTwo                       +-anotherImportantCustomer-+                                                  +-anotherBespokeProject      The idea was (and still is) to use the structure of the repository to help structure communication between the engineering team; the customer-facing part of the business and various other stakeholders & domain experts. To wit: Source documents that sit in one of the "project" directories get used (and earn money) only once. Documents that sit in one of the "productLines" directories earn money as many times as a product from that particular line gets sold. Documents that sit in one of the "libraries" directories earn money as many times as any of the products that use them get sold. It makes the notion of amortization of costs explicit, and helps build support for source document reuse across the business. It also means that there is a common structure over which our build automation tools can operate. (Our build scripts walk the source tree looking for "build" folders within which they find configuration files specifying how each component is to be built; a similar process happens for documentation generation and testing). Significantly, the products on which I work typically take a LONG time to run performance measurement & characterization tests; from 20 to 200 hours; generating somewhere between several GB to several TB of processed test results/intermediate data (that must be stored and tied to a particular system configuration so performance improvement over time can be measured). This issue makes configuration management an important consideration, and also imposes some requirement for centralisation, as typically the computational resources needed to run the performance measurement and characterization tests are limited; (a small cluster of 64-128 cores). As one final note; the continuous integration system knows that it needs to trigger a build; static analysis; smoke test & unit test run each time trunk is modified, each time any "tag" branch is modified, and each time any "AUTOMATED" branch branch is modified. This way, individual developers can use the CI system with their personal branches, an important capability, IMHO. Now, here is my question: How can I replicate all of the above (and improve upon it, if possible), with Mercurial. \--edit: My current line of thinking is to use a central Subversion Repository, to define the overall structure, but to allow the use of hg as a client so developers can have repos available locally.


title: Tell a user whether they have already viewed an item in a list. How?

text: It is pretty common for a web application to display a list of items and for each item in the list to indicate to the current user whether they have already viewed the associated item. An approach that I have taken in the past is to store HasViewed objects that contain the Id of a viewed item/object and the Id of the User who has viewed that item/object. When it comes time to display a list of items this requires querying the database for the items, and separately querying the database for the HasViewed objects, and then combining the results of these queries into a set of objects constructed solely for the purpose of displaying them in the view. Each e.g li then uses the e.g. has_viewed property of the objects constructed above. I think it is time to find a better approach and would like to know what approaches you would recommend.


title: Coping with build order requirements in automated builds

text: I have three Scala packages being built as separate sbt projects in separate repos with a dependency graph like this:                 M---->D       ^     ^       |     |       +--+--+          ^          |          S      S is a service. M is a set of message classes shared between S and another service. D is a DAL used by S and the other service, and some of its model appears in the shared messages. If I make a breaking change to all three, and push them up to my Git repo, a build of S will be kicked off in Jenkins. The build will only be successful if, when S is pushed, M and D have already been pushed. Otherwise, Jenkins will find it doesn't have the right dependent package versions available. Even pushing them simultaneously wouldn't be enough -- the dependencies would have to be built and published before the dependent job was even started. Making the jobs dependent in Jenkins isn't enough, because that would just cause the previous version to be built, resulting in an artifact that doesn't have the needed version. Is there a way to set things up so that I don't have to remember to push things in the right order? The only way I can see it working is if there was a way that a build could go into a pending state if its dependencies weren't available yet. I feel like there's a simple solution I'm missing. Surely people deal with this a lot?


title: Benefits to using fragments in Android projects

text: I am learning Android programming and right now and i'm reading about fragments. I understand what fragments are, but either the tutorial is missing some steps or i'm missing something. So my question is when developing an Android UI, what are the benefits, if any, to using fragments as apposed to single page layouts? Are fragments more common than single page layouts or is it more based on the situation. Also, if fragments are more common, do you try to structure most situations so that fragments work?


title: What do you call parentheses operators?

text: In most programming languages documentation where they talk about operators `+-*/=<>` they also include `()[]` as operators. There are _unary_ operators, _multiplicative_ operators, _additive_ operators, _bit shifting_ operators, etc. etc. I can find no terminology that separates _parentheses_ operators from the rest of them. Calling them just _parentheses_ operators doesn't seem right, because they can be used in very different contexts. Specify casts, or type conversions.                a = (int)x;      Invoke methods.                fooMethod();      Define order or operations.                x = (2+4)*8;      In the above examples. What is the correct terminology for each type of parentheses. I require this for documentation purposes.


title: How to document a project which is already developed?

text: I would like to know what options are available for documenting a project which has already been developed, as the developers who worked on didn't write even a single page of documentation. The project has no other details other than many pages of scripts with functions written and modified by developers who worked on this project from the past 2 years. All I have is the database schema and project files. I would like to know if there is any way to organize this project and document it so that it could be helpful for the developers who will be working on this project in the future. The project was developed with PHP and MySQL. The functions are poorly commented so I can't get good results when I run it with doxygen.


title: is there an order for resource bundle loading / searching sequence in java

text: just for a trial, I generate two ResourceBundle, one is a property file MyResourceBundle.properties and the other one is MyResourceBundle.java in the same directory.When I tried to get a key with this code,                   ResourceBundle bundle = ResourceBundle.getBundle("ResourceBundle",currLocale);         System.out.println(bundle.getObject("name"));      The value is brought from the MyResourceBundle.java file. How java decides to get values from in such a situation where all conditions are same ?


title: How necessary is it to follow defensive programming practices for code that will never be made publicly available?

text: I'm writing a Java implementation of a card game, so I created a special type of Collection I'm calling a Zone. All modification methods of Java's Collection are unsupported, but there's a method in the Zone API, `move(Zone, Card)`, which moves a Card from the given Zone to itself (accomplished by package-private techniques). This way, I can ensure that no cards are taken out of a zone and simply vanish; they can only be moved to another zone. My question is, how necessary is this kind of defensive coding? It's "correct," and it feels like the right practice, but it's not like the Zone API is ever going to be part of some public library. It's just for me, so it's kind of like I'm protecting my code from myself when I could probably be more efficient by just using standard Collections. How far should I take this Zone idea? Can anyone give me some advice on how much I should think about preserving the contracts in classes I write, especially for ones that aren't really going to be publicly available?


title: Programming languages and variety

text: So the issue I have as an undergraduate Software Engineering student, is the topic on which languages must one carry under their belt for future markets. I've been having this debate with teachers and students alike on which language takes the stand. The other debate I've been having is: what does it mean to be "knowledgeable" or "proficient" when it comes to a specific language? More specific:   1. Is it how well you can organize and structure and construct your code, based on the language's syntax, structure etc, but little knowledge about what's under the hood, e.g libraries ?   2. Is it how much experience you've had working with language: graphics, animation, complex projects, vast knowledge of libraries etc. Although this may seem trivial, if a person has never coded in a specific field, such as graphics, does that make him less worthy of a candidate for a job? Does it make the person less "knowledgeable", if you will, in that language? In other words, if you've been working with C# for most of your career, and suddenly are faced with a Java-based project, given that you fall under category 1 (above), would you be worthy to be part of this project? The reason I'm asking this, is because I'm trying to figure what to learn and to what extent. Learning to do animations won't do you any good if you're future career is going to be doing everything BUT that. Or are things in the real world not measured in that way? If I don't make sense, I do apologize as I'm trying to make sense of it myself!


title: What is the difference between method header and method signature?

text: I want to know what is exactly a method header and what is a method signature and is this the same among programming languages or just in C#? So, is it correct to say the following is a method header:               public void SumNumbers(int firstNumber, int secondNumber)      and the following is the method signature:               public void SumNumbers(int, int)      ?


title: Should cookies be used in a RESTful API?

text: I'm specifically interested in how users perform authorized / authenticated operations on a web API. **Are authentication cookies compatible with the REST philosophy, and why?**


title: How faster could a dedicated chip do sequential squaring modulo operations to break a time crypto capsule?

text: I'm facing a very real problem and, sadly, I cannot find the answer on my own: I'm hitting my limit as a programmer because my hardware knowledge is not sufficiently advanced at all. It's an issue I'm encountering during the development of the system (I need to find safe parameters value which depends on the answer to the question I'm asking here) (maybe _crypto.SE_ would be better but _crypto.SE_ seems more about theoretical questions about math/cryptography). For a project I'm working on I need to use a "time capsule cryptosystem". More specifically the following one, invented by Rivest (the 'R' in 'RSA'): Rivest's time capsule crypto puzzle It is an inherently sequential operation: parallelization here is of no use. An attacker could use a botnet of million computers: it wouldn't help. One million ASIC chips wouldn't help either. The solution can only be found sequentially, _by design_. Now I need to approximate (one or two orders of magnitude off is ok: an approximation 10x faster/slower or even 100x faster/slower ain't really an issue) how much faster could a dedicated chip solve that puzzle compared to a fast CPU (a fast _core_ , really). Basically solving that puzzle consists in doing a _lot_ of squarings modulo _n_. Let's consider there's no "attack" on that puzzle: I've chosen bit enough RSA integers etc. Would a GPU help compared to a CPU here? A FPGA? Would a dedicated chip like some ASIC chip help? If any of these would help, how can I determine how much faster it could be than a fast CPU? I'd need some back-of-the-envelope calculation and, as I stated previously, an approximation about 10x or 100x the actual answer ain't that a big problem. I guess my question boils down to something like (but feel free to rewrite if I'm mistaken): knowing that the problem is inherently sequential and consists in repeated squaring modulo `n` operation, can you build/program some hardware to only do sequential squaring modulo operations and how much faster would it be than an actual CPU?


title: Best practices for coding date sensitive websites

text: I'm creating a website for an event that is coming up. It has some functionality related to the event (such as "send me a reminder"), other stuff that takes place during the event, and finally some stuff that comes after the event. I need to start working on code that takes place during the event and after the event, plus some fixes for the current site (which is already live). What is the best way to approach this problem? Some solutions that occur to me are creating branches for each state and merging stuff as needed. Other one is hiding and showing functionality based on the date, i.e               if (currentDate < eventDay) { reminder.show(); }      Ideas?


title: Retexturing a model via API on the web

text: I'm looking at creating a site where a user could see our product and configure the options or look of it and see an image that represents that. The way I'm doing it now is if you have Piece A selected and then you choose Texture X, I have an image on the filesystem that is A with X applied to it. I just swap out my default image with that specific one. One product has 8 areas, with 10-70 pieces per area, and about 200 textures for each piece. Programming the site was pretty simple but we are getting bogged down in rendering all these pieces/textures and entering them into the system. What I would love to do is build a model and have some way to apply the textures via API and render it to the browser. I would even settle for exporting a flat image and pulling that into the browser. Is that possible with something like SolidWorks, 3DSMax, or something else? If the rendering is too time intensive it would still help to batch create all my images and use them the way I am currently.


title: Do you use to third party companies to review your company's code?

text: I am looking to get the following - Basic code review to make sure they follow the guidelines imposed. Security code analysis to make sure there are no loopholes. No performance bottlenecks by doing a load test etc. We have lot of code coming in from third parties and is becoming laborious to manage code reviews and hence looking to see if others employ such practices. I understand that it may be a concern for some and would raise the question "Well, who is going to make sure the agency is doing their job right?" But basically I am just looking for a third party who can hold all vendor code to the same standards.


title: Is JQuery or Javascript capable for image processing?

text: My plan is to develop a web based application in the future. I think I can name it "Booth Reservation System" for the Events companies here in our country. One of the main functionality of the system and the most tricky part/difficult part is that the user can upload a "floor plan" (the design of the area were the booth is located in any image format) and then select the specific location on the floor plan to reserve to the booth. Also, the user can create a floor plan on the system. What do you think? What programming language can I use?


title: What can I do with Ruby beside RoR?

text: Beside RoR, what do people use Ruby for? Is there any use for Ruby on Windows platform? If you use ruby for scripting why not use Bash or Powershell?


title: Asp.net certification

text: I want to get my certification in .NET, which certification is the best for me? For the past 8 months I have been working in the .NET 3.5 and 4.0 frameworks. How can I grow myself by appearing this exams? I know that "certs != experience", but I still want to get certified. Right now I am working in PHP 5.3 and PostgreSQL but I want to switch directions because .NET pays a good salary package as compared to PHP.


title: What training book should I choose after Microsoft's Application Development Foundation (70-536)?

text: I've just finished 70-536 ("Microsoft .NET Framework - Application Development Foundation") Microsoft training book from Microsoft Press. I found it quite good. I have also done the 70-528 ("Microsoft .NET Framework 2.0 - Web-based Client Development") book. What book should I be reading next? I am job hunting, so I want to be marketable for a position as a software developer. What will make me stand out from the crowd and get the job?


title: Does Agile (scrum) require one server environment?

text: Is it necessary/recommend/best practice/any other positive to use only one server environment to perform all development, unit testing and QA? If so, is it then wise/part of Agile to then have only one staging environment before Live? Considering that this could mean internationally distributed teams of developers and testers in different time zones is this wise? * * * This is something being implemented by our QA manager. The opinion put forward is that doing all the dev and testing on a single server is "Agile." The staging environment would be a second environment, and then live.


title: Learning the domain-specific knowledge or dig deeper into fundamentals?

text: ## **Context** I've graduated from college a couple of months ago and now I'm working as a software engineer for a company that builds software products. I consider myself lucky that I don't have to work on one of those line-of-business applications. The product we're working on is an authentication solution for - I would say - mass market. I understand that no product could be built without a deep understanding of it's domain. Either it was an industry it's addressing, or a particular set of protocols/use cases/scenarios. In case of a solution like ours, The domain knowledge is a deep understanding of the authentication protocols used by our potential clients, the scale at which it's used, the usage scenarios and other solutions it's going to interact with. ## **The Question** Now as being a relatively new to the industry, what would be your suggestion towards my education? Do you think it's more important to dig deeper into the domain I'm currently working on and dedicate my time to read books, blogs, experiment more in my free time about the set of protocols, standards and tools for building authentication solutions? Or maybe a better idea would be to dedicate my time to get a better understanding of computer science fundamentals that I wasn't taught in detail at the university, like for example:   * The language (C#/C++/Java/anything's) object model, understanding how really my source code is translated to assembly, what is augmented by the compiler, how can I expect thigs to be really laid out in memory (considering all the optimization, tricks, etc.. done by the compiler and/or run-time).   * Advanced multi-threading techniques, knowledge beyond the basics like shared r/w locks, task/data decomposition or basic atomicy/lockfreeness.   * Memory Layouts, Memory models, exact implementations of TEBs.   * Advanced algorithms for massive datasets, how to deal with enormous amounts of data, failure tolerance, etc.. I believe that the second category will make me a better engineer and will help me with designing any sort of product in the future by equipping me with the awareness of their existence - but again - the domain knowledge in the scope of my product is also very valuable and important. I would be thankful for sharing your thoughts on this matter


title: Aren't structured programming and object oriented programming complementary?

text: It seems there is a lot of discussion on the web about the differences between these two paradigms, and how OOP is somewhat better than structured programming. But aren't they complementary? From my point of view one could organize his application following OOP principles and implement its logic using structured programming, couldn't he?


title: Path forward into making Python web applications

text: I currently know a working knowledge of Python and some related libraries (including the included-with-Python SQLite) for the purpose of making **desktop** applications. I would now like to start to make **"web applications"**. By this, I mean that whatever is on the desktop application will be done by visiting a website...so the web page will have all the same sorts of widgets found in desktop apps (buttons, pulldowns, textboxes, etc). I am **not** interested in making just static web sites or online magazines or things like that. All I know about anything web-related is the basics of HTML and CSS. I also get the sense that I will have to learn Javascript and find a Javascript widget toolkit for the widgets. **I'm unclear on what else I will need.** I've heard a lot of good things about the Django web framework, but I'm not sure what the role of a "web framework" is in the mix here (and I got the sense that Django was used mostly to build things like online magazines, not web applications), though I get the sense I will need one to handle the basics of routing information through the web. I'm also open to the idea of using a different programming language than Python, though I like it and would prefer to keep using it. _I'd like to start simple and make small toy apps just to get the basic ideas, and then build from there._ **EDIT FOR SPECIFIC QUESTION: What are the minimum tools/services will I need to get/learn to produce web apps (as defined above) using Python?** **EDIT 2:** I'm removing references to SaaS. Let's just call it a widget-using web app.


title: Are there cases where it is a good idea to disallow remote access to a database?

text: My coworker is working on a project and decided to have the database subside entirely on the glassfish server with glassfish being the only thing that can directly access the database. He will then create web services and a library in Java to access this data. To me that sounds like a horrible way to structure the architecture of one of the most important databases in the company (contains all the employee data). I've mentioned to him that it is a bad idea because it isn't possible to easily get data out currently, to which he said he would write a java library to wrap the REST web service. The problem is that I deal with .NET and I told him that. The web service doesn't work and there is no documentation and currently I have to export data from the database to Excel using PhpMyAdmin and then read it from there since it would take a long time for me to properly format the SQL to work with MS SQL Server. My question is this: does my coworker have a decent design and I'm just suffering because it is in its infancy or am I correct and this design is awful. If it is an awful design, what are points I can bring up to help him see that it may be better to have a more open database?


title: What is the difference between a Master's in Computer Science and a Master's in Software Engineering?

text: I am a college student and I am majoring in Computer Science and Applied Mathematics. As I get closer to my senior year, I have noticed that continuing my studies is the best choice right for me now. I see that several universities offer an Computer Science Master's Degree and a Software Engineering Master's degree. What are their pros and cons?


title: Code bases for desktop and mobile versions of the same app

text: I have written a small Java Swing desktop application. It seems like a natural step to port it to Android since I am interested in learning how to program for that platform. I believe that I can reuse some of my existing code base. (Of course, exactly how much reuse I can get out of it will only be determined as I start coding the Android app.) Currently I am hosting my Java Swing app on Sourceforge.net and use Git for version control. As I start creating the Android app, I am considering two options:   1. Add the Android code to my existing repository, creating separate directories and Java packages for the Android-specific code and resources.   2. Create a new Sourceforge project (or even host a new one) and creating a new Git repository. a. With a new repository, I can simply add the files from my original project that I will reuse. (I don't particularly like this option as it will be difficult to modify both copies of the same file in both repositories.) b. Or I can branch the original repository. This adds the difficulty of merging changes of shared source files. Mostly I am trying to decide between choices 1. and 2b. If I'm going to branch the existing repository, what advantages are there to hosting it as a separate SF project (or even using another OSS hosting service) as opposed to keeping all my source code in the current SF project?


title: Forking an open source project using Git

text: There is an open source project that I want to fork for my own reasons. It currently has a Git mirror of its main SVN repository which I can use. What are the best techniques for forking a project whilst still maintaining the ability to merge future changes from the original project into your own forked repository using Git? Please note I will not be using Github at all for development so using any features from that is out of the question. The project will be hosted on a private VPS.


title: Is Unix/Linux adoption a measure of developer skill?

text: Is Linux/Unix based OS adoption for development (or recreation) a rough measure of the awareness, adaptability and/or skill of a developer, after considering factors like learning curve for effective code testing via the CLI, basic scripting, tweaking, etc.


title: How to structure an application that combines WCF and WPF

text: I'm in the process of learning how to use WCF (Windows Communication Foundation) to allow a client/server desktop application to communicate. The application's UI will be implemented using WPF, and we will probably use SQL Server for our database. What I'm struggling with, is understanding how to structure such an application. From what I've read, there are three components of a WCF application (which in the examples I've seen have existed as separate projects):   * A WCF service   * A WCF service host   * A WCF service client My question then, is - should these projects solely implement the functionality of sending/receiving data from the client/server? Would it make better sense this way? Would it make sense to create a separate WPF (Windows Presentation Foundation) project to implement the UI for the application? And so, when I need to send/receive data from the client/server, I could simply invoke the operations provided in the WCF projects that I have created? For anyone who has built similar applications previously, perhaps you could explain what worked best for you in terms of structuring your application? For example, if I create a user registration page. When the user clicks the 'Register' button, the client application will need to send the data to the server. In this case, could I just invoke the methods provided in the WCF projects to send the data? Also, what data structures worked best for you when sending/receiving data? My initial thought is sending/receiving XML containing the data. Is this an option that is easy to implement? I realise that answers to this question may well be a matter of opinion - unless there are specific best practices that I'm not aware of. Thank you


title: Should I be coding this myself?

text: As I've always liked doing things myself, I chose to code in C++ rather than Visual Basic at university because I could see what was going on and how it worked. However, sometimes I feel like I'm wasting my time though, as there are so many 3rd party libraries out there. Here's an example of what I mean. A while ago I created my own collision detection function based on the x,y coordinates of the mouse and the dimensions of the sprite looping through each line checking for visibility of pixels. About a fortnight later I found out that there is already an identical function built into DirectX. Doing it your self helps you understand how it does it but you cant possibly understand everything about programming, there's to much and it keeps changing. Being young and relatively new to the commercial world I was wondering what experienced professionals opinion was on when to code something yourself and when to just used what's out there?


title: What markup languages are good for programming articles/tutorials?

text: I very much wish to write a programming tutorial in my native language (Latvian). There are far too few of those. I am however unsure on what markup language to use for writing it. Here are a few things I would like to achieve:   * The same source can be compiled to both HTML for online viewing and printed form (PDF?). In HTML form it would allow superior interaction and appearance (see below), while the print form would look good on paper (layout etc).   * I have the idea that the tutorial could be multi-language. Different students have different requirements in their schools. For example, some schools teach Java, some teach C#. You could choose the language on the top of the HTML page and the relevant code snippets (and occasionally pieces of text) would swap out. Most of the text is the same anyway, only the language syntax is a bit different.   * The text would occasionally contain images too of course and these would need to be included in both the HTML and the printed version   * In the HTML version the code snippets should get automatic syntax coloring which should ideally be the same as in the recommended IDE for the tutorial. In case there are ambiguities, hints for the syntax colorer should be possible, but I don't want to do the whole coloring by hand.   * "Output" syntax coloring which would emulate a standard 80x25 text console (since many of the initial programs would be console applicatioins)   * Collapsible sections for answers to questions (aka "spoiler tags")   * Automatically generated index/table-of-contents   * Links to other parts of the tutorial (rendered as links in HTML and as references in print version)   * "Side note" sections, rendered as separate blocks on the side.   * Other functions useful in publications that I'm not aware of :) I know this is a bit much to ask, but is there something close enough that I could take it as a starting point and add the necessary features myself? Or is there something in the whole list (like the desire to have both HTML **and** print versions from the same source) that makes it all fundametally infeasible?


title: Notifying a separate application of an event

text: I have an application that runs through various tasks as an automated process. My client would like me to create a file in a given folder for each task as a way to flag when each task completes. They prefer this to a database flag because they can be notified by the file system rather than continually polling a database table. I can do this but creating and deleting files as flags feels clunky. Is there a more elegant approach to notifying a third-party of an event?


title: how do you manage api keys?

text: I have a few projects that use various webservices e.g. DropBox, AWS. For managing private information I use `bash_profile` which works great with heroku that uses env variables to manages secret informations. The problem is my bash_profile is growing significantly (HEROKU_ADD_ON_1 HEROKU_ADD_ON_2 etc.) and it bit me today. What's the better way?


title: Should a developer be allowed to use VSS if he prefers it?

text: I introduced Mercurial to my department. I love it, but it is my first version control experience. I am using it with NetBeans PHP for web development. Another developer who works on internal company applications likes using Visual Source Safe and does not want to switch. He works in a Visual Studio environment. All the other developers have bought into Mercurial except this one. For the most part though, we all work pretty independently. I am trying to move this department in the right direction, I have set everyone up with an account on Kiln, I was hoping to get everyone using Fogbugz down the road as well (since there is currently no bug database being maintained.) I have never used VSS but I hear very bad things about it. Would it be better to just allow him to continue using VSS if that's what he prefers, or would it be in best interest to get him on board with Mercurial?


title: Decorator not calling the decorated instance - alternative design needed

text: Assume I have a simple interface for translating text (sample code in C#):               public interface ITranslationService     {         string GetTranslation(string key, CultureInfo targetLanguage);         // some other methods...     }      A first simple implementation of this interface already exists and simply goes to the database for every method call. Assuming a UI that is being translated at start up this results in one database call per control. To improve this, I want to add the following behavior: > As soon as a request for one language comes in, fetch _all_ translations > from this language and cache them. All translation requests are served from > the cache. I thought about implementing this new behavior as a decorator, because all other methods of that interface implemented by the decorater would simple delegate to the decorated instance.   However, the implementation of `GetTranslation` wouldn't use `GetTranslation` of the decorated instance _at all_ to get all translations of a certain language. It would fire its own query against the database.   This breaks the decorator pattern, because every functionality provided by the decorated instance is simply skipped. This becomes a real problem if there are other decorators involved. My understanding is that a Decorator should be additive. In this case however, the decorator is _replacing_ the behavior of the decorated instance. I can't really think of a nice solution for this - how would you solve it? Everything is allowed, even a complete re-design of `ITranslationService` itself.


title: How to serialize and deserialize lambda expression in F#?

text: I serialized lambda expressions in C# before. Now I wanna use F# instead of C# for serialization and deserialization. I heard F# is better in this area. Is it true? How can I do that with F#? I’d appreciate even if you just suggested a correlated link.


title: Big-O of this algorithm?

text: 1. How can I describe the growth function in terms of n for the following algorithm?   2. What is the bounding function (the Big-O)? Is it O(n^3)? * * *               for(i = 0 to n - 1)     {         c = i + 1         for(j = c to n)         {             arr[j] += arr[i];                  for(k = c to 0 step -1) // what does the keyword "step" mean?             {                 arr[k] *= arr[j];             }         }     }


title: Are there any resources on how to identify problems that could best be solved with templates?

text: I decided to improve my knowledge in template meta-programming. I know the syntax and rules and been playing with counteless examples from online resources. I understand how powerful templates can be and how much compile time optimization they can provide but I still cant "think in templates", I can't seem to know by myself if a certain problem could be best solved with templates and if it can, how to adapt that problem to templates. Is there some kind of online resource or book that teaches how to identify problems that could best be solved with templates and how to adapt that problem?


title: Should we compile our website to a single dll, or a dll per page?

text: We're developing a new project that is to be deployed on a large number of client sites. The project contains a web-based GUI as one of it's "access points". Speed of the web interface is a priority for this project, second only to security. In the past, we've always created "web sites" in Visual Studio, which, when published, results in one dll and one aspx file for each page within the system. However, I am aware that you can actually create a "web application" and have it compile everything down to a single dll. To me (based on no real data, just gut feeling), compiling the site as a single dll sounds like it would be better for both security and speed (if only marginally). What are the considerations we should look at, and are there any obvious pitfalls we should be aware of when choosing the method that's right for us?


title: Reporting in Visual Studio 2010 Express

text: I want to download Visual Studio 2010 Express Edition to learn all that is new in it. I find it insufficient as there is no Crystal Reports integration in it. Apart from that I want to learn other enterprise features that are bundled with the Professional Edition. If I download the VS 2010 Professional Edition, it is just limited to 90 days. Is there any other alternative for learners? Also, is there any FREE alternative for reporting in Express Edition.