C/C++ in applications that do not concern performance

C is the best language (or maybe the single language) suitable for operating systems, drivers, embedded systems etc. For more complex domains like computer graphics C++ is a better choice. But these applications have thorough performance requirements and they are only feasible to be built in C/C++. Now the question is, if the performance requirements can be achieved in another language, are there any technical reasons to choose C/C++?


iOS Server: HTTP/Apache Drawbacks?

I'm looking to create a client/server application for iOS devices, where client is the iPhone/iPad and server is hosted either at home (Macbook w/ Apache) or online. I've seen many methods suggested in my googling, but the most common method seems to be HTTP POST and GET requests. I'd like to know if there are any limitations of using HTTP for a client/server-based iOS application before I get too involved with the implementation. Performance is not my first priority, as I'd only be sending small amounts of data at a time. Also, is using Apache HTTP Server a viable solution, or should I use a different tool on the server side? Pardon my inexperience in the area. Thanks in advance. I've also heard of Parse and Amazon EC2, can anyone vouch for either? **EDIT:** To clarify, the server would be a single computer/host for all clients, not one server per client. I'd also like the cheapest (if not free) solution available.


Can I use the database structure of an open source project?

I found a database structure for a CMS system and I want to copy it with the EF that this database is done in, is it OK to copy the database structure of open source software which is under GNU v2 lisence? I don't want the rest of the software only the database structure.


CodePlex and Google Code Concerns

I was wondering about the risks involved with hosting on Microsoft CodePlex and Google Code. Let's say I host a project on one of them and it ends up taking off and getting tons of downloads. I was wondering if it is possible (or maybe has already happened) for either Microsoft or Google to rebrand the project and turn it into closed-source? The reason I ask is because Microsoft and Google are multi-billion dollar companies and your average lawyer would have to be crazy to try and fight them.


Max. SMS length that will reach all users

I'm building a grants management system where we're trying to find a list of lost users using a number of different means. The first attempt is email but if we do not have an email address, we will try SMS. Just wondering, before we get our business guys to start thinking up SMS messages, is there a maximum length or something which I should stay within to reach every phone with SMS capability? Taking also in account that whilst we won't be sending an SMS to international numbers, a lot of the users will be from foreign countries and may have a foreign cell phone. Also, messages will only ever be in English.


An alternative to requiring red in TDD: reverting code change?

According to this answer to this question, a good reason for always starting with a failing test ("Red") is to make sure that the test is working and that the code that will be written is what makes the test passes. (my paraphrase) Since it appears to me that the ability to write a test before any code has been written is a kind of mental acumen that not everyone can do (I can't), would it be sufficient if I write the code first, then write the test, then revert my code change to see that the test will fail without the code change? Suppose that could be automated by some kind of IDE integration - would that be an alternate form of TDD? In development environments in which TDD is enforced by the IDE/Framework, does strict mechanical rule enforcement limits developer's options for optimizations? **An example** in which this might be useful: Suppose the module and its unit tests have already been completed and are both working correctly. Now, I want to introduce a refactoring which would improve the performance by an _unknown_ amount by reducing the number of _internal_ function calls, without any fundamental change in the _external_ behavior of the module. Because I don't know how much benefits I would get from that refactoring, I can't write a test for that. But without a failing test, I'm not allowed to modify the code. This seems a chicken-and-egg problem. If I am allowed to write a dummy test which simply captures the number of internal function calls in the old/new code, and then modify the code (in the name of "refactoring"), now I can update my test (if the refactoring is successful in reducing the number of internal calls) to assert that the number of internal calls should be reduced. **(Afterthought)** Although, this type of performance tests has a lesser importance than requirement unit tests:   * I would like to keep the benefit of the more efficient code if there is no change in functional requirement, and I do not want others to "refactor away" this benefit based on the assumption that no functional requirement would be broken.   * However, if there is a change in functional requirement, and if it's not possible to meet the current performance level, then the functional requirement should be met first. After that, a new performance target would be set from experimentation. (Disclaimer: I have never done strict-TDD (and am skeptical of it), although I have been doing test-soon-after-coding for several months.) **More afterthoughts**   * The code change in this question appear to be "post-TDD development", since it occurs well after all functional requirements had been met and all tests were in place. Therefore, as long as all of the original TDD unit tests continue to pass, this type of code change is considered "tuning".


Programming language constructs for cache optimization?

Clearly optimizing cache usages is bound to improve my program efficiency. Surprisingly, I don't see too many programming languages actually having this sort of a feature. So here's my question:   1. What kind of language constructs have you seen that help improving cache usage?   2. How to innovate on cache usage since most systems won't easily reveal stuff like their L1 cache size easily? (Windows does have API or maybe /proc/cpuinfo on Linux, but I am looking for something simpler for the intermediate developer)


Randomly Generate Points in a Spiral Motion using Javascript

So I have a javascript program that currently gets random points, it generates a random x,y,z value around the center point, within the radius `r`                 var maxArms = 3;       var i = 0;         var color = [];       for(var arm = 0; arm <= maxArms; arm++) {         var perArm = (numStars/maxArms);         var perPoint = Math.ceil((r/10)/5);         var actualPoints = ((r/10)/5);         perPoint = (perArm/(actualPoints+(actualPoints/4)));         var angle = 8;              for (var ra = 0; ra < 412; ra += 2) {             for (var p = 0; p < (580-ra); p++) {             var an = Math.random() * Math.PI * 2;             var pX = x(ra,angle) + ((Math.cos(an) * (Math.random()*512)) * (Math.random() > .5 ? 1 : -1)),                      pY = y(ra,angle) + ((Math.cos(an) * (Math.random()*512)) * (Math.random() > .5 ? 1 : -1)),                 pZ = Math.random() * ((r/2)-p) * (1 / ra) * (Math.random() > .5 ? 1 : -1),                     particle = new THREE.Vertex(                         new THREE.Vector3(pX, pZ, pY)                     );                 innerRing.vertices.push(particle);                      var h = Math.random() * (291 - 185) + 185,                     s = Math.random() * (66 - 34) + 34,                     v = Math.random() * (100 - 72) + 72;                 color[i] = new THREE.Color(0xffffff);                 color[i].setHSV(h / 360, s / 100, v / 100);                  i++;             }         }       }      Now I am trying to find a way rather than just randomly placing things anywhere within the radius, to spiral out the points, into a defined number of "Spiral Arms", I am sure this is going to require something with Sine and Cosine, but I have spent hours now looking to understand how to use these functions to do what I need and I am not sure how to do it. What I am looking for is I want a variable for the number of arms `numArms` and I want to have the function above take the number of arms, and create an equal number of points in each arm, and each arm arc out from the center point `0,0` in a spiral motion. Does that make sense? I have found other questions, and different answers with google about how to make a spiral, as well as how to find random points (as shown above) but nothing that can help me find random points around spiral arms, but once I have the points for the spiral I am not sure how to get the random x,y,z coordinates around the spiral. Also, if it is possible, to make it so towards the beginning of each arm there are more points than at the end of the arm. Yes I know my script is not properly optimized, but I am looking more for function at the moment. I have attached an image of what the currently generated with the code below, as well as a sample of a spiral galaxy, althought I do not want the center as huge as the second image. * * * **Edit** I have made some changes to the generation script, although rather sloppy, it starts out making stars come from the middle like a spiral, but it inevitably gets larger and no longer looks like a spiral, I have tried playing with all of the variables (`ra` and `angle`) but it does not make the spiral look any better, what can I do? Current Generation: http://i.stack.imgur.com/sfkh3.jpg Sample Generation: http://i.stack.imgur.com/RikVh.jpg


What is the name of this tree?

It has a single root and each node has 0..N ordered sub-nodes . The keys represent a distinct set of paths. Two trees can only be merged if they share a common root. It needs to support, at minimum: insert, merge, enumerate paths. For this tree:               The      +--------+----------------+      |        |                |     cat      cow              dog      +        +--------+       +      |        |        |       |     drinks   jumps    moos    barks      +      |     milk      the paths would be:   * The cat drinks milk   * The cow jumps   * The cow moos   * The dog barks It's a bit like a trie. What is it?


Criteria for a language to be considered "object oriented"

I had a discussion about OO programming today and by browsing the internet I found a lot of different specifications for object oriented languages.   * What are the requirements for a language to be object oriented? For myself an object oriented language must have classes, inheritance and encapsulation.   * Is C an object oriented language just because you can use structs and program with an object oriented design? Why/ why not? Are there any good sites/articles about this? And please, no Wikipedia links because I've already been there.


Object locking over Internet

I am building a tutoring application that can be used to draw objects and then one is able to drag them around. I would like to know what is the best thing to do when someone clicks on an object and starts to drag it. I was told I should "lock" it - prevent it from being grabbed by someone else at the same time and being able to drag it. But that would require sending a request to the server (and then to all other users connected to the tutoring session) to lock it which might take a bit of time (what if a teacher is in USA and student is in Africa on dialup)? I was also told I should loop until I see that the object was locked by me. This way, the user might not be able to grab and drag and object for several seconds (UX design problem). I proposed perhaps to only enable one to drag object you drew, but that seems short sided. Any suggestions? Thank you!


If I open a port and add an exception to the Windows firewall, should I ask the user first?

I have an application running with admin rights, which in order to work, need add a port and register himself to the exceptions list of the Windows Firewall. the question is, is considered a bad practice do this without inform to the final user? or must be done asking to the final user about this ? Thanks in advance.


Pros and cons of JIT and AOT

In which respects "Just In Time" compilation is better than "Ahead Of Time" compilation? And vice versa. Is AOT same as direct native compilation?


Scrum Newbie: Internal Stories

I am trying to implement Scrum and have some basic questions. I understand creating stories to implement end user functionality, but where does a "meta- task" like collecting requirements for the stories in the first place come from? Is this even before the story process begins? I guess I am struggling with the fact that a project starts up at some point, and then tasks like "get requirements" and "create user stories" are needed, but those are also part of the project and need to be captured somewhere. Do they fit into Scrum stories? Are they part of a sprint? It seems like they should be, but creating stories for them seems recursive...I hope that makes sense. Thanks!


Create a subclass of model for class-based viewmodel creation

Is it justified to create a model subclass just for creation of appropriate viewmodel based on this class. Am I missing something? How to pass data about model into viewmodel?


Any ASN.1 parsers written completely in managed code & safe from buffer overflows

ASN.1 is a data format used on HTTPS certificates, and various other critical pieces of infrastructure. I need to analyze some potentially hostile ASN.1 data, and want to ensure my code is safe from any programmer error. I think the best way to do this is to use a managed language that does not use unsafe code. Are there any managed implementations (C#) of an ASN.1 parser that is well tested and safe from buffer overflows. Even better if there was a way to detect such an overflow to begin with.


Is it an anti-pattern to use void* and enums to enable type-checking?

Say in a game engine, you have `Object`s that composited of different components. One of these is a `RenderComponent` which can be either a `Mesh`, a `Sprite` or a `Light`. Now, all these are vastly different classes with non-complatible interfaces, so deriving them all from `RenderComponent` makes little sense. Also, an `Object` can only have one `RenderComponent` at a time, so you saving three pointers in `Object`, two of which must always be `nullptr`, seems wasteful. So what I came up with is using `RenderComponent` to store a `void*` pointer and the type.               class RenderComponent{     public:         enum class RenderType{             Mesh, Sprite, Light         };              RenderType getType(){ return type_; }              Mesh* asMesh(){              if(type_ == RenderType::Mesh)                 return static_cast<Mesh*>(pointer_.get())              else                 return nullptr;          } /* the same stuff for Sprite and Light */              RenderComponent(unique_ptr<Mesh>&& pointer) :             pointer_(std::move(pointer)),             type_(RenderType::Mesh)         {} /* the same stuff for Sprite and Light */          private:         unique_ptr<void> pointer_;         RenderType type_;     }      It should work as intended, but I feel like this is an anti-pattern. I'm basically discarding all typesafe aspects of C++ and then reimplement them myself. This can't be right. So, is this an anti-pattern? What are common workarounds for this problem? Am I missing something obvious? Or is this a known, but (for good reason) only rarely used pattern?


Using Twitter share and Facebook share

Hi I m trying to use **Social Plugins** in my website For a Tweet on Twitter   `<a id="twitter-link" href="https://twitter.com/share" class="twitter-share- button" data-lang="en" data-size="large">Tweet</a>` I have included the above line my url is something like this   localhost:3000/#a=abc `to give it a faster response i used a location.hash instead of changing params so to avoid reloading the webpage` so when any user clicks on any image the url changes to localhost:3000/#a=def but the twitter share button tries to shares the url `localhost:3000/#a=abc` How can i solve this?   Thanks in advance!!


Async function iterated calls

I'm new to using async calls in ajax. My problem is that I have two server "tasks": one that just checks if session is set (fast), and another that sets the session (slower). I want to check if the session is set and if not, set it. And I want to try X number of times (I'm unsure if I really need to but that, but that is another question). If I just do it with a “while” or a “for” and not do think about that it is async, I will generate problems like to many calls, and it will not be check session then set session. I could to it on the server, but I do not want to send the request data if session is set, only if it is not set. Below is the way I'm trying to do it now, but I'm unsure if there is a better way of doing it? The code below just implements the idea and is not tested. The idea is that send the counter back and forth between checking and sending session in the success function. What I do not like about the code is that the set session really is just understandable in context of checkSession. If I in some time come back to the code and just want to setSession, I would have a magic number of X to make sure it does not check the session also. Is there a smoother way of doing this? If the code smells even worse, please tell me.               self.start = function() {         self.checkSession(0);     };     self.checkSession = function(count) {         server.CheckSession(function(returnValue){             if(returnValue == false && count < 4){                count++;                self.setSession(count);             }},function(err){});};     self.setSession = function(count) {           var sessionData = someData;           server.SetSession(sessionData, function(d){               self.checkSession(count);     }, function(err){});};


Populate date to jList in netbeans (Java)

I created a jFrame using netbeans, Here is a screenshot on how i want the data to be added in to jList, From A to B. ![enter image description here](http://i.stack.imgur.com/LyTxa.png) Can you show me how i can do it?


Use of Abstract Syntax Notation (ASN.1)

The problem of Electronic Data Interchange over networks is well known and understood. Today, the most common formats for data interchange are things like XML and JSON. There are various pros and cons of using one format over the other, and certain formats lend themselves better to certain data-sets. I've been programming for quite some time now, and I've only just NOW come across the **ASN.1 (Abstact Syntax Notation)** format, which is apparently used in certain Internet protocols such as LDAP, and is actually quite old (in Internet years). I read a bit about the format. Like JSON, it provides primitive data types (boolean, integer, etc.) and also sequence and set types. It's a bit different from JSON or XML in the sense that, while the notation itself is human readable, the encoding is usually not human readable (it is usually encoded in a binary format.) Is there some reason why this format is so rarely used? (Or am I totally wrong, and it is actually used often?) I've only just now heard of it for the first time, and I've never heard it come up in any of the various discussions I've read about the merits of JSON, YAML, XML or whatever interchange format. Is there some major drawback to ASN.1 that prevented it from being more widely used?


Brainstorming questions to elicit features in new software version?

Because of a change in technologies, we are doing a major version change in our in-house enterprise software. I am going to be doing the usual of interviews, observations and brainstorming sessions. What general (and fun!) questions do you recommend/use in a first pass to elicit the discovery or remembrance of new functionality or changes to existing functionality? (Too much literature on requirements gathering tells you the easy part: how to get details on functionality. Nobody seems to have much on actually eliciting the function at first!) Examples:   1. You have a magic wand. You can wave it and change one thing about General Software v1.0. What would you change, how and why?   2. Have you used any software where you wished something in it was also in General Software v2.0?   3. What functionality is too complicated in General Software v1.0?


Model-View-Controller and client-side concurrency responsibility

In a web application that has a significant ajax component, where is the best place for the client-side concurrency responsibility to lie? We're trying to use MVC on both the server application (LAMP stack) and the client application (ajax, mostly jQuery and unobtrusive js). On the server-side, our model throws an exception if it finds a concurrency conflict that it can't solve on it's own. Essentially, the model tracks a revision number and date/user of creation and update. If the object being saved is out of date (older revision than in the data store), it attempts a merge. If it fails, the controller handles the exception and initiates some kind of resolution workflow. The issue is with the client application; since ajax runs requests asynchronously, the model doesn't necessarily have the latest version of the data, but only the controller would know that--it is responsible for handling the queue/polling. The original idea was to pass all the updates fetched from the server directly to the javascript models for handling the concurrency-- problem being that the lack of exceptions in javascript limits us to making flow-control decisions in the model that way. Is it a bad idea to move the merging/model-conflict-resolution into the javascript controller? Is there a better way to handle this without the controller getting to far into model land? Flow of the page:   1. User loads page(ajax application) with initial models--the models are numerous and have many attributes.   2. Page polls server for updates every 10-15 seconds--this is for auto-save and getting updates from other users.   3. User edits models.   4. Any conflicts that arise after initial entry are resolved when the user clicks the "save" button at the bottom of the page.


Bare minimum on the Joel Test

From the Joel Test, of the 12, which do you think are the absolute must-haves to at least have a decently running software department/company? I realise there is no absolutely right answer. I'm just trying to get opinions of others out there. My own organization only manages a measly 5 of 12. If you check listings on Careers 2.0, most companies don't score a full 12 either but I'm sure they're doing fine. Does SO publish the stats for those anywhere? Or has anyone tried scrapping the results? Would be interesting to know which are practised the most. And whether because they are easier to implement or whether they actually have the most impact. Thanks. EDIT: These are the ones practised by my company and for the given reasons   1. Having source control. - Have to agree with one of the answers that that is the one I would not negotiate about.   2. Fix bugs before writing new code. - Matter of principle but not a must-have.   3. Have a spec. - In a small software house with tight margins, specs save life. But I could see it done away with in other companies without affect.   4. Candidates write code during an interview. - Saved us hiring the wrong candidate many many times over. This is the other non-negotiable must-have for me.    5. Hallway usability testing. - Easy for us. Our whole office is a hallway. It's really easy to grab people anytime. But that also means we don't have a quiet working environment for developers.


Should I make a variable readonly when I modify it, but I don't actually set it outside of the constructor?

## Background: I was writing some code. It looked something like this:               class X     {         private List<int> _myList = new List<int>();         public void MyMethod(int x)         {             _myList.Add(x);         }     }      R# suggested that I make `_myList` readonly. I wasn't so sure, as though I technically could make it readonly, I think it would be slightly confusing to do so, as I'm still modifying the list, just not reassigning it. So while I could make it readonly, I'm not sure if I should. ## Question: Should I make variables like this readonly? **Why?** If not, why does R# suggest this?


Designing Algorithm Flowchart Application

I need to develop an GUI application in C# where users can freely add conditional/statement blocks on the algorithm flowchart like the one shown below. By freely, I mean users can add a block on wherever the arrows are. I'm having some problems brainstorming how to approach this problem, especially what to choose for my datastructure to store the blocks. I was thinking LinkedList since everything follows a linear fashion and every node always has a head and tail, but the If/Else block (b>a) has two branches (heads) to store, so this complicates things a little bit. How would a smart one approach problems like this? My apologies if this question isn't suited for Programmers stackexchange, but this is more of a conceptual problem rather than implementation problem so I figured this place was appropriate for the question. ![enter image description here](http://i.stack.imgur.com/FSS4W.png)


Shortest Common Superstring: find shortest string that contains all given string fragments

Given some string fragments, I would like to find the shortest possible single string ("output string") that contains all the fragments. Fragments can overlap each other in the output string. Example: For the string fragments:               BCDA     AGF     ABC      The following output string contains all fragments, and was made by naive appending:               BCDAAGFABC      However this output string is better (shorter), as it employs overlaps:               ABCDAGF     ^     ABC      ^      BCDA         ^          AGF      I'm looking for algorithms for this problem. It's not absolutely important to find the strictly shortest output string, but the shorter the better. I'm looking for an algorithm better than the obvious naive one that would try appending all permutations of the input fragments and removing overlaps (which would appear to be NP-Complete). I've started work on a solution and it's proving quite interesting; I'd like to see what other people might come up with. I'll add my work-in-progress to this question in a while.


ASP.NET MVC - Dynamic Views with many similar controls

I have a main View which has several sections and a main dropdown at the top which defines how the rest of the view looks like. All these sections have some data that is visible all the time, and some that need to be hidden when certain values are chosen in the main dropdown. As of now, I have partial views for each section, and I am having lots of if/else statements in my view to show/hide the specifics, which is getting clumsier by the day.


Documenting higher-level concepts

I will be leaving my current project in a few days, and as part of securing my knowledge I have been asked to add comments to the code wherever I feel that can add value. The problem I am running into now is that the comments I want to write are not really suitable as comments, because they do not pertain to a single entity in the code (a few lines, a function, a class or even a file), but they are more about how two or more entities interact with each other or about a feature whose implementation is spread over multiple entities. So, how do you go about documenting the stuff that does not belong to a single entity but is important to know to understand the bigger picture? And also: Where do you document it? In the source file or in an external document? As an example, we have a client-server architecture in C (with the client and server both running on the same embedded device). To avoid flooding the server, the client has a mechanism to throttle the sending of similar requests to the server such that a request can only be sent if the previous one has been answered. The innards of this mechanism are spread over multiple functions. Where would you place the documentation of such a feature, especially if the file with the functionality also has some other, unrelated, functions? **Edit** : Extended the question a bit.


Web Service REST clarification

I'm new to web-service programming, and I'm unsure of a few things. I know that REST web-services can be used to interact with the system like this:   * to retrieve a user: GET /user?id=1   * to retrieve all users: GET /user   * to insert a user: PUT /user?{all user data} When I need to do an update action for some tables using a JSON object can this be done with a REST API or does it need to be some other interface? If is REST, what is the right method (GET, POST, DELETE, etc) to use? Is it correct to have two type of patterns in the same web-service?


Some Insight on the Field of Knowledge Representations and Reasoning

I started following an MS in computer sciences after about two years of work for a software company. I worked primarily in data warehousing and business intelligence related software development during my previous occupation. There is a high chance for me to select a research in knowledge representations, ontologies and reasoning, as there are no other research available in any other interesting fields, such as pattern recognition and navigation. I developed an interest towards knowledge representation with what I learnt from the courses I am taking currently. But I do not have a deep understanding of it in terms of which areas such a field would have an impact in a real life scenario, and how it will help me when I am hunting for a job in the near future. Some thought about this would be greatly appreciated.


When to do Code Review

We have recently moved to a scrum process and are working on tasks and user stories inside of sprints. We would like to do code reviews frequently to make them less daunting. We are thinking that doing them on a user story level but are unsure how to branch our code to account for this. We are using VS and TFS 2010 and we are a team of 6. We currently branch for features but are working on changing to branching for scrum. We do not currently use shelvesets and don't really want to implement if there are other techniques available. How do you recommend we implement code review per user story?


I'm hoping to start an online supermarket and needs advice on open source shopping cart software and applications

I have been researching on both open source software and off-the-shelf software for an online supermarket project in Africa. I have now narrowed by search to X-cart and the PHP based PrestaShop shopping carts. My plan is to acquire an open source shopping cart either by purchasing or as a free open source cart and hire a local developer to customize it to our local needs. I have been doing the demo for x-cart for three weeks now and had thought it might work best for us but after going through the 600 page manual and I'm concerned with how far it can be localized. Yesterday I was looking at the possible Prestashop free open source cart and I seem to like the back-end. Didn't like the back-end for Magento much but from reviews conducted by third- parties they seem to recommend it. I'm now wondering whether I should have a developer start the whole project from scratch, or use an open source software such us PrestaShop or get x-cart which can then be customized? Note that my store will have thousands of products and services including groceries and so I want something that can handle up to 500,000 products and over. * * * Thanks guys for your thoughts and advice. I have indeed looked at the other shopping carts and from a store managers point of view i like PrestaShop back- end and the fact that more modules can be added. You have raised a red flag for me though about the capacity to host that many products. Whats the point then of marketing the software as 'Unlimited Products' when it really cant. Perhaps someone can refer me to a website that has that many products and is PrestaShop? I agree though it has to be customized. Am just worried about asking someone to start from scratch since i believe open source software have been worked on by many minds and been tested enough something that a scratch project may not have.


Is there any open source code analyzer for java which I can adopt my software metrics algorithm on it?

I am doing my masters dissertation and I have conducted a software metrics. I need to adopt my metrics on an open source tool. I have found PMD and check style on sourceforge.net but there is not adequate explanation about their codes. However, I couldn't to find their source code to customize them. I will be appreciated, if you introduce one open source tool for java which I can customize it's code.


Is this Java Compiler error message incorrect? (byte loss of precision)

The following IMHO valid java program doesn't compile because the Oracle 1.7 javac compiler thinks there's a possible loss of precision in lines 5 and 6. If you uncomment line 3 and comment out line 4, it compiles fine. Would someone explain why the compiler believes there is a loss of precision on the assignment to either byte `b2` or `b3`?               public class BUG {         public static void main( String[] args ) {             //final byte b1 = 9;             byte b1 = 9;             final byte b2 = -b1;    // fine if line 3 is uncommented and line 4 is commented             final byte b3 = 0 - b1; // fine if line 3 is uncommented and line 4 is commented         }     }      If my sample code is correct, then I'd like to report this as a bug but I can't find out where. Would someone explain what the compiler error message is saying in this case and why it's correct?


Liability for software framework

If I ask money for a software product (php famework) instead of offering it for free, does it make me more liable for problems caused by my product?


Recommend resources for development team leaders

I was recently made the team leader of a database (95% MS SQL Server, 5% misc- Oracle, Sybase, Access) development team that manages and develops a large number of databases in a corporate environment. I'm looking for resources (checklists, utilities, best practices, procedures, websites, books, etc) that will help me to implement fundamentals which have been lacking in this development group in the past, such as code reviews, cross training, documentation, enforcing standards, knowledge sharing, mentoring and so forth. Most of what I'm finding is general management skills resources, but I would like to find anything that might be specific to leading a team of developers. Corporate processes are "standard" waterfall type SDLC, so resources geared towards Agile are not nearly as relevant.


Minimizability or readability?

I am authoring a lot of plugins for the content management system that I am writing. I believe it to be of utmost importance that script files (especially if they're plugins) should load quickly, which leads to me to the question that I've asked today? **What's more important for plugins, minimizability or readability?** Let's imagine that we live in an ideal world where code is always perfect. Should a plugin (which being perfect, the author doesn't expect the end user to read) be designed so that it takes up as little space as possible, or so that it readable by the end user. For example, I'm writing a piece of code that spits out HTML and appends it to the body. I have replaced every instance of the tag 'div' with '!' and then used `String[replace](/\!/g, 'div')` to save four characters (therefore bytes?) for each declaration of a div element. _NB,`[replace]` is also a declared variable so that when it is minified it will read something to the effect of `String[r](/\!/g,'div')`_ Am I caring too much about download speed or should care a bit more about readability. (IMO, most minifying techniques are easily reverse-engineered, but is it bad practice?) * * * **Edit** Thanks for all the answers, you guys are great!


What precisely do I/my company need to do "make available/publish" source code changes and satisfy GPL/LGPL

This seems like a basic question, but I have not found a definitive source. I need to modify the source for an LGPL application for my employer to plug a security hole. Longer term we will upgrade to a later version of this application, but for now, this is the quickest solution. (specifically: I will change a 2005-era version fork of Apache Tomcat'--jboss- web 2.0.1--to add allow "httpOnly" and 'secure' JSESSIONID cookie). **The question** What exactly must I/my company do to "make available" or "publish" the source code? Must it be accessible from the company's own website or github repository? Or can I have it on my own private github account and simply have the company link to it? thanks


Encode Optimal Huffman code

I have given message encoded with non-optimal Huffman code. I need to decode the message and encode it again, but this time with optimal Huffman code, so after that I can find `average_number_of_bits_per_symbols = num_of_bits_in_message / num_of_characters_in_message`   **Example:** **_input:_**               6     A 11     B 10     C 01     D 0001     E 001     F 0000     101100000001000010001001100011000000010001010010000000100001000110001100011000000010000000000000100110001000100000000000000011011111010100100101011001010000111001010110000100000010010000000111010000001100100100001010001000100000000001      **_output:_**               2.469      Here is what I got from decoding:               // Third column is occurrence of the letter     A 11 5     B 10 19     C 01 12     D 0001 8     E 001 18     F 0000 19          BAFDFBEEBEBFEDCEFDFBEBEBEBFEFFFCEBEDFFFDBAABBBCECCBCCFABCCCBDFEEFDACFEBCEFBBEDFFE          num_of_characters: 81      So now I have to find optimal codes for these letters. I've tried tree like this one:               19      19     18     12      8     5       B      F      E      C      D     A        \     /       \     /      \     /        0\   /1       0\   /1      0\   /1          \ /           \ /          \ /           \             \            /            \             \          /             \            0\        /1              \             \      /               \             \    /                \             \  /               0 \             \/                  \            /                   \          /                    \        /1                     \______/      And with this I will get:               A 111 => 3 * 5  = 15     D 110 => 3 * 8  = 24     C 101 => 3 * 12 = 36     E 100 => 3 * 18 = 54     F 01  => 2 * 19 = 38     B 00  => 2 * 19 = 38     num_of_bits     = 205          So 205 / 81 = 2.530 => which is not equal with the example output...      So what I am doing wrong?


Is it a bad sign that I am often redesigning as I develop a project?

When I first started programming, I assumed that I would one day get to the point where I would start a project by sitting down and sketching a UML diagram of all the classes, then pretty much stick to that. I have now been programming for a couple years and it is not turning out that way. As I go through a project, I am often saying   * "Hey, I need a class to do ___ _. I didn't think of that before."   * "Wait, this function should really be in that class instead of this one. I'll move it over."   * "This should actually be two classes instead of one. I'll split it up."   * "I should make these three stand-alone classes all inherit from one abstract class."   * Etcetera, etcetera. Is it a bad sign that I am often redesigning like this as I go along? Does this mean I'm a poor programmer or is this normal?


Passing notifications between programs written in different programming languages

I work in a team of people with experience in varied programming languages. Recently we were required to build a report when an order is placed in our system. Our ecommerce store runs on PHP and the program to send the report was written in Java. The major challenge we faced was setting up a way so that the Java process is triggered as soon as the order placed. In the same vein, we have plenty of programs written in Python, Scala etc that need to be coordinated and be aware of when to do a task X when task Y happens. As of now, our go to solutions to this problem is to setup a cron to routinely check whether a file or value in DB exists and THEN run (simple polling). I believe a task queue is a right way to solve this problem. However, I'm not sure how to setup one, and how will the Java process know that a task is waiting for it? Also, would a lot of change be required in my PHP program to put something in task queue? Thanks a lot!


From a high level programming perspective, where does the 'different-paradigm' barrier between C# and F# really kick in?

I'm aware that they both use different programming paradigms, but from a high level perspective apart from differing syntax it seems most basic tasks can be achieved in similar fashion. I only say this because when I've previously touched functional programming languages such as Haskell, writing code for basics tasks was (at first) difficult, frustrating, and required a completely different mindset. For example the following took some time to get to grips with using recursive syntax:               loop :: Int -> IO ()     loop n = if 0 == n then return () else loop (n-1)      Where as an F# loop is recognisable and understandable almost immediately:               let list1 = [ 1; 5; 100; 450; 788 ]     for i in list1 do        printfn "%d" i      When C# programmers start learning F# they are advised to completely re-think their thought pattern (which was definitely required for Haskell), but I've now written several F# programs dealing with conditions, loops, data sets etc to perform practical tasks, and I'm wondering where the 'different-paradigm' barrier really kicks in?


Dev environment different from testing environment

I'm working on a .net web app project where we develop on our personal machines, but our testing and production environments are in a corporate intranet. The problem is I run into bugs that only present in the testing/production environment, but not in dev. I find this makes it really difficult to track down the cause of the problem. Are there any tips/strategies to deal with this issue? **Please note I have no control or options when it comes to setting up new servers or modifying the test environment. I can only make changes to my local machine. I also do not have access to a company image file to image my PC.


More requirements in a single use case - correct?

I have been arguying with a developer who insists that 1 FR=1 UC. I think that is a non sense as there are requirements often describing situations arising from the same point - for this the use cases have alternate flows. For example: FR01 - User can log in FR02 - User's account will be locked after 3 incorrect passwords. FR03 - Logged user can log out I believe all these can be nicely captured within a single use case, describing the interaction between the user and the system. But maybe I am missing something? EDIT: According to the book "Use Case Modeling" from Bittner, Spence: > a use case contains a set of description of requirements, the requirements > are presented in the form of narrative rather than an itemized list... ...   So I would say definitely more requirements can be captured within a single use case.


I found free software project whose executables are spreading a virus. What is the correct couse of action?

Today I found a GPLed project on SourceForge whose executables are spreading a virus. This fact has been pointed out several times in reviews of the project and the infected executable is still available for download. Apparently, older executables are not infected, so the project itself does not seem to be made with malicious purpose in mind. There is no preferred way to contact developers and forums for the project are dead. What should I do?


Why is the cyclomatic complexity equal to two for a simple Hello World?

I would have two questions related to cyclomatic complexity:   1. Can I use this metric for a whole app? I guess I cannot, as it would be incredibly large number, considering functions calling functions etc. Is it just for module/method/unit?   2. In Visual Studio, for starting app with just calling the `Main` method, the cyclomatic complexity value is 2. Why? There is just one possible way if I run the program - it ends.


How to implement loose coupling?

I want to implement loose coupling in a project. I know two examples of successful loose coupling designs:   1. On a Unix workstation, shell scripts realise a loose coupling between basic utilities. The loose coupling relies on the shell's ability to _blindly_ redirect data flows between utilities, without having any knowledge on the structure. Utilities agree on a common form to cooperate like a _pipe-separated format_ for sort, cut, paste, awk, etc., a svn dump or a _trivial dump_ of a normalised SGML document (with onsglmls).   2. On a Mac OS X system, Applescripts can be regarded as a loose coupling. In these two examples, I see that cooperating components agree on a common protocol to serialise and deserialise data that needs to be exchanged. Thus components depend on the serialisation protocol rather than on internal representation of data. Is the implementation of a stable communication protocol between application components a winning strategy to implement loose coupling (and good encapsulation)? To solve ties, I also ask what would be a nice name for the protocol artefacts: “data” is a bit vague and there is a lot of them at various places in a software!


Is there such a thing as a super programmer?

Have you come across a super programmer? What identifies him or her as such, compared to "normal" experienced/great programmers? Also. how do you deal with a person in your team who believes he is a super programmer? Both in case he actually is or if he isn't? **Edit** : Interesting inputs all round, thanks. A few things can be gleaned: A few definitions emerged. Disregarding too localised definitions (that identified the authors or their acquaintance as super programmers), I liked a couple definitions:   1. Thorbjørn's definition: a person who does the equivalent of a good team consistently for a long time.   2. Free Electron, linked from Henry's answer. A very productive person, of exceptional abilities. The explanation is a good read. > A Free Electron can do anything when it comes to code. They can write a > complete application from scratch, learn a language in a weekend, and, most > importantly, they can dive into a tremendous pile of spaghetti code, make > sense of it, and actually getting it working. You can build an entire > businesses around a Free Electron. They’re that good. Contrasting with the last definition, is the point linked to by James about the myth of the genius programmer (video). The same idea is expressed as egoless programming in rwong's comment. They present opposite opinions as whether to optimise for such a unique programmer or for a team. These definitions are definitely different, so I would appreciate it if you have an input as to which is better. Or add your own if you want of course, though it would help to say why it is different from those.


Visual Studio versions and Team Etiquette

I have a project on CodePlex that I have opened to basically anyone to join and help out on. I am mostly an enthusiast coder, although I have done some programming work as part of my job it has always been solo projects that my team uses for IT support. With my CodePlex project, I got my first new fork yesterday. I cloned it to see some of the changes and realized he had upgraded the package to VS 2012 from my 2010. What is team etiquette for Visual Studio in a team environment? I can see the benefit of using the latest and greatest, but forcing the hand of a team to upgrade seems a little off too. My assumption is this developer did not consider it. Is it considered good etiquette to maintain a standard, even if outdated like with VS 2010? Or is the best etiquette to use the latest stable Visual Studio, and those with out an upgrade can use the Express versions of the latest? Or is there a standard way to make a solution IDE agnostic between VS versions? * * * **Edit** A ton of great input. And the verdict seems to be there is no universal or established etiquette. That it really boils down to my own preferences for the project and what affect the change has on the project.


Dictionary of objects

I have a dictionary of Objects of a class Columns               Dictionary<double, Columns>      Columns is a class of columns, i.e. name, post code, etc, mobile phone. I would like to make Columns class as much open for extension as possible, so it will be no trouble to add more classes. I need to set few of the columns to be there always, and would like the user to be able to define which columns to display from the remaining, and also add custom columns. Each columns has to have a method getValue() My idea is to create an abstract class Column and derive specific columns from it. Make each child class implement the getValue() method by making it abstract what should force it to be overridden (am I correct?). I will define enum which will list all available column types. Finally, a class Columns would keep all the available columns in dictionary               Dictionary<enum, Column>      My question is: is my thinking process correct? Is there any room for improvement? Would it be a better idea to use interfaces? Finally, is this design going to be efficient and fast for rapidly changing values in columns, i.e. within a second I might have to update 50 different records in this dictionary.


how to create a new "Custom Conditional Statement" in programming language

Is it possible to create a new "Custom Conditional Statement" in java. Here i am planning to create a new custom component for the switch statement to give better performance. The custom Switch control which i am planning to create will have only integer operators: example:               int i = SOMEVALUE;     Switch(i)     {     Case 1:      //Some Statement     Break;     Case 2:      //Some Statement     Break;     Case 3:      //Some Statement     Break;     ....     ....     ....     Case 10000000:      //Some Statement     Break;     Default:     //Some Statement     Break;     }      According to my knowledge the Switch condition will check in a particular order. If the actual value of the "i" variable is 9999999 then it has to check the case for 9999999 times but if we check it with some algorithms similar to binary search then its performance will be improved. Am I Right ?? If right then why don't we add this functionality to our programming language ? So why don't we create a "Custom Conditional Statement" something like "OrderedIntegerSwitch statement" , in which the value passed inside that switch should be an integer.


Is it a good idea to use width and height properties with the < td > tag?

I am new to HTML and Im working on a self made project and I have to use < table > and < fieldset > tags in my html files. I need to set the width and height properties to the tables like               <td width="100" height="200" > </td> <!-- something like that -->      But Im afraid of these reason because as the Monitor size changes with the computers some have large screens and some have small screens like notebook pc's. The table dimensions looks small for the big screen computers and big to the small screen computers.How do I manage them. How do I fit it to all types of screen sizes. I mean when it goes to the right most part of the screen it jumps to the next line, if I use width property to the < td > tag? and also using Padding like these is a bad idea ?               < span style="padding-left:100"> </span>      It looks exactly what i want on my browser. Does it look same on all types of monitor sizes? or does it vary? Is there any standard way to follow it? I love your answers but answer these original question too, does it matter to the monitor sizes using width and height properties in < td > tag ?


What's the most important, useful or enlightening thing you learnt in the last 12 months?

A lot of people in the coding community talk about continuous improvement, deliberate practice and so-on - but when they talk about their current practices it's almost like they 'sprang fully formed from the loins of Zeus' because you don't hear about how their opinions changed over time or what they learnt recently. Every now and then though I go to a talk, or read a book, or talk to someone and they open up a bit more and I find that I learn a lot from these insights. So, if you had to pick **one** thing from the last 12 months that you learnt what would it be?


git repo structure with post-receive hook

I plan to use git/gitolite to provide managed read/write access for approximately 30 developers and project managers to a shared SAN with the following file structure:                   base/          clients/           clientA/            dirA/              xxx-config.xml-app1              xxx-config.xml-app2            app1/              conf/              deploy/              app1.tgz            app2/            app3/            ...           clientB           ...      I can use gitolite to to configure R / RW access for different groups of devs. The files the developers need to read / modify are the xxx-config.xml-appX and the files in the conf/ and deploy/ folders. Further, whenever anything in conf/ or deploy/ are modified (via "git push"?), I need a git hook script to recreate the appX.tgz file containing all the new contents of the appX folder. I'm assuming each developer could do a "git clone" to their local computer and do periodic "git fetch" to refresh or "git push" whenever they make changes. The "git hook" requirement has me wondering whether I should have one git repo for each client folder: /base/clients/clientA, .../clientB, etc. or one repo for each clientX/appX folder. The following comes from the gitolite samples:                   repo    clientA           RW+     =   @clientA-grp           option hook.post-receive    =   deploy      If there is one repo for each client folder, how would the "deploy" script know which appX.tgz file needs to be recreated? Or would it just recreate them all indiscriminately? The second option clearly doesn't scale.


How to address, "Is anyone even using this feature?" questions

My team will regularly make code changes that break a unit or integration test for a feature hidden deep in the dark corners of our application. When the test breaks there is a frequent question, "Who is even using this feature!?". We generally un-break the code and make the test pass because, as developers, we cannot determine if a feature is still in use and still needed. How can my team and I effectively address obscure or seemingly strange features? I think what we want to know is if any customer is using them and if not can we remove the feature. With several hundred users and the nature of our app it would be hard to put a logging or reporting feature in our app to phone home whenever a 'feature' is used. I think that makes this a management process rather than a technical process.


Finding the best practice for a game simulating tool

I'm studying Java right now, and I'm thinking of this tool as my practice project. The game is "League of Legends" in case anyone knows it, I'm not actually simulating the game as in simulating game play, I'm just trying to create a tool that can compare different champions to each other based on their own abilities and items bought inside the game. The game basics are:   * Every player has a champion in a team of 5 players playing against another team.   * Each champion has a different set of abilities (usually 4) that s/he uses to do damage to opposing champions.   * Each champion gets stronger by buying different items, increasing the attack it deals or decreasing the damage received. What I want to do is to create a tool to be used outside the game enabling players to try out different builds for their champions and compare the figures against other champions they usually fight against. The goal is to enable players get a deeper understanding of the different item combinations (builds) that can be used during the games, instead of trying them out in real games which can be somehow very time consuming. What I'm stuck at is the best practice I should follow to make this possible using Java, I can't figure out which classes should inherit from which, should I make champions and items specs in the code or extracted from other files, specially that I'm talking about hundreds of items and champions to use in that tool. I'm self studying Java, and I don't have much practice at it, so I would really appreciate any broad guidelines regarding this, and sorry if my question doesn't fit here, I tried to follow the rules. English isn't my native language, so I'm really sorry if I wasn't clear enough, I would be more than happy to explain anything that's not understood.


Is there a clear leader amongst JVM-based languages?

What is the current status of these projects, and has any one (or two) emerged as a clear leader? To demonstrate my motives for asking this question, cast your mind back several years. Prototype and jQuery were going head-to-head with other players like MooTools fighting to survive as well. Fast forward to today, and the general consensus is that jQuery is the best general purpose JavaScript library. Has something similar happened in the last several years with these JVM-based languages? Have certain languages fallen into disrepair and abandonment? From what I've read, it seems that Scala is certainly well-prepped to become the favorite, but then again, nearly everything I've read is several years old. * * * I've done a bit more research - I had the idea to check out search volume through the years by using Google Trends. It seems that Jython and JRuby have relatively little interest while Groovy's volume is decreasing and Scala's volume is constant (at worst) or increasing slightly (at best). Is this an accurate assessment? * * * And yes, I'm referring to non-Java languages on the JVM such as Jython, JRuby, Groovy, Scala, Clojure, etc.


Is it a good practice to create a list of definitions for all symbols and words in a programming language?

After arriving at this point in Learning Python The Hard Way I am wondering if this is a good practice to create a list of symbols and define what they do as noted in bold below, for every programming language. This seems reasonable, and might be very useful to have when jumping between programming languages? Is this something that programmers do or is it just a waste of effort? > Exercise 22: What Do You Know So Far? There won't be any code in this > exercise or the next one, so there's no WYSS or Extra Credit either. In > fact, this exercise is like one giant Extra Credit. I'm going to have you do > a form of review what you have learned so far. > > **First, go back through every exercise you have done so far and write down > every word and symbol (another name for 'character') that you have used. > Make sure your list of symbols is complete.** > > **Next to each word or symbol, write its name and what it does. If you can't > find a name for a symbol in this book, then look for it online. If you do > not know what a word or symbol does, then go read about it again and try > using it in some code.** > > You may run into a few things you just can't find out or know, so just keep > those on the list and be ready to look them up when you find them. > > Once you have your list, spend a few days rewriting the list and double > checking that it's correct. This may get boring but push through and really > nail it down. > > Once you have memorized the list and what they do, then you should step it > up by writing out tables of symbols, their names, and what they do from > memory. When you hit some you can't recall from memory, go back and memorize > them again.


How is leaving on time perceived in software companies?

What are the consequences of leaving work on time in software companies? What's the professional way to deal with this? [Editorial addition] The question is about working standard hours and not putting in extra hours without being explicitly asked to. Is working extra hours a norm or an expected work attitude in software companies and/or for a software developer role? How is one going to be perceived by colleagues and peers if one only worked the standard hours specified by local laws or the contract?


How to document the high-level structure of a Java program?

**Background:** My collaborators and I are writing an article for an academic journal. In the course of our research, we wrote a simulation program in Java. We want to make the simulation program freely available for others to use. We have decided on hosting the code on a GitHub repository. In order to make it easy for others to use, we want to write good documentation for our program, including:   * Javadocs for each class and method   * How to use the code   * Describing the high-level structure of the code My high-level question is: **Could you provide a good example of the words and diagrams that can be used to describe the high-level structure of a program?** This includes as sub-questions:   1. How do we show what classes are contained in which packages?   2. How do we show what packages depend on other packages?   3. How do we show how the objects/classes in the program work together?   4. We have tried to use domain-driven design principles in the design of my code. How do we show the correspondence between the objects in the domain and the particular source code files encoding these objects? (See my "ubiquitous language" description of the project below.) # What I have done so far ## Ubiquitous language We put a "ubiquitous language" description of the code in a file `ubiquitous- language.md`, contents below. The purpose of this project is to study how well a replenishment policy performs in a simple supply chain with a single facility, under different lead time models, report delays and demand models. In each period, the following events occur:   1. If a **shipment** is scheduled to arrive at the **facility** at the current period, then the inventory level of the facility is incremented by X units.   2. If the **schedule** indicates that the current period is a reporting period, then the **facility** submits a **report** to the **supplier**. The **supplier** may receive the **report** instantaneously, or with a delay of several weeks, as specified by the **schedule**.   3. If the **supplier** has received a **report** , then based on the **replenishment policy** , it will calculate a replenishment quantity of X units. A **shipment** of X units of the product will be scheduled to arrive after a lead time of l periods.   4. Customers arrive at the **facility** and demand X units of the product. Any unmet demand is lost. ## Source Code Structure We put an incomplete "high-level" description of the code in a file `structure.md`, contents below. ### Package Level Structure At the highest level, the source code is organized into three packages   * `com.gly.sfs` The main class with the `main` method resides in this package.   * `com.gly.sfs.model` The domain model classes reside in this package.   * `com.gly.sfs.util` Helper classes reside in this package.


Which one to choose: XML attribute or Sub node?

We want to export some data from our data base as XML. For example, a `Person` can have `age`, `name` and some other properties. We have two choices to define the XML format. Choice #1:               <Persons>        <Person>            <Age>16</Age>            <Name>Richard</Name>        </Person>        <Person>            <Age>34</Age>            <Name>Eric</Name>        </Person>        ...     </Persons>      Choice #2:               <Persons>        <Person Age="16" Name="Richard"/>        <Person Age="34" Name="Eric"/>        ...     </Persons>      So what's the difference between definition of sub node or attribute? And what's the benefit of each choice?


When to use tools vs custom development?

To learn dependency injection in a current side-project, I am writing my own dependency injection container. But this has lead me to wonder, at what point is it worthwhile to use a third party product vs "roll my own"? What would be the kind of questions you would ask to figure this out?


Maintaining code-style conventions for large projects

For a while I've been maintaining an ad-hoc script to check code style against our project's guidelines. I'm aware of AStyle/Uncrustify and have used them, but they are best for once- off code-style cleanups, but impractical to just run all code through some automatic process after every commit. To explain the issue a little more, yes - we have code-style documentation, but devs don't always follow exactly, and it's not really great to give them personal mail every time they make some tiny change that goes against some convention. So I took the approach to deal with this like compiler warnings, report inconsistencies but leave it up to the developer to resolve (some of you may be familiar with Python's pep8 style checker). Once every so often we do style cleanups. In general I'm very happy with the outcome (unlike most style checking tools), you get to get a lot of flexibility - so you can choose where to be strict and where to be relaxed about conventions (avoid too many false positives is important too). Currently I'm using Python and Pygments to parse C source code (some C++ also but mainly C) and then my own script to check the tokenized results meet our conventions. This works fairly well, I don't need the full AST you can get with GCC or Clang for example, simply knowing if text is a comment, string, punctuation, preprocessor... etc. is enough (what you would get from syntax highlighting, or a source tokenizer). But I did end up having to write quite a few utility functions for the source:   * extract the body of a block between brackets.   * find matching brackets.   * identify casts.   * inspecting whitespace around punctuation. ... nothing really advanced. The exact conventions are probably not so important, but for an example here are some checks:   * Placement of braces for 'if' statement checks broken into multiple lines.   * Placement of `break` in a `switch` statement.   * Spaces around operators, braces, function calls, after commas.   * Indentation for multi-line if statements.   * Indentation consistency. At this point I would be interested to move away from my own utility functions but still have a script which checks code-style, if there is something else well maintained solving similar problems. I'd be surprised if there is not some other people doing similar projects to maintain consistent source style in this way, so I'm interested to know of any alternatives available. # Question: Considering the workflow I have described, can anyone cite their experiences using a similar workflow, are there projects that already do this, I'm interested to see a precedent.


Is it good practice to create convenience delegate methods?

Suppose I have design like this:               class Corpus:         def something1(self):             pass         def something2(self):             pass         def serialize_to_stream(self, stream):             _CorpusJsonSerializer().serialize(self, stream)          class _CorpusJsonSerializer:         def serialize(self, corpus, stream):             .             .             .         .         .         .       I think that the serialization process should be in a separate class for various reasons. That makes the method `serialize_to_stream` in `Corpus` unnecessary. I would however like to have it there because I think it makes it easier for the users of the Corpus, because they do not have to know anything about another class `CorpusJsonSerializer`. Do you think it is reasonable? Or shall I just expose the `CorpusJsonSerializer` and let the user do the work?


SOA in .NET 4.5 with MSMQ Durability

I have been doing some investigation regarding ASP.NET Web API. I have enjoyed using the WCF REST template to create new RESTful web services, and Web API seems to be a cleaner iteration on that. However, I like the flexibility of WCF in allowing http, TCP, MSMQ. This aspect seems to facilitate a distributed and scalable architecture. Is it correct for me to conclude that WCF would continue to be my best bet when it comes to fire-and-forget durable message queueing?


What methodology to use for planning/developing a Language conversion project?

I am trying to help my friend by creating a part of his on-going project. What I'm going to do is create a Java parser to break up the Java code into operators, parameters etc to build XML representation. Next I want to create a code generator to convert the parsed java code to XML conforming to the schema I've created. Finally I want to use an XML style-sheet to transform the XML into another programming language type. Basically I just wanted some advice on which methodology/model I should use for planning and developing this project. Is there some benefit to using Agile etc for instance?


How can I get non-programmer colleagues on board with bespoke software rather than Dynamics CRM + Sharepoint?

I am working with a company which designs and builds one-off machines. They have been 'dabbling' with hosted Dynamics CRM and Sharepoint (on different servers!) in an attempt to centralise their data and help colleagues collaborate more effectively across projects. They haven't used either system to their potential. Now we are looking at the engineering department who already use a form of version control software for the various CAD files (Autodesk Vault) however it is becoming increasingly necessary to implement more of a generic file version control system as they use many more files than can be managed in Vault (sometimes just photos or scans of paper documents), hence why they were looking at using Sharepoint. However... as the 'programmer' of the bunch, I can see several scenarios which don't seem to fit well with the Dynamics + Sharepoint approach; simple reports based on cross-table queries, exporting certain metrics as a spreadsheet, defining project hierarchies and many-many relationships, and as such I have been pushing for an in-house developed 'ECM' / 'ERP' software package (perhaps in .NET or php). Some colleagues seem to attach a greater value to the MS software (perhaps becuase it has a logo!) but don't see that it's just a framework, not a solution. Can anyone provide a good example of when custom software would actually be better than using Dynamics + Sharepoint and how do I relate that to non- technical staff?


Can I start learning C# immediately?

I've got my BSc in Computer Science 4 years ago and I feel like I've forgotten everything I learnt. I still know the basics such as CPU, mohterboard, RAM, software, hardware, etc but I forgot how they work exactly. In general, I know what a programming language is and I have worked with Java when I was at Uni. To be honest I was just trying to solve the assignments in that time and now I've found I have some interest in programming and I chose C# because I can use it for web and for desktop applications. Now, I want to learn C#. Is there any prerequisites for that? I mean do I need to come back to all the materials that I did study on my BSc? Or can I srart learning immediately?


SVN code review tool

I would like to do some code review on the SVN repository used by our team. For now, I've used Eclipse: show log on trunk, click on a revision and "Compare" to see the changes. The diff renders great, but the navigation isn't practical IMO. I'm looking for a tool that could enable code reviewing with "diffs", but with an **easy navigation in the changes**. For example, being able to **filter/exclude commits** based on their names/patterns, show commits of a user, **show changes since last tag** , maybe watch commits on sensitive files, etc... An Eclipse plugin would be the best, as I could still use functionalities such as Ctrl+click on methods/classes. But any suggestion in welcomed.


Formatting code a bad thing when using a VCS?

I almost always format my code before I commit to make sure it's done properly. Most of my team don't really care and don't always format their code properly (minor things that don't affect the code but affect readability when trying to maintain it). I recently installed the VS power tools that has an option "Format on save", and made a change to a file that wasn't formatted prior. The development VP just came to me and reprimanded me for formatting since it shows up in the merging tool as having almost the entire file changed, instead of just a line or two (so he can't see exactly what I modified easily), and told me to disable the format on save in the future. While I understand that concern, I find it difficult sometimes to sort through the code that is unformatted, and IMO it should be formatted properly all the time anyways. Note that I'm not just reformatting things on a whim., but as I write code I'll either use the power tool or hit the key command to format the text to make it easier to read, and in SVN this shows up as a modification. So I ask, is always formatting the code actually a bad thing? Are his concerns more valid than making sure the code is readable?


Are there any real-world cases for C++ without exceptions?

In When to use C over C++, and C++ over C? there is a statement wrt. to code size / C++ exceptions: Jerry answers (among other points): > (...) it tends to be more difficult to produce truly tiny executables with > C++. For really small systems, you're rarely writing a lot of code anyway, > and the extra (...) to which I asked why that would be, to which Jerry responded: > the main thing is that C++ includes exception handling, which (at least > usually) adds some minimum to the executable size. Most compilers will let > you disable exception handling, but when you do the result isn't quite C++ > anymore. (...) which I do not really doubt on a technical real world level. * * * Therefore I'm interested (purely out of curiosity) to hear from **real world examples where a project chose C++ as a language and then chose to disable exceptions.** (Not just merely "not use" exceptions in user code, but disable them in the compiler, so that you can't throw or catch exceptions.) Why does a project chose to do so (still using C++ and not C, but no exceptions) - what are/were the (technical) reasons? * * * Addendum: For those wishing to elaborate on their answers, it would be nice to detail how the implications of no-exceptions are handled:   * STL collections (`vector`, ...) do not work properly (allocation failure cannot be reported)   * `new` can't throw   * Constructors cannot fail


Solo .NET Programmer moving to a team

I've been a solo .NET programmer for a small startup for the last 8 years. I've put together some pretty decent software, and I always strived to better myself and conform to best practices, including source control (SVN/TFS). I worked very closely with a team of engineers of other disciplines, but when it came down to the software I was the only one programming. I love the craft of programming and love learning new things to sharpen my tools. In 2 weeks I will be starting a new job in a team of 20 .NET developers. My position will be mid-level, and I will be working under some programmers with incredibly impressive backgrounds. Again, the team aspect of development will be new to me, so I'm looking for some general "new guy" tips that will help me be as effective and easy to get along with as possible from the get-go. Anything goes, including high level tips, and small day-to-day things about communication.


Single Identity for Desktop and Web

I'm building a system has both a WPF desktop application as well as an Asp.net MVC application. I need a common user identity component so that user can log on to either one with the same credentials. Is ASP.NET Identity appropriate for this task? Has anyone used ASP.NET Identity with a WPF application? Are there any alternatives?


Looking for statistics on automated testing, continuous integration and refactoring usage

Are there any credible sources of information on the adoption of agile techniques like automated testing, continuous integration and refactoring? Of those that are using unit testing, how many follow test first or test driven development. I'm trying to determine how widespread these practices are.


Do privacy concerns prevent us from accessing location-based user data?

Every time my team begins to explore the scenarios that are possible with mobile device location data, location data that is part of user data, or even location data that may be retrieved or inferred from IP address or browser cookies, we are stopped dead in our tracks by the risk of violating a user's privacy. It's frustrating, because working with location data creates whole new areas for providing a great user experience. I have taken a look at the Mobile Device Privacy Act, related online opinions, such as the ars technica article, and the Electronic Frontier Foundation's recent Mobile User Privacy Bill of Rights, but there isn't really an authoritative (or even de facto) standard and opinions differ. Is it as simple as obtaining a user's permission to make use of location-based data and then safeguarding the data? I would like to know how others are addressing or even skirting this issue. Do you obtain user permission before utilizing location data? Are you just riding it out for now and waiting to see if a national law is passed?


Are DDD Aggregates really a good idea in a Web Application?

I'm diving in to Domain Driven Design and some of the concepts i'm coming across make a lot of sense on the surface, but when I think about them more I have to wonder if that's really a good idea. The concept of Aggregates, for instance makes sense. You create small domains of ownership so that you don't have to deal with the entire domain model. However, when I think about this in the context of a web app, we're frequently hitting the database to pull back small subsets of data. For instance, a page may only list the number of orders, with links to click on to open the order and see its order id's. If i'm understanding Aggregates right, I would typically use the repository pattern to return an OrderAggregate that would contain the members `GetAll`, `GetByID`, `Delete`, and `Save`. Ok, that sounds good. But... If I call GetAll to list all my order's, it would seem to me that this pattern would require the entire list of aggregate information to be returned, complete orders, order lines, etc... When I only need a small subset of that information (just header information). Am I missing something? Or is there some level of optimization you would use here? I can't imagine that anyone would advocate returning entire aggregates of information when you don't need it. Certainly, one could create methods on your repository like `GetOrderHeaders`, but that seems to defeat the purpose of using a pattern like repository in the first place. Can anyone clarify this for me? **EDIT:** After a lot more research, I think the disconnect here is that a pure Repository pattern is different from what most people think of a Repository as being. Fowler defines a repository as a data store that uses collection semantics, and is generally kept in-memory. This means creating an entire object graph. Evans alters the Repository to include Aggregate Roots, and thus the repository is amputated to only support the objects in an Aggregate. Most people seem to think of repositories as glorified Data Access Objects, where you just create methods to get whatever data you want. That doesn't seem to be the intent as described in Fowler's Patterns of Enterprise Application Architecture. Still others think of a repository as a simple abstraction used primarily to make testing and mocking easier, or to decouple persistence from the rest of the system. I guess the answer is that this is a much more complex concept than I first thought it was.


What's the proper hand position for the movement keys in Vim?

I've recently started using Vim and am working to replace Notepad++ as my go- to. However, I'm running into an issue where I keep hitting u instead of i because my right hand is on HJKL instead of the usual JKL;. So, Vim users: Is there a preferred right hand positioning for the editor, or should I just get used to moving my hand back and forth for normal and insert modes?


Maintaining a list of nodes with challenging requirements

This is a question regarding the design of a collection of ordered nodes which have some requirements that I am struggling to satisfy. In the problem area that I am dealing with we have routes which are an ordered collection of nodes. A route will be between 1000 and 25000 nodes. A node itself is a complex object. I need to be able to persist the nodes, ideally to a relational database (as the wider application is currently delivered using an architecture that uses a relational database for persistence). I have two separate requirements which present a difficultly in how to model the data.   1. I need to be able to insert nodes (or pointers to nodes) into the middle of the list and reorganise the list on the fly.   2. I need to be able to retrieve the list in it's correct sequential order with both an efficient index and the ability to random access. The only way I think that I can satisfy the first requirement is to model the data as a linked list where every node points to the next node in the list, which would allow the list to be edited and reorganised on the fly. The only way I think that I can satisfy the second requirement would be to sequentially order the list so each node has a reference to it's position in the list and order/access the list by the position. Is there any other method that I could use that can satisfy the two requirements or am I stuck with building a hybrid that employs both methods at various times depending on operational context and that keeps the two referencing types in synch?


What are the different ways  for performing authorization in a web application other than role-based authorization?

The most common approach used for authorization which I know is role based authorization. Instead of directly storing the access rights against the user ids you create roles and store the access rights against them. Then assign the users the roles. Though I find the role based method quite flexible and easy to maintain I am still interested to know whether there are any better methods for storing authorization details. I am using Spring Security for securing JSF web applications. Along with solutions for Spring Security I would also appreciate general solutions (not specific to a particular security framework).


Usage of "Multi-Paradigm Languages" in commercial applications

I am currently learning the two languages F-Sharp and Scala. These two languages are, in my opinion, both quite comprehensive to grasp. Nonetheless, what seems to make Scala and F-Sharp similar, is that both of them try to offer a conglomeration of programming paradigms (OO, functional), in order to solve real-world tasks and to make them applicable as general-purpose languages. While both languages seem to get the most attention in academia, there is comparable little mention of their usage in commercial software projects. Considering the different platform philosophies behind these two languages, which is -in your subjective opinion- more promising to become widely used for commercial purposes in the near future?


What Are Some Advantages/Disadvantages of Using C over Assembly?

I'm currently studying engineering in Telecommunications and Electronics and we have migrated from assembler to C in microprocessor programming. I have doubts that this is a good idea. What are some advantages and disadvantages of C compared to assembly? The advantages/disadvantages I see are: **Advantages:**   * I can tell that C syntax is a lot easier to learn than Assembler syntax.   * C is easier to use for making more complex programs.   * Learning C is somehow more productive than learning assembler cause there is more developing stuff around C than Assembler. **Disadvantages:**   * Assembler is a lower level programming language than C,so this makes it a good for programming directly to hardware.   * Is a lot more flexible alluding you to work with memory,interrupts,micro-registers,etc.


WHere do I put my update class and handle request / response from HTTP web request?

I don't know how to organize my code. Right now I just dumped everything in MainPage for testing. But what is the proper way to handle getting data from REST web service in Windows Phone 8? I have multiple pages that need to utilize the data that is returned.                   /// <summary>     /// State information for our BeginGetResponse async call     /// </summary>     public class UpdateState     {         public HttpWebRequest AsyncRequest { get; set; }         public HttpWebResponse AsyncResponse { get; set; }     }               public partial class MainPage : PhoneApplicationPage     {         // Constructor         public MainPage()         {             InitializeComponent();                  // Sample code to localize the ApplicationBar             //BuildLocalizedApplicationBar();         }              private async void test()         {                  var handler = new HttpClientHandler();             if (handler.SupportsAutomaticDecompression)             {                 handler.AutomaticDecompression = DecompressionMethods.GZip |                                                  DecompressionMethods.Deflate;             }                  // form the URI             UriBuilder fullUri = new UriBuilder("http://test/GetData?");             fullUri.Query = "format=xml&param=test&dateFrom=20071225&dateTo=20080101";                  var httpClient = new HttpClient(handler);             var str = await httpClient.GetStringAsync(fullUri.Uri);             string test = "";         }              private void Button_Click(object sender, RoutedEventArgs e)         {                       test();                            // form the URI             UriBuilder fullUri = new UriBuilder("http://test/GetData?");             fullUri.Query = "format=xml&param=test&dateFrom=20140124&dateTo=201425 ";                  // initialize a new WebRequest             HttpWebRequest request = (HttpWebRequest)WebRequest.Create(fullUri.Uri);                  // set up the state object for the async request             UpdateState state = new UpdateState();             state.AsyncRequest = request;                  // start the asynchronous request             request.BeginGetResponse(new AsyncCallback(HandleResponse),                 state);         }              /// <summary>         /// Handle the information returned from the async request         /// </summary>         /// <param name="asyncResult"></param>         private void HandleResponse(IAsyncResult asyncResult)         {             // get the state information             UpdateState forecastState = (UpdateState)asyncResult.AsyncState;             HttpWebRequest forecastRequest = (HttpWebRequest)forecastState.AsyncRequest;                  // end the async request             forecastState.AsyncResponse = (HttpWebResponse)forecastRequest.EndGetResponse(asyncResult);                  Stream streamResult;                  string newCredit = "";             string newCityName = "";             int newHeight = 0;                  string XMLresult = string.Empty;                  try             {                      // get the stream containing the response from the async call                 string type = forecastState.AsyncResponse.ContentType;                  streamResult = forecastState.AsyncResponse.GetResponseStream();                      XMLresult = getXMLData(streamResult);                      // load the XML                 XElement xmlData = XElement.Parse(XMLresult);                      string t = "";                  }             catch (FormatException)             {                 // there was some kind of error processing the response from the web                 // additional error handling would normally be added here                 return;             }              }


Etymology of “throw an exception“

Why do we use the expression “throw an exception“ and not something like “generate“? Where was that term born and in which language?


With ASP.NET MVC actions, should I use web services?

In ASP.NET Web Forms if you want to use jQuery and call a method directly, you should either implement a web service, or use Page Methods. Also you can use Generic Handlers (.ashx files). However, in ASP.NET MVC, a controller action (a method in nature) can be called directly from jQuery. What web services has to offer in ASP.NET MVC world? In other words, seems that I can fulfill of my requirements via MVC's clean URLs, controllers and actions. Should I bother using Web Services?


Which version management design methodology to be used in a Dependent System nodes?

This is my first question so please indicate if my question is too vague and not understandable. My question is more related to High Level Design. We have a system (specifically an ATCA Chassis) configured in a Star Topology, having **Master Node (MN)** and other **sub-ordinate nodes(SN)**. All nodes are connected via Ethernet and shall run on Linux OS with other proprietary applications. I have to build a recovery Framework Design so that any software entity, whether its Linux, Ramdisk or application can be rollback to previous good versions if something bad happens. Thus I think of maintaining a State Version Matrix over MN, where each State(1,2....n) represents Good Kernel, Ramdisk and application versions for each SN. It may happen that one SN version can dependent on other SN's version. Please see following diagram:- ![enter image description here](http://i.stack.imgur.com/dh1pv.jpg) So I am in dilemma whether to use Package Management Methodology used by Debian Distributions (Like Ubuntu) or GIT repository methodology; in order to do a Rollback to previous good versions on either one SN or on all the dependent SNs. The method should also be easier for upgrading SNs along with MNs. Some of the features which I am trying to achieve:- 1) Upgrade of even single software entity is achievable without hindering others. 2) Dependency checks must be done before applying rollback or upgrade on each of the SN 3) User Prompt should be given in case dependency fails.If User still go for rollback, all the SNs should get notification to rollback there own releases (if required). 4) The binaries should be distributed on SNs accordingly so that recovery process is faster; rather fetching every time from MN. 5) Release Patches from developer for bug fixes, feature enhancement can be applied on running system. 6) Each version can be easily tracked and distinguishable. Thanks


Why '42' is the preferred number when indicating something random?

I have seen this on the SO on many times. Whenever a question is vague and the question is asking some magical answer somebody or the other leaves a comment saying answer is 42. Even a book I am reading right now uses '42' as the number whenever it wants demonstrate some basic concept using an integer. So is there any history behind it or it is just a coincidence?


What's the first thing you write when trying out a new language?

I think everyone has their own program or set of features beyond "Hello World!", that they use when trying out a new language. Mine is a guessing game:               I'm thinking of a number 1-10, guess what it is!     Guess: 3     Nope, too low!     Guess: 7     Nope, too high!     Guess: 5     Yes, You win!     Play again (Y/N)? N      What do _you_ write?


When does pair programming work for you? When should you avoid it?

Rather than slavishly pair program all the time, we use pair programming selectively on our team. I think it works best in the following circumstances:   * Ramping up brand new team members on a project (instead of letting them wade through documentation or code on their own).   * Having junior and senior people work together (helps to show some of the skills and tricks of the more experienced developers, plus it allows the old dogs to learn new tricks sometimes).   * When someone is trying to track down a defect, it often helps to pair with a fresh set of eyes. When do you pair program and why? When do you avoid pair programming? Why?


What syntax element do you hate most in a programming language you use frequently?

No matter how much you love a programming language, there are always a few details in it that aren’t quite as nice as they could be. In this question, I would like to specifically focus on **syntax elements.** In a programming language that you use frequently (perhaps your favourite programming language, or perhaps the one you are forced to use at work), which syntax element do you find most unreadable, unclear, inconvenient or unpleasant?


Should accessible members of an internal class be internal too?

I'm designing a set of APIs for some applications I'm working on. I want to keep the code style consistent in all the classes I write but I've found that there are a few inconsistencies that I'm introducing and I don't know what the best way to resolve them is. My example here is specific to C# but this would apply to any language with similar mechanisms. There are a few classes that I need for implementation purposes that I don't necessarily want to expose in the API so I make them `internal` whereever needed. Generally what I would do is design the class as I normally would (e.g., make members `public`/`protected`/`private` where necessary) and change the visibility level of the class itself to `internal`. So I might have a few classes that look like this:               internal interface IMyItem     {         ItemSet AddTo(ItemSet set);     }          internal class _SmallItem : IMyItem     {         private readonly /* parameters */;         public _SmallItem(/* small item parameters */) { /* ... */ }              public ItemSet AddTo(ItemSet set) { /* ... */ }     }          internal abstract class _CompositeItem: IMyItem     {         private readonly /* parameters */;         public _CompositeItem(/* composite item parameters */) { /* ... */ }              public abstract object UsefulInformation { get; }         protected void HelperMethod(/* parameters */) { /* ... */ }     }          internal class _BigItem : _CompositeItem     {         private readonly /* parameters */;         public _BigItem(/* big item parameters */) { /* ... */ }              public override object UsefulInformation         {             get { /* ... */ }         }              public ItemSet AddTo(ItemSet set) { /* ... */ }     }      In another generated class (part of a parser/scanner), there is a structure that contains fields for all possible values it can represent. The class generated is `internal` too but I have control over the visibility of the members and decided to make them `internal` as well.               internal partial struct ValueType     {         internal string               String;         internal ItemSet              ItemSet;         internal IMyItem              MyItem;     }          internal class TokenValue     {         internal static int EQ(ItemSetScanner scanner) { /* ... */ }         internal static int NAME(ItemSetScanner scanner, string value) { /* ... */ }         internal static int VALUE(ItemSetScanner scanner, string value) { /* ... */ }         //...     }      To me, this feels odd because the first set of classes, I didn't necessarily have to make some members `public`, they very well could have been made `internal`. `internal` members of an `internal` type can only be accessed internally anyway so why make them `public`? I just don't like the idea that the way I write my classes _has_ to change drastically (i.e., change all uses of `public` to `internal`) just because the class is `internal`. Any thoughts on what I should do here? It makes sense to me that I might want to make some members of a class declared `public`, `internal`. But it's less clear to me when the class is declared `internal`.


Is it legal to release GPL version project into FreeBSD?

I could not differentiate between FreeBSD and GPL liecense. Can anyone tell me the in what respect these two liecense are different. Is it legal to use some source based on GPL license and release the new product as FreeBSD license? In particular, I have following scence: I would like to follow some of the implementation module of some implentation for my use. The implementation is standard algorithm implementation. So basically i am taking some reference to implement in my own way. I am not making use of verbatim copy, some module matches with the original one. The one which i am taking reference is in FreeGPL V3 license. The new product which i will release with FreeBSD license. Is it legal to do this or I should relase my product in FreeGPL license? [EDIT] Moreover, my case is, I am implementing some standard algorithm. Lets say here a data structure linked list. I think,whoever implements it, he/she will have same structure and similar kind of functions for search, delete and insert.Even the operations will be seen. I saw some code in internet and i got the influence of that of code my implementation which was so unavoidable. In this case how can a programmer can claim that the particular code is his own original code?


What languages are used by professional mobile app designers?

I've recently done some Java programming for an android app (though my question is not android specific), and was wondering if what I was doing was just a lot less complicated, but generally the same as what a professional mobile app designer would do. I kind of asssumed that an app designer working for, say, the BBC would use an expensive software package, and maybe a different language. So my question is **what language would they be using?** Maybe they would use one that would work for both Android and iOS?