Threading and async intterupting on same process and thread, along with related

So, I'm trying to understand threads. I realize they are a mix of hardware and OS decisions. I also know that a thread, or process, has a set of register/stack variables and functions. In each thread, they get duplicated when forked, "packed up" when not running and "unpacked" back into the registers when they start again. I can use them fairly decently, but there are a few things I do not know: What happens when you interrupt the same thread? Eg, I'm on the main thread, bug a SIGCHLD is called or any interrupt, which interrupts the main thread in order to run this one function, then goes back. How do the stack variables "pack up", if they even do? (basically, same thread is interrupted, what happens to stack vars and function stack) A game loop, or event loop is continuous. I've started to accept the idea that, halfway into any function, it could just stop and switch to another thread "context". I also know that after every loop, it may or may not say "I'm waiting for a timer/event, sleep for a few ms on me", so will it try to run its interrupts there or just at any random time? How do I tell my own loops to stop and wait if I want to keep a certain pace? - I realize this might be in a book on OS's, just don't know what part. (Basically, how do threads sleep? Are they really interrupted halfway into a task?) (the above is surprising to me because I always thought of a program as a continuous set of things, it's like I have to change my mindset completely to understand how it really works) As far as I'm aware, sync-ing ensures that a variable is the same across all registers. So with my first Q, is the register and stack the same when the main thread is interrupted? Must I sync anything? If they are different threads, does it wake up the others just to sync the variables, or do the threads stay "asleep"? I'm betting they all point to the same heap vars, but where could differences arise besides pointers pointing to old addresses? I realize if I knew where to read, maybe I could infer more than half of this. I apologize if they sound basic, I've been reading but a lot of this, I just don't get but would like to. I use GCD a lot which hides the details, so I know to sync, gate, but I have absolutely no idea where my threaded variables are going and when/how. I learned about this from some sockets programming and an OS book I was reading, but obviously I'm missing some critical details. Thank you. Stephen


SPA: outsourcing client-side development

Given a SPA-based web site (with a client developed using any JS MVC framework and the server providing a REST API), does anyone have any experience in outsourcing the development of the client side and parallel development of the server-side? What were the problems you encountered? Was it really beneficial?


How early is too early to be involved in new feature development?

I develop an internal business application that our engineers use to test and debug the company's product. The engineering manager has been pushing to get the software developers involved when the engineers are in their design phase. He says that he wants to give us an idea of what's coming down the pipe, and give us the opportunity to provide feedback on their designs (we rarely have feedback). The engineering manager wants the developers and engineers to implement new features simultaneously, so that by the time the engineers have implemented their end, they can use the software to test them. The feature designs tend to be volatile until they are fully implemented by the engineers, making it difficult to draw up requirements. He thinks the engineers and developers can do all of our debugging side-by-side, at integration time. It all seems inefficient and backwards to me.


Who should set the goal for a retrospective?

I am the SM of a team and would like to know who should set the goal for the retrospectives


How to cure the "can not deliver"/ "cannot deliver on time syndrome"

I am an above average programmer (I take interest in the development of languages, frameworks and technology in general and have a good grasp of systems), but I constantly find my self not being able to deliver things (on time). This does not affect my day to day work as it has good control process (bite sized tasks with shame driven development) But it definitely hurts me in my personal projects. Some of the reasons that I think are at play. -I make things more complicated than they need to be. Often a lot more than I admit to my self. -I am not very good at making the tasks smaller at times. -I wander off into obscure corners when I encounter them instead of keeping a laser focus. The result is often that I don't deliver. Now I may know at the back of my head that what I need to do, but I would appreciate your strategy on how to be the guy who "delivers".


Single Page Web Application Web Service Scalability

I am trying to build a single page web application that will call multiple web services (both SOAP and RESTful) and aggregate the data in the UI. Initially I though I could do it all client-side, with ajax requests, but I realize that   * If there are many requests, and they are fired per user, the data can take a long time to load.   * If there are a lot of users, then I can easily reach my limit of API calls. So now I'm thinking that I will have to have some kind of server-side process that runs every hour (or whatever), retrieves the items, and inserts/updates them in a database. Is this the right approach? Are there any other pitfalls I need to avoid?


Any good tips for a PHP Programmer for starting on Iphone and ipad apps? (have pc only)

I am trying to learn creating apps for IPhone and IPad, apps like database oriented websites where user can save their data. I am a normal php programmer and use only Windows PC. Any good tips that you guys can suggest me to begin with would be highly appreciated. Thanks!


Should static data be stored in a database or somewhere else?

I'm working on some software at them moment and I'm not sure which route to take with this. I have some data to store somewhere on a mobile device. The data will never change, and has a hierarchical relationship, and will be used to populate the display. There is a reasonably amount of this data. I have the following options:   1. A set of enums/objects   2. An XML file   3. The embedded SQLite database In this particular case I think that the enums option is the least work, but I get a smell from the data being embedded in the code like that. The XML file makes the most sense I think, but parsing it will be a resource hit that seems like a waste since it will 'never' change. The database should provide less of a performance hit, but seems like overkill for static data. Which is the correct design path here? **Note:** By 'Never' change I mean that it will rarely change. The data in question is a model of a set of government standards, so they may well change at some point in the future but its not going to be regularly and its not going to automatically update our software either as a change in the standards could well trigger a change in our requirements.


web content management system

Quite a few of my friends want to have their own personal website to showcase their talents. However, they don't want to deal with such technical things as writing html and managing web server. Neither do I. It would be nice that we go to our URL and view our pages and we edit and update our information when logging in. So basically the content displayed will be what we provide and at the same time we can choose from some provided templates for page layout and style. It seems a typical content management system to me. If it is, I'd like to build a simple one myself because I'd like to have the experience of building a simple CMS. Since I have no previous experience for this, I need some help figuring out what is all I need for it. And, what are the most appropriate tools and technologies? So far, I have **html** , **css** , **JSP** , **Tomcat** , **SQLite** in my mind. Is that enough? Are they the best combination? Also, I have no idea how to approach the authorization and security aspects of building the system. (PS: I'm not sure what tags are proper for my question. Feel free to edit them for me)


When to use RCP?

I like to write small GUI applications using Java and Swing, something like a client for the social website Tumblr Should I use Eclipse RCP or the Netbeans platform? And what benefits do I get from using either one over using plain swing/SWT? Do RCP applications require more dependencies than those developed using Swing or SWT?


Please share experience on how to make the source code easy for other to follow?

I can write source code in a period of time, but after a while of not touching the project, it takes me time to be familiar with the source code again. Also, other people need some time to study the program... How do you make source code more easy for others to follow?


Is there a typical way of having a view that is a dependent on another?

I am working on a program with two views, html and ajax (which will be html transmitted via json). The HTML view is the standard, and by default the ajax should look the same. However, the ajax view is also meant to have options configurable on the client side for which components of the page should be displayed. I'm having trouble wrapping my head around making an elegant way to handle this requirement. Is there a standard way to handle related views like this?


Modelling project structure for Management

The project I am putted in is running awful. :-) Main Problem is a missing architecture and a missing guidline how to organize projects. In this case I have done a sample project architecture with UML class and component diagrams and layer diagrams. The main problem is, that I have to present this architecture to the management. But the management is not familiar with UML or Layer Diagrams and for most of them its not possible to understand the logic behind it. In that case I want to present the management a visualized project structure with easy understanding. I've searched for some ressources and examples with easy understanding visualizations, but was not able to find one. So my question is how you would visualize your software architecture to the management, which techniques do you use? Little Note: its a very big sharepoint project with more than 50 sub projects.


What's a generation in Software Development?

I've heard about software and apps going into Generation 1.2 or 2.6, is there an actual methodology behind this? or it's more of a marketing thing? Currently we are using Scrum as our methodology in agile software development and it's based on sprints, but I haven't been able to find any information detailing what's actually a generation in software development (neither on Agile based methodologies and non-agile). http://en.wikipedia.org/wiki/Sprint_%28scrum%29#Sprint


When does it become mandatory to sign up with the Bluetooth Special Interest Group (SIG)?

My company is looking to add Bluetooth functionality to our hardware, so that we can integrate connectivity to our products with various tablet devices. To do this, we are looking to purchase an all-in-one chip that we can integrate into our boards. Everyone within the development team is new to Bluetooth integration and as I am doing my research, I am finding a lot of references and material that points me back to Bluetooth.org and mention becoming a Special Interest Group (SIG) member. This has raised various questions regarding the necessity for us as a company to join the SIG. We would rather not have to go through that process because that would involve paying various fees and dragging corporate lawyers into the process. We've already had to jump through a few legal hoops ( _ahem_ , MFi anyone?) and would prefer not to have to go through any of that again for the sake of development time. If we want to integrate simple Bluetooth connectivity into our devices, do we have to go through the process of joining the Bluetooth SIG or are we covered and allowed to promote our devices as Bluetooth enabled since the all-in-one chips we will be integrating will becoming from a major manufacturer who has already become a SIG member and has had there chipset certified by the SIG?


Passing a Scala function to a Java 8 method

The following Scala code works and can be passed to a Java method expecting a function. Is there a cleaner way to do this? Here's my first pass:               val plusOne = new java.util.function.Function[Int,Int] {       override def apply(t:Int):Int = t + 1            override def andThen[V](after:function.Function[_ >: Int, _ <: V]):         function.Function[Int, V] = ???            override def compose[V](before:function.Function[_ >: V, _ <: Int]):         function.Function[V, Int] = ???     }      Here's my second pass - it uses a generic wrapper for the Java-8 Function interface to make the Scala syntax simpler:               // Note: Function1 is Scala's functional interface,     // Function (without the 1) is Java 8's.     case class JavaFunction1[U,V](f:Function1[U,V]) extends Function[U,V] {       override def apply(t: U): V = f(t)       override def compose[T](before:Function[_ >: T, _ <: U]):         Function[T, V] = ???       override def andThen[W](after:Function[_ >: V, _ <: W]):         Function[U, W] = ???     }          val plusOne = JavaFunction1((x:Int) => x + 1)     val minusOne = JavaFunction1((x:Int) => x - 1)      Can we do better? As a follow-up, is there any chance that Scala will someday use the invoke- dynamic op-code as Java 8 does for its first-class function application? Will that make everything magically work, or will there still need to be a syntactic conversion?


Naming convention: field starting with "m" or "s"

I saw lot of code (for example some Android source code) where fields name start with a "m" while static fields start with "s" Example (taken from Android View class source):               private SparseArray<Object> mKeyedTags;          private static int sNextAccessibilityViewId;      I was wondering what "m" and "s" stand for... maybe is "m" mutable and "s" static? Since it seems that is a largely adopted pattern do you know if there some literature about this kind of naming convention?


should I extend or create instance of the class

I have two classes Class A and Class B in Class A, i have three methods that perform the save, delete and select operation based upon the object I pass them. in Class B I perform the logic operations, such as modification to the property of the object before being passed to the methods of Class A, My problem is in Class B, should it extend Class A, and call the methods of class A , by parent::methodName or create instance of class A and then call Class A does not includes any property just methods.               class A{       public function save($obj){              //code here         }             public function delete($obj){              //code here         }              public function select($obj){              //code here         }      }      //Should I extend class A, and call the method by parent::methodName($obj) or create an instance of class A, call the method $instanceOfA->methodName($obj);                class B extends A{              public function checkIfHasSaved($obj){              if($obj->saved == 'Yes'){                       parent::save($obj);   //**should I call the method like this**                      $instanceOFA = new A();   //**or create instance of class A and call without extending class A**                       instanceOFA->save($obj);                 }                  //other logic operations here           }           }


Would you make use of "Google 20%" time if your employer encouraged and funded it?

We know about Google's 20% projects, whereby a developer can spend up to 20% of their time on a personal project which interests them. If your employer let you spend 20% of your time on a project that wasn't part of your day-to-day work, would you make use of it? I can think of a couple of reasons why not:   * It would make your normal work take 20% longer (extended deadline)   * You might want to keep your personal idea "personal."


What are the most common ways used to migrate a Delphi application incrementally to .NET?

If you have several million lines of Delphi code and want to incrementally migrate to .NET/C#, what strategy would you use?


Exception Handling Frequency/Log Detail

I am working on a fairly complex .NET application that interacts with another application. Many single-line statements are possible culprits for throwing an Exception and there is often nothing I can do to check the state before executing them to prevent these Exceptions. The question is, based on best practices and seasoned experience, how frequently should I lace my code with try/catch blocks? I've listed three examples below, but I'm open to any advice. I'm really hoping to get some pros/cons of various approaches. I can certainly come up with some of my own (greater log granularity for the O-C approach, better performance for the Monolithic approach), so I'm looking for _experience_ over opinion. * * * **EDIT:** I should add that this application is a batch program. The only "recovery" necessary in most cases is to log the error, clean up gracefully, and quit. So this could be seen to be as much a question of log granularity as exception handling. In my mind's eye I can imagine good reasons for both, so I'm looking for some general advice to help me find an appropriate balance. * * * ## Monolitich Approach               class Program{         public static void Main(){             try{                 Step1();                 Step2();                 Step3();             } catch (Exception e) {                 Log(e);             } finally {                 CleanUp();             }         }              public static void Step1(){             ExternalApp.Dangerous1();             ExternalApp.Dangerous2();         }              public static void Step2(){             ExternalApp.Dangerous3();             ExternalApp.Dangerous4();         }              public static void Step3(){             ExternalApp.Dangerous5();             ExternalApp.Dangerous6();         }     }      ## Delegated Approach               class Program{         public static void Main(){             try{                 Step1();                 Step2();                 Step3();             } finally {                 CleanUp();             }         }              public static void Step1(){             try{                 ExternalApp.Dangerous1();                 ExternalApp.Dangerous2();             } catch (Exception e) {                 Log(e);                 throw;             }         }              public static void Step2(){             try{                 ExternalApp.Dangerous3();                 ExternalApp.Dangerous4();             } catch (Exception e) {                 Log(e);                 throw;             }         }              public static void Step3(){             try{                 ExternalApp.Dangerous5();                 ExternalApp.Dangerous6();             } catch (Exception e) {                 Log(e);                 throw;             }         }     }      ## Obsessive-Compulsive Approach               class Program{         public static void Main(){             try{                 Step1();                 Step2();                 Step3();             } finally {                 CleanUp();             }         }              public static void Step1(){             try{                 ExternalApp.Dangerous1();             } catch (Exception e) {                 Log(e);                 throw;             }             try{                 ExternalApp.Dangerous2();             } catch (Exception e) {                 Log(e);                 throw;             }         }              public static void Step2(){             try{                 ExternalApp.Dangerous3();             } catch (Exception e) {                 Log(e);                 throw;             }             try{                 ExternalApp.Dangerous4();             } catch (Exception e) {                 Log(e);                 throw;             }         }              public static void Step3(){             try{                 ExternalApp.Dangerous5();             } catch (Exception e) {                 Log(e);                 throw;             }             try{                 ExternalApp.Dangerous6();             } catch (Exception e) {                 Log(e);                 throw;             }         }     }      **Other approaches welcomed and encouraged. Above are examples only.**


Updating Java SE and Java EE knowledge

I wonder how you guys are updating your tech knowledge on a daily basis. Definitely it will be from internet. But what are those sources? E.g. I didn't know about the DWR technology but knew if from my colleague and used it in my work. I like to know about technologies like this, to use in our Java SE and Java EE projects as soon as they are available to the community.


"Worker object pool" pattern?

In my application requests are processed by objects of `Processor`-derived classes, something like `CreateItemProcessor` or `MoveItemToGroupProcessor`. Base Processor class implements most of common processing logic, and derived ones make some specific business logic related tasks. An object of a certain processor type is created before request processing, and then wiped out afterward. Eventually it came to a situation, when creation of a single processor object was taking major part of request processing time. So now I'm thinking about creation of a pool of request processor objects, and reuse them instead of using create/delete approach. The problem here is that any single `Processor` object is not thread-safe, and actually shouldn't be tread-safe: it stores request-specific data inside. So my general approach to that is as follows:   * Try to acquire 'processor' from a pool;   * If there are no any available, wait;   * When we have processor available, mark that as 'working' and start processing;   * When job is done, "return" processor to the pool;   * Notify pool that free processor is available. Is there a kind of design pattern for that? Am I missing something from the existing GoF patterns? Any C#-related implementation details?


Why were Java collections implemented with "optional methods" in the interface?

During my first implementation extending the Java collection framework, I was quite surprised to see that the collection interface contains methods declared as optional. The implementer is expected to throw UnsupportedOperationExceptions if unsupported. This immediately struck me as a poor API design choice. After reading much of Joshua Bloch's excellent "Effective Java" book, and later learning he may be responsible for these decisions, it didn't seem to gel with the principles espoused in the book. I would think declaring two interfaces: Collection, and MutableCollection which extends Collection with the "optional" methods would have led to much more maintainable client code. There's an excellent summary of the issues here. Was there a good reason why optional methods were chosen instead of the two interfaces implementation?


In c++, difference between linking a class object and just including it.

this is my first time here. I'm a physics grad student and I've recently found a research group to work with. We study statistical mechanics using computer models, so there is a significant programming aspect to it. My first job has been to take the old data analysis code (written in java) and clean it up in c++. The guy before me who wrote the original program used the traditional physics method of using an enormous amount of spaghetti code and shoving it all in a constructor. This irked me quite a bit, so I divided it up into separate classes and now it has a reasonable class structure. In the past, whenever we had defined a class we would put its definitions and its methods in a header function, then to use it we would just include it. I know this breaks the rules of how to use .h and .cpp files, but is there any reason other than code etiquette to compile and link a class object rather than include it? Sorry for the long question.


Using mocks to set up object even if you will not be mocking any behavior or verifying any interaction with it?

When building a unit test, **is it appropriate to use a mocking tool to assist you in setting up an object** even if you will not be mocking any behavior or verifying any interaction with that object? Here is a simple example in pseudo-code:               //an object we actually want to mock     Object someMockedObject = Mock(Object.class);     EqualityChecker checker = new EqualityChecker(someMockedObject);          //an object we are mocking only to avoid figuring out how to instantiate or      //tying ourselves to some constructor that may be removed in the future     ComplicatedObject someObjectThatIsHardToInstantiate = Mock(ComplicatedObject.class);          //set the expectation on the mock     When(someMockedObject).equals(someObjectThatIsHardToInstantiate).return(false);     Assert(equalityChecker.check(someObjectThatIsHardToInstantiate)).isFalse();          //verify that the mock was interacted with properly     Verify(someMockedObject).equals(someObjectThatIsHardToInstantiate).oneTime();      Is it appropriate to mock ComplicatedObject in this scenario?


what is the technical term for this presentation model?

I have an application I've inherited that I'd call "proto-MVC", and I love the concept of MVC but am new to it. In my ideal dream of a lightweight application, all of the document's content is stored in an array:               <script>     var MVCDocument={         DOM:{            ...         },         listeners[           {..},           {..}         ]     }     </script>      That array defines the content and structure of the page, as well as what programming assets are present at the time. Next, I would have listeners or running processes that monitor the structure of the MVCDocument and react to any changes in it. These processes are the "brains". Ajax calls will modify or annotate the MVCDocument. Changes to the MVCDocument object might in turn modify the listeners/"Brains". CSS would function to style the presentation layer. The problem is that I don't know the right terms to look for examples of what I'm wanting to develop. I prefer NOT to re-invent the wheel. What are some good examples of aps that run based on this premise? and are there more components than just the bones (document array), brains (javascript coding), and clothing (css)?


Does not testing internals entail diligent refactoring and/or rely on developer talent?

I'm not asking here what the arguments are for/against testing internal methods (though I'll restate some, and don't mind hearing others). My questions relate to the implications of only testing public interface. Especially, whether I understand the extent of the "refactor" part of Red- Green-Refactor in by-the-book TDD, and if there are non TDD techniques TDD practitioners use that address the problems that make me want to test internals. My question is: If you write the most straightforward code possible to get the light green, and if you don't test internal methods, does it follow that from time to time you allow yourself to start off by writing a class that does far more than it should with a bunch of member variables you know will not survive refactoring? And wind up after refactoring with a bunch of methods that aren't explicitly tested? As I get familiar with TDD, it feels like anyone would at least be tempted to test internal methods. And many practitioners flatly say you shouldn't. E.g. (of about 23 million results): Item 2 here and it's comments and this StackOverflow post Given an implementation will involve more than one non-trivial problem, if you only test the public interface, there are two possibilities: 1) non-trivial logic winds up getting tested only indirectly, AND tested in the same calls as other non trivial logic. 2) you make methods public that you don't expect clients other than the SUT and the tests to call. I think what I hear from the advocates of by-the-book TDD is "1 is right. Yes, a lot of non trivial code is tested only indirectly, and that isn't a problem. After all, you don't want your tests to start failing when you improve the implementation. Even if they don't fail, it's not innocuous if tests keep passing when they're targetting a bunch of no-longer-used code, because the tests show how to use your class. You Should Only Test the Public Interface." And that sounds like a reasonable thing to say, but I haven't seen it said explicitly. But even though it sounds reasonable -- if I don't test internals I feel like I lose part of what helps keep the tests DRIVING the coding (maybe part of my difficulty applying the precepts is that I don't distinguish between coding and developing). If there's some internal logic that has to turn a String to a valid int32, int64 or decimal value depending on what's in the string and the type of some other object, I want to test that little bit of logic, not just find out that the whole method failed. I want one test to pinpoint those few lines of code and exercise what should fail. The thinking in the doubly downvoted answer here seems so obviously attractive that I have to wonder if the by-the-book fellows are neglecting to mention some instrumentation/tracing/logging code they use in addition to TDD, or if they watch it work in a symbolic debugger. Or do they just recognize that as a failure point and write a test with input that will cause a failure pinpointing those few lines of code? If they do that it's testing the implementation though. It seems so natural to want to test that code in isolation, and verify it fails where it should, even though it's an implementation detail. I suppose that with talent and experience you can classify bigger chunks of code as "non-trivial" but I haven't seen anyone bluntly saying or condescendingly implying that that's why they don't have to test implementation details. Lots of time it makes perfect sense to me to test the public interface, lots of methods really are like what you see in TDD examples. But for the feel of where I wonder if purists are doing something more than writing tests on a public member: Say you want to put data from an ISAM file into a database. There is one public method to the envisioned consumer of the code: public void LoadIt(SqlConnection c). "Loadit" has a bunch of other dependencies that will be resolved using configuration files and environment variables: some code has to determine that it can find the name of the folder where the ISAMs live; to find, load and parse the schema file for the isams using the ISAM vendor's DDL library; so forth+so on. But none of that is of any interest to any envisioned calling code. My only reason for moving the dependency resolvers out of the Loadit class would be so I could test them OR to make the code easier to understand/maintain. Moving to another class to make them testable is Doing It Wrong -- they're really just implementation details of LoadIt. And in my first implementation, I am just trying to write enough code to get the light to turn green. So I won't write anything with reasonable maintainability if it's easier to just manhandle a bunch of variables in a big method or two. I won't write helper classes. Instead, I'll get the light green and then do the Refactor part diligently. Even when I clean it up, any classes introduced keep "internal/friend" accessibility, and only get tested via the call to LoadIt. Thanks for reading this far; as a reminder, my question is in the second paragraph.


How suitable is D2 for numerical work

I'm interested in working with the D programming language for simulating physics. How suitable is it? Is DMD's floating point code generation mature enough to compete with compilers available for c++ and fortran? Have fast matrix libraries been ported to D (or are they accessible from D)? Is there anything in the language itself that would inhibit/improve the floating point performance of the language? I love programming in the language, however I'm worried that the compilers/libraries might not be suitable yet for numerical work.


How to deploy a heterogeneous server application to customers?

We have a bigger application server which customers would like to have deployed locally. It consists of an MySQL server database, a REDIS database, multiple Web servers for sub parts, a NGINX reverse proxy so that these web servers are reachable from Port 80 and a homegrown C++ server. All sub parts (DB, Webservers, ...) have to be configured to be accessible by each other. At the moment (for in house use) deployment and configuration is done by hand; but in order to roll it out to customers, we would like to have a Out-of-the- Box-Solution which gets assembled by some build script. What would you suggest?   1. Maintaining a VM which just gets configured and then deployed?   2. Maintaining some installation script or package   3. Something else? Usually we would prefer 2. as it seems the more natural way and let the customer decide whether he wants to use a real server or a VM. Also sounds automatic creation of VMs rather time-expensive. The Problems we face are the usually not-to-be-embedded-components like MySQL and NGINX. NGINX configuration is stored in /etc/nginx/. I don't think that .DEB-packages are allowed to overwrite foreign NGINX configuration nor is it a good practice. The same with MySQL. It is also possible to embed MySQL/NGINX/Redis but this is not a trivial task.


What about ALM systems, ERPs, and embedded products?

We are working on getting a new application lifecycle management (ALM) system, including a bug tracker, a documentation system, project management, etc. The concern is that we deal with quite complex embedded systems and we would like to have the best possible integration of the different services (project management, issue/task tracking, documentation, etc.). If it was software only, I'd just buy something like JIRA, but the fact that we would hope to manage software, firmware (no big problem there), and hardware in the same system makes me doubt a little bit. I'm looking for advice regarding these points:   * What about managing "bugs" with embedded products? In software, you have the versions of the affected module(s). In embedded products, you have different software driving often times different firmware operating sometimes different hardware. Is it good in practice to simply consider hardware parts as if they were software modules in a software-intended system? I tend to believe it will add many custom fields to the bug tracking interface and consequently won't promote its systematic use.   * Some would like to push integration to the level where you have hardware inventory integrated to the rest. This means that a project in the ALM (think JIRA) would have to reserve its hardware components based on the sub-components. It would also mean that, for example, the ALM in question would have to be able to manage part providers and offer facilities to easy purchase order creation, sending, and management in general. I'm wondering, at that point, if everything in an embedded project management process can be integrated in one management system, or if a line has to be drawn between 1) bug/task tracking (possibly software and hardware) and project management and 2) high level project management, inventory tracking, sale/buy orders, etc. What is ultimately wished for seems to be nothing less than an integrated JIRA and ERP. Or is it possible to do proper ALM in an existing ERP or have a decent ERP in an ALM system already? My personal opinion, from what I know right now, would be to split issues and project management (ALM + documentation + ...) from the ERP. The problem with that is that there's documentation about a project both in the ERP and in the project management of the ALM (which would be used for software, firmware, hardware, ...). What's funny in this is that some things might seem very unrelated at first, like the time sheets (ERP) and an issue (bug tracker in ALM), but in the end, it might very well be interesting, wanted, or even required to know how much time was spend on a bug, or a project altogether (bugs, issues, features, other tasks). This gives a point toward total unification of ERP/ALM... At this point, you should get a feel of my questioning. Any helpful input is greatly appreciated. Thanks!


LINQPad still being used much out there?

I'm trying to guage how popular and how used LINQPad is today. I'm just wondering if it's still a useful tool or not as VS and other tools have gotten better. Furthermore, I am coding over LLBGen by working with LINQ to SQL. I see there is a plug-in for LLBGen and LINQPad. Still I wonder if LINQPad is really worth it or what benefits it can give me or if it's still highly suggested out there for ORMs, etc.


What language is the CLR written in?

Just out of curiosity, what language is the CLR written in? I read on the Java Virtual Machine wikipedia entry that it is programmed in C++; is this the same for the CLR? Sorry if this is off-topic, I didn't feel that this question was technical enough to go on Stack Overflow. Thanks! :)


Why is an interface in Java not allowed to have state?

There must be a good reason why Java designers didn't allow any state to be defined in interfaces . Can you please throw some light on this aspect of design decision ?


When not to use Google Web Toolkit?

I'm considering use of GWT on a major in-house web app development project, namely it's major advantage in my eyes is the cross-compilation to Javascript which would (at least theoretically) help my team reduce the size of tech stack by one. However, having been burnt before (like most devs), I would like to hear from programmers who did actually use it on any problems with GWT which would hamper, or limit, it's use within a certain problem domain. What are the arguments against using GWT, and why?


CakePHP: Automation triggers after save - best done as component or behavior?

Folks, first time on CodeReview - just looking for some input in creating some automation in CakePHP, wondering if this is best used a component or a behavior. It's model driven but involves logic and processing. Here's the scoop: The app I'm creating requires the user to be notified when a model meets certain conditions - additionally data in the affected model or a related model might need to be changed. For example, if a customer model is saved with a certain state/province, assign that customer to a sales rep (by changing a relational field) and notify them through a Growl or an Email. So it's data driven, for sure, suggesting behavior, presumably afterSave() But it also requires logic and other utilities not typically used in the model or behavior (email, for example and Session/system configuration/user preferences) - functionality typically found in a controller/component and not readily available to a model or behavior. So is this best developed as a behavior or a component? Any tips on how to approach by Cake Guru's this would be much appreciated. Thanks in advance.


When using int's as boolean values, is it in poor form to use 0's and 1' directly?

Is it better to do this               #define INT_TRUE 1     #define INT_FALSE 0          int someFunctionalityIsEnabled = INT_TRUE;      or this?               int someFunctionalityIsEnabled = 1;      It can be safely assumed that false will always be zero and true will be non- zero.


If you could only have one programming related book on your bookshelf what would it be and why?

One per answer please. I'll add my favourite as an answer.


Is local "User" rights enough or do developers need Local Administrator or Power User while coding?

We have an offshore development crew who has a bad habit of installing nonsense software on corporate desktops (which has nothing to do with their job function) and so are considering removing their local administrator rights. Is Local Administrator, or local Power User a requirement with VS2010? How do you run without elevated rights? What issues will you run into?


Established antipattern name? Only getting data ducks in a row right before you need them

This one's all over our codebase but I'm not sure I've ever heard a name put to it. We have C# and Java (and Rails but we don't have to touch it very often) so I'll speak more generally. It's like the data concerns never get fully established until you're literally right in a view controller preparing to drop it on the page (note: we're way past the actual SQL queries in most cases here). For instance, we have data for a certain product type coming in from CRMs, from scans done with our mobile app, and pulled up from inventory in DBs and yet somehow it's not until we get to the spot where we're literally about to drop it on the page that we suddenly discover that there's business logic to attend to. Our actions and view controllers are GIGANTIC. We're asking all kinds of questions of every object and branching on them, whether it isThis or hasThat, data sources, customer preferences and sometimes stuff so seemingly arbitrary it might as well be phase of the moon, migration habits of species I've never even heard of, most-googled film stars... And it doesn't always stop at the controller. The Java in particular is notorious for letting it all spill out into the JSP and then even onto the client-side in the JS. This phenomenon has to have a name, but I've never heard it. What is it?


Regaining my spark on a project

So I'm in a little bit of a pickle. I suppose some people have gotten in my situation at some point, I know but at least as many have kept going for various reasons. To put the problem shortly; I am stuck in a project which I have after several attempts of "new fresh attitude" ended up drained out of energy and creativity and been less productive than I wish I were. The scenario is this; I had earlier been handed a, in my opinion, half done project made in Drupal. At first it had really terrible code, but I managed to get them to clean it up a bit first. Needless to say, a poorly constructed house full of used clothes and thrash is still a poorly constructed house even without the used clothes and the thrash. My hope currently is to regain that spark I have for all of my other projects that lets me work effeciently and mainly gets things done. In this case, I have little to none interest in working with this project. Here are some reason:   * The code have quite some room for improvements. The only things that I find acceptable are the things contributed from Drupal, which are simply implemented into this project. Most custom things made in it is nothing I cherish.   * I can't push myself to endure it, because I know this project will be something I'm forced to work with in the long term. In the same way I can't push myself to run the last mile of a marathon faster if I know I have to walk the entire way home afterwards.   * I've read up quite a bit regarding people's opinion upon Drupal, and have came to the conclusion that Drupal is great if you have the right mindset for it. I don't have that mindset.   I prefer to create as much as possible myself and simply let a framework such as CodeIgniter worry about the process. It helps me be more confident with my code and less dependent on a module fetched from somewhere.   * I generally don't believe in the project. It already takes silly long time to load, weird bugs appears from time to time that I can't even solve through google effeciently. It feels like the best thing I can do with the project is to patch it up, but I strive to do great websites, not make bad ones less bad.   * Drupal has a long learning process, and I've been put in the middle of a half made project and am supposed to implemented more advanced features. Usually I have no problem to add these things in my other projects, but in Drupal it feels close to impossible often. Apart from this, I might add that I'm currently economicly independent and don't fear loosing my job for that reason. I generally have nice colleagues but I work alone as a developer and would prefer to have at least someone whom I could discuss technical solutions with. This project isn't something that will go away from my understanding, I've sat down with my boss, explaining how I feel regarding this project but all I get in reply is "We've spend too much time and money on this project. It needs to get completed." From my point of view, we're currently throwing money into a pit, hoping that the money will reach the surface sooner of later. **Question:**   How can I regain the spark for this project? The creativity simply isn't there for me. This project won't give me much knowledge that I will have use of in the future (I have maintained lots and lots of code for 3 years) and it doesn't lead me towards my goal; to create "the perfect website". If I can't regain the spark, what other alternatives should I consider? **Note:**   I am aware that this question can seem too localized, but I think my main question can help many in a similiar position. I'm sorry if I sound like a spoiled developer who only wants to take on specific tasks, but I work _so_ much better with project I'm comfortable with and I also like being productive.


Is there any situation in which it would be appropriate to use unless... else?

This construction is considered wrong               unless       #..     else       #..     end      This is for the general reason of double-negative confusions. It translates to:               if not        #..     if not not       #..     end      _We all agree this is confusing._ * * * Is there any situation (include semantic) that the `unless..else` construction would be more appropriate?


How do you ask or get asked to speak at a software conference?

This is in my TODO.txt. How would you go about achieving this goal?


How should I include third-party models in my domain model?

I'm currently trying to design a little application using Domain Driven Design but I'm afraid I don't really get the concept yet. Let me try to explain this as clearly as possible.               public interface IMyDomainRepository     {         void Add(IAnInterfaceFromAThirdParty element);     }      The interface above is defined in my domain model and this will be used in a different project called `ThirdPartyImplementionVersionX`. Now `IAnInterfaceFromAThirdParty` is not defined in my domain model but comes from my third party library. I could create a class/interface in my domain model which implements the same properties and methods as the interface `IAnInterfaceFromAThirdParty` but this interface has 20 methods defined thus making it a difficult task to implement the same logic. Is this the way to go or am I missing something?


Managing re-usable code in user-centric agile stories?

I work on an agile team at the moment where our stories are written primarily from the user perspective as well as testing. So, for example, we may have a request for a date picker. The story would go something like:               User goes to page x and clicks on date to launch a native date picker      All fine and good, but the problem is how to communicate what that is from a development POV. For example, the issues we'd want to address:   * we have to support multiple devices   * even though the user sees a 'native' widget, we're often having to build emulated versions in JS   * we'd want to be using said widget on many other pages than just x and would want to incorporate variations needed on page y and z into this one component. We're struggling in figuring out how to best handle this to enable the dev team. One option seems to be for our dev team to build our own component and pattern libraries. We'd then take the user stories and use that data to enhance our own component/pattern library. Have you ran into this problem and, if so, have you found a way to consolidate the discrepancies between user stories and the concept of reusable component code for the dev team?


Charles Barkley syndrome

Charles Barkley was an excellent basketball player, a hall of fame, and a dream team member. He played for the 76ers, Suns, and Rockets. Yet he never won an NBA championship. Some might argue this was because he was never surrounded by other players of his caliber, and in the NBA, you can't win on your own. So what does this have to do with programming? How many of you out there feel like Sir Charles? Leading your team in every category, KLOCs, bugs fixed, systems configured... Always the one pushing for improvements, upgrading systems, negotiating with customers... Feeling like you are carrying the team. Anger just under the surface. Only to retire eventually, without "the ring"1. * * * 1: Keep in mind, Charles never blamed his team. He just performed at his best.


Understanding my dvcs workflow

We are going to be building a new project using Mercurial as our version control system. I'm still trying to fully understand what my workflow should look like, so I've listed below a case that I need some help undertanding. A single application with multiple modules (Each module being hosted in its own repository) Multiple developers need to make changes to the same module. How should this be managed?   * Should a hg pull be done and all changes be made on the local developers machine. Once those changes have been made the changes are pushed to dev.   * Should each feature/bug fix get a new repository or branch on the server and the developer pushes his changes from his local hg to the remote hg. Once the feature is completed that repo/branch is merged back into dev.   * Or a combinatiom of both. Small changes go straight into dev, and a feature that could take some time gets its own branch/repo.   * Or any other strategies that you think are better suited.


How valuable are programming conferences?

Inspired by this, just how useful are programming conferences of various types? What do they offer that you can't get from just reading and researching subject online?


Are any companies moving from DVCSs to CVCSs?

Are there any actual business cases that have made any company move from a DVCS to a CVCS (regardless of whether they were on a CVCS originally)?. Other than having a closed mind and rejecting the paradigm shift altogether (for the particular case of companies coming from a CVCS) I cannot think of any cause for this happening. Double chocolate cookie for anyone with empiric evidence.


Constant values in the interface

Some time ago I have read two different books and each of them gives totally different answer for the question if it is a good pattern to define constant values in the interface (in java). So I am curious of your opinions with some reasonable arguments. Is it a good habit/ pattern to define constant values in interfaces in java? Is it generally good, generally bad or it depends?


How do you safely work around broken code?

Once in a while, a co-worker will check-in bad code which blocks my application from initializing properly. To get around this problem quickly, I comment out the offending code. I then forget to uncomment the offending code at the time of my check-in, so I want to prevent this from happening again. Do you have any suggestions on how to:   1. Disable bad code that stop you from working    2. Prevent yourself from checking in unwanted changes? I'm currently using Visual Studio as my IDE and TFS as my source code repo.


Unindented elses

Been writing code since about 18 years now. Lately, I've got into the habit of not indenting elses and when I look at the code it does worry me a bit mostly that someone who might look at the code might cry foul. The snippet below explains the need for the style               if(condition) {        ...     } //1      if(condition) { // Don't want this second block to be entered unnecessarily        ...     }      So I put an else where the comment labelled 1 is               if(condition) {        ...     } else     if(condition) {         ...     }      Putting an else there helps maintain readability especially when forgetting to put one there doesn't necessarily break anything. What I'm uneasy with is that it doesn't strictly follow conventions (Sun's in this case) in two different ways - 1) proper indentation 2) having an open brace after the else I guess what I'm trying to do is prevent having massive indents which really makes a difference in blocks that have a lot of conditions - 5 or more although only three are showcased below.               if(condition) {        ...     } else {        if(condition) {            ...        } else {           if(condition) {               ...           } else {              ...           }        }     }      I find it a lot neater to have the else unindented and without a brace following. What are your thoughts?


How can I implement a database TableView like thing in C++?

How can I implement a TableView like thing in C++? I want to emulating a tiny relation database like thing in C++. I have data tables, and I want to transform it somehow, so I need a TableView like class. I want filtering, sorting, freely add and remove items and transforming (ex. view as UPPERCASE and so on). The whole thing is inside a GUI application, so datatables and views are attached to a GUI (or HTML or something). So how can I identify an item in the view? How can I signal it when the table is changed? Is there some design pattern for this? Here is a simple table, and a simple data item:               #include <string>     #include <boost/multi_index_container.hpp>     #include <boost/multi_index/member.hpp>     #include <boost/multi_index/ordered_index.hpp>     #include <boost/multi_index/random_access_index.hpp>          using boost::multi_index_container;     using namespace boost::multi_index;          struct Data     {       Data() {}       int id;       std::string name;     };          struct row{};     struct id{};     struct name{};          typedef boost::multi_index_container<       Data,       indexed_by<         random_access<tag<row> >,         ordered_unique<tag<id>, member<Data, int, &Data::id> >,         ordered_unique<tag<name>, member<Data, std::string, &Data::name> >       >     > TDataTable;          class DataTable     {     public:       typedef Data item_type;       typedef TDataTable::value_type value_type;       typedef TDataTable::const_reference const_reference;       typedef TDataTable::index<row>::type TRowIndex;       typedef TDataTable::index<id>::type TIdIndex;       typedef TDataTable::index<name>::type TNameIndex;       typedef TRowIndex::iterator iterator;            DataTable() :         row_index(rule_table.get<row>()),         id_index(rule_table.get<id>()),         name_index(rule_table.get<name>()),         row_index_writeable(rule_table.get<row>())       {       }            TDataTable::const_reference operator[](TDataTable::size_type n) const       { return rule_table[n]; }            std::pair<iterator,bool> push_back(const value_type& x)       { return row_index_writeable.push_back(x); }            iterator erase(iterator position)       { return row_index_writeable.erase(position); }            bool replace(iterator position,const value_type& x)       { return row_index_writeable.replace(position, x); }            template<typename InputIterator> void rearrange(InputIterator first)       { return row_index_writeable.rearrange(first); }            void print_table() const;            unsigned size() const       { return row_index.size(); }            TDataTable rule_table;       const TRowIndex& row_index;       const TIdIndex& id_index;       const TNameIndex& name_index;     private:       TRowIndex& row_index_writeable;     };          class DataTableView     {       DataTableView(const DataTable& source_table) {}       // How can I implement this?       // I want filtering, sorting, signaling upper GUI layer, and sorting, and ...     };          int main()     {       Data data1;       data1.id = 1;       data1.name = "name1";       Data data2;       data2.id = 2;       data2.name = "name2";            DataTable table;       table.push_back(data1);       DataTable::iterator it1 = table.row_index.iterator_to(table[0]);       table.erase(it1);       table.push_back(data1);       Data new_data(table[0]);       new_data.name = "new_name";       table.replace(table.row_index.iterator_to(table[0]), new_data);       for (unsigned i = 0; i < table.size(); ++i)         std::cout << table[i].name << std::endl;          #if 0       // using scenarios:       DataTableView table_view(table);       table_view.fill_from_source(); // synchronization with source       table_view.remove(data_item1); // remove item from view       table_view.add(data_item2); // add item from source table       table_view.filter(filterfunc); // filtering       table_view.sort(sortfunc); // sorting            // modifying from source_able, hot to signal the table_view?       // FYI: Table view is atteched to a GUI item       table.erase(data);       table.replace(data);     #endif            return 0;     }


XDIME for Mobile Applications

I'm involved in a project that requires to mobile-enable some previously developed Portlets. The Portlets are deployed in WebSphere Portal, and the container offers a technology called IBM Mobile Portal Accelerator that uses XDIME to render mobile pages according to the device. I'm trying to document myself in the technology and I'm having a bad time: Google only shows some outdated sites from IBM and even older posts from Volantis, another company involved in the technology (Amazon shows no related books). So... what's the current status of that technology actually? Is has some decent level of adoption?


What javadoc equivalents do you use in .net?

Java developers use Javadoc in order to write inline documentation in their comments. What are the alternatives for .net - specifically c# and VB.net that people actually use in real world projects?


Randomized Hash function with no collisions

Related to the question Which hashing algorithm is best for uniqueness and speed? Is there a way to create a hash function, or find one, whose hash length depends completely on the input length, has an adjustable hash character set (Since it must be 1-to-1 function the input must comply to this character set constraint as well). Moreover the most important part is that the hash function generates as **random** as possible strings. So for example it would be possible to get the following two different results.               Hash(aaaa)->blue // for character set a-z      and               Hash(aaaz)->pink  // for character set a-z      More examples:               Hash(aa@12a)->dakj@4   // for character set a-z, @, 0-9      and               Hash(a2#46Ww)->@3#0Pdw // for character set a-z A-Z, !-), 0-9      **Notice** the character length between input and output and the character sets. What I thought so far was a probability distribution function, there are random distribution functions but I am not sure how to get there. http://en.wikipedia.org/wiki/Probability_distribution http://en.wikipedia.org/wiki/Normal_distribution


Why are interfaces more helpful than superclasses in achieving loose coupling?

( _For the purpose of this question, when I say 'interface' **I mean the language construct`interface`**, and not an 'interface' in the other sense of the word, i.e. the public methods a class offers the outside world in order to communicate with and manipulate it._) Loose coupling can be achieved by having an object depend on an abstraction instead of a concrete type. This allows for loose coupling for two main reasons: **1-** abstractions are less likely to change than concrete types, which means the dependent code is less likely to break. **2-** different concrete types can be used at runtime, because they all fit the abstraction. New concrete types can also be added later with no need to alter the existing dependent code. For example, consider a class `Car` and two subclasses `Volvo` and `Mazda`. If your code depends on a `Car`, it can use either a `Volvo` or a `Mazda` during runtime. Also later on additional subclasses could be added with no need to change the dependent code. Also, `Car` \- which is an abstraction - is less likely to change than `Volvo` or `Mazda`. Cars have been generally the same for quite some time, but Volvos and Mazdas are far more likely to change. I.e. abstractions are more stable than concrete types. All of this was to show that I understand what loose coupling is and how it is achieved by depending on abstractions and not on concretions. (If I wrote something inaccurate please say so). **What I don't understand is this:** **Abstractions can be superclasses or interfaces.** **If so, why are interfaces specifically praised for their ability to allow loose coupling? I don't see how it's different than using a superclass.** The only differences I see are: 1- Interfaces aren't limited by single inheritance, but that doesn't have much to do with the topic of loose coupling. 2- Interfaces are more 'abstract' since they have no implementation logic at all. But still, I don't see why that makes such a big difference. **Please explain to me why interfaces are said to be great in allowing loose coupling, while simple superclasses are not.**


How do Traits in Scala avoid the "diamond error"?

_(Note: I used 'error' instead of 'problem' in the title for obvious reasons.. ;) )._ I did some basic reading on Traits in Scala. They're similar to Interfaces in Java or C#, but they do allow for default implementation of a method. I was wondering: can't this cause a case of the "diamond problem", which is why many languages avoid multiple inheritance in the first place? If so, how does Scala handle this?


One controller per page or many pages in one controller?

I just wanted some advice regarding the MVC way of doing things. I am using codeigniter and I was wondering if it's better to have one controller per page for a _website_ or to have one controller for all the pages? Let's say I have a simple website where you can visit the homepage, login, create an account and contact the admin.   1. Would it be better to have these controllers: frontend(index), login, account, contact OR having one controller called frontend or whatever with the actions such login, createAccount, contact?   2. When do you know if its better to use one controller in a situation?


What is the difference between Acceptance Test-Driven Planning and Acceptance Test-Driven Development?

What is the difference between Acceptance Test--Driven Planning and Acceptance Test--Driven Development? Are they the same?


Enterprise VS Regular corporate developer

Ok, I " _almost_ " lost a job offer because I " ** _didn't have enough experience as an enterprise software engineer_** ". I've been a programmer for over 16 years, and the last 12-14 professionally, at companies big and small. So this made me think of this question: What's the difference between a software engineer and an enterprise software engineer? Is there really a difference between software architecture and enterprise architecture? BTW: I try to do what every other GOOD software programmer does, like architecture, tdd, SDLC, etc.


One-week release cycle: how do I make this feasible?

At my company (3-yr-old web industry startup), we have frequent problems with the product team saying "aaaah this is a crisis patch it now!" (doesn't everybody?) This has an impact on the productivity (and morale) of engineering staff, self included. Management has spent some time thinking about how to reduce the frequency of these same-day requests and has come up with the solution that we are going to have a release every week. (Previously we'd been doing one every two weeks, which usually slipped by a couple of days or so.) There are 13 developers and 6 local / 9 offshore testers; the theory is that only 4 developers (and all testers) will work on even-numbered releases, unless a piece of work comes up that really requires some specific expertise from one of the other devs. Each cycle will contain two days of dev work and two days of QA work (plus 1 day of scoping / triage / ...). My questions are: (a) Does anyone have experience with this length of release cycle? (b) Has anyone heard of this length of release cycle even being attempted? (c) If (a) or (b), how on Earth do you make it work? (Any pitfalls to avoid, etc., are also appreciated.) (d) How can we minimize the damage if this effort fails?


Python : how can I impress people coming from Ruby/Java?

I am preparing a presentation about Python for my company, and would like to show Python's awesomeness to developers using Java or Ruby ! I guess it will be very simple to write shorter and cleaner looking stuff than in Java, however I've never coded in Ruby (well only a few stuff with rails, but I don't know the language) ! **PLEASE NOTE** : This topic **IS NOT** about which language is the best. I just want to convince people that don't know Python at all, or even -for some- think that it is weird, that it is worthy of interest as well (as much as Ruby, Java, etc... are). And for this, I need input from people that know Ruby (or Java) and Python ... I'm looking for an easy to understand code snippet or application that would shows where Python shines. I was thinking of a couple of list comprehensions, because I think it is really great. Some operator overriding, because that looks dead simple in Python, maybe some metaclass programming, and/or why not a doctest/sphinx example ... Any other/better suggestions ? PS : the people are backend web developers


"To code quickly, you must quit coding"

First off, not my phrase: http://www.whattofix.com/blog/archives/2010/11/to- code-quickly.php Props to Mr. Markham. BUT, it got me to thinking about a lot of questions I have seen about being able to get things done. The approach advocated (setting a timer for a set period, in this case 50 minutes, but I've seen people talk about breaking procrastination by setting times as short as five minutes on tasks that you just cannot bring yourself to do, and then taking a short break) seems to be common sense, but lots of people advocate getting into the "zone" and staying there as long as possible, maybe many hours, rather than break their groove. I keep trying different approaches and find that each has its own strengths and weaknesses. What kind of technique do you use to be more EFFECTIVE (i.e., getting work done to the quality level demanded by your client / boss / etc. in the time frame allowed) in your software development and not just to spend more time at the keyboard?


Should curly braces appear on their own line?

Should curly braces be on their own line or not? What do you think about it?               if (you.hasAnswer()) {         you.postAnswer();     } else {         you.doSomething();     }      or should it be               if (you.hasAnswer())     {         you.postAnswer();     }     else     {         you.doSomething();     }      or even               if (you.hasAnswer())         you.postAnswer();     else         you.doSomething();      Please be constructive! Explain why, share experiences, back it up with facts and references.


Good practice and terminology of braces

> **Possible Duplicate:**   >  Should curly braces appear on their own line? I've come across two methods of using braces with if/for/switch/while/function blocks in Java, JS, C++, and PHP (any language that uses braces for creating scopeblocks) One of them is like this:                If(...){         ...      }else{       ...      }      I've always used this, it's become an unbreakable habit for me. This leads to compact code, but many people who look at my code get confused because they don't realise that there is an opening brace. I personally call this method 'bouncing braces' (don't know why) The other method is this:                If(...)      {         ...      }      else      {       ...      }      This is less compact, but is clearer. This is what most people seem to expect (from what I've seen--and I've not seen much). If they don't see the opening brace below the if, they think its missing. So I have two questions:   * What are these two practices, (if they have names) called?   * Which one is better practice?


Web versus desktop development - is web development worse?

As a longtime desktop developer looking at doing our first large-scale web application, what are the pros and cons of doing web development? Is developing a web application much worse than developing a desktop app? E.g., is it more tedious or annoying? Is the time to market much worse? Is the web platform excessively limiting? If the answer to any of these is yes, then why? (And how does developing a Flash or Silverlight app compare?)


When is it appropriate to do calculations in front-end?

My team is developing a WEB based finance application and there was a bit of an argument with a colleague where to keep the calculations - purely in back- end or keep some in front-end too? Brief explanation: We are using Java (ZK, Spring) for front-end and Progress 4gl for back-end. Calculations that involve some hardcore math & data from database are kept in back-end, so I'm not talking about them. I'm talking about the situation where the user enters value X, it is then added to the value Y (shown in screen) and the result is shown in the field Z. Pure and simple jQuery-ish operations, I mean. So what would be the best practice here: 1) Add values with JavaScript that saves from going to the back-end and back and then validate them at the back-end "on save"? 2) Keep all the business logic in the same place - therefore bring the values to the back-end and do the calculations there? 3) Do the calculations in the front-end; then send data to the back-end, validate them there, do the calculations again and only if the results are valid and equal, display them to the user? 4) Something else? Note: We do some basic validation in Java but most of it is still in the back- end as all the other business logic. Increase of data that would be sent by recalculating everything in a back-end wouldn't be a problem (small XML size; servers and bandwidth would withstand the increased amount of operations done by users).


How come many project-hosting sites don't have a forum feature?

I'm considering starting an open-source project, so I shopped around some popular project hosting sites. What I find surprising is that many (see here for a nice feature table) of the popular project hosting sites (e.g. GitHub, BitBucket) don't have a forum feature, i.e. a place where users can talk to the devs, ask questions, raise ideas, etc.   IMHO an active forum is an important factor in creating a user community around a project, so I would expect that most project owners would be interested in such a feature. I've also noticed that some projects _do_ have support forums (or mailing lists) hosted elsewhere - e.g. Ruby on Rails is hosted on GitHub but has a Google Groups support group, and TortoiseHG is hosted on BitBucket but has a mailing list on SourceForge - so it's not like this feature is unneeded. So how come many project hosting sites don't have a forum feature?


I'm currently researching the options which I have, to build an 'Online Help System'. This system should offer the user information about dialogs - which consists mainly out of forms. So my main question is: Is there any taxonomy/language to describe user interfaces? I have searched a lot on this subject matter, but end up with things like XUL. Which is not what I'm looking for. I'm looking for a structure / language / taxonomy to describe the user interface (of the dialogs). However, I'm not sure of its existence. Since I'm not, I would also be pleased with any (search) terms which are worth investigating in this case. Besides this, I'm also looking for languages / taxonomies which are used for regular Online Help systems. The things I came across were: DocBook, DITA and MAML. Are there any other big players in this 'market'?


Cloud Newbie ... what should I know while creating my App

I never developed for the Cloud, and to tell you the truth I am not fully 100% sure of what Cloud is when coming down to servers and services. I am starting to develop an App where I will need to be able to scale as needed. The App has a lot of User entries as well as file uploads. Think is as a "forum" (this is the closest model that I can think that applies to my App). User will be able to register, create "threads", create "polls", answer, and vote. They can also upload images, videos, and audio files. The person that previously created the website used 'Auto-increment" fields to keep track of the user ids. while rebuilding the page I was thinking to drop that part and use UUID() for all the users entries, this, I believe might solve the concurrency of entries at the same millisecond or weird locks or duplicate ids or possible other problems... but... other than that, I do not have a clue of what the "cloud" would do. Those are my questions:   * I will use MySQL as DB, will I have to connect to different DBs to write to alleviate the stress or I should not even worry about that because the "cloud" will take care of that? (I will have replication for the reads)   * When accessing files, will I have to know on what server the files where uploaded to be able to serve them, or will the "cloud" magically do that ?   * If I increase the "cloud" space by adding a new server, what should I know about it? simply deploy it and everything is up and running or will I need to do something to my code to tell "hey, there is another instance, now do this and that differently" Thank you and I hope you understood what I meant.


Can I legally publish my Fortran 90 wrappers to Nvidias' CUFFT library (from the CUDA SDK)?

From a legal standpoint (licensing issues), can I legally, in agreement with the license, publish Fortran 90 wrappers (bindings) to the CUFFT library from Nvidia CUDA Toolkit, under some open source license (either CC0, that is, public domain, or some kind of permissive license like BSD)? Nvidia provides only C bindings with their CUDA SDK. Header files contain the following text.               /*      * Copyright 1993-2011 NVIDIA Corporation.  All rights reserved.      *      * NOTICE TO LICENSEE:      *      * This source code and/or documentation ("Licensed Deliverables") are      * subject to NVIDIA intellectual property rights under U.S. and      * international Copyright laws.      *      * These Licensed Deliverables contained herein is PROPRIETARY and      * CONFIDENTIAL to NVIDIA and is being provided under the terms and      * conditions of a form of NVIDIA software license agreement by and      * between NVIDIA and Licensee ("License Agreement") or electronically      * accepted by Licensee.  Notwithstanding any terms or conditions to      * the contrary in the License Agreement, reproduction or disclosure      * of the Licensed Deliverables to any third party without the express      * written consent of NVIDIA is prohibited.      The `License.txt` file includes the following fragment > Source Code: Developer shall have the right to modify and create derivative > works with the Source Code. Developer shall own any derivative works > ("Derivatives") it creates to the Source Code, provided that Developer uses > the Materials in accordance with the terms and conditions of this Agreement. > Developer may distribute the Derivatives, provided that all NVIDIA copyright > notices and trademarks are propagated and used properly and the Derivatives > include the following statement: "This software contains source code > provided by NVIDIA Corporation."


At what point in the process do you create the visual design?

I like to do a wireframe before I start coding and work from there. But when should I start worrying about the visual design? When should I consider the colours, the font, whether corners should be round or sharp, icon design, etc? Is that the last thing to do before launch? Or is there any reason to work on it while you're still in the coding phase, or testing and debugging phase?


What is the role of QA in a BDD-driven project?

If running a project using BDD with 100% coverage of user stories with automated acceptance tests, what would be the role of a tester / quality assurance person? I guess I am imagining that developers would write the acceptance tests in conjunction with the product owner, let me know if that seems like a foolish assumption.


How does requirements management work in the long term with Agile projects?

Requirements Management in the short term for Agile projects seems like a solved problem to me. From the Scrum angle new requirements or changes to existing requirements are delivered through User Stories. And User Stories grouped under an Epic or Feature facilitate the delivery of larger more complex requirements. Of course, a User Story isn't technically a requirements document. It is a manageable grouping of work which maps to what is often called a _Vertical Slice_ of functionality. And the scope of these stories can be defined unambiguously through the use of Acceptance Criteria (AC). So, although User Stories aren't formal requirements, browsing through them can give you a pretty clear idea of their underlying requirements. In the short term. I say in the short term because, as a project progresses, the number of User Stories increases. Thus, browsing through an ever increasing list of Stories to find a Requirement becomes less and less efficient over time. This problem is compounded when you consider User Stories that expand on, supersede, or even negate previous Stories. Now, imagine a 2 year gap between development iterations on a project (stable in production). The original team is gone and so is all their knowledge. If the original team knew this was going to happen (eg, it's the nature of the business), then what measures could they take to help subsequent teams? Sure, the backlog will provide some information, but it's hardly in an easily browsable form. So, what can be done to help subsequent teams understand the state of the project, including _why_ and _how_ it got there? In my experience, the following things don't work:   * **Backlog grooming** to delete or update previous User Stories so that the Backlog can be read as a requirements document.   * **Documentation Sprints** where team members are tasked with documenting the current state of the system.   * **Documentation through Behaviour Tests**. This approach is the only one I have seen come close to working. Unfortunately, Coded Behaviour tests are victims the Naming Problem. Although the tests might properly document the system, getting a fluctuating team of developers to write their tests following the same Domain terminology, wording, and style is almost impossible. So, to reiterate: How does one manage Agile project Requirements in the long term?


Tweaking a ranking algorithm from a few variables

I'm going to have a mySQL table with elements in it and would like to rank them in the same manner than Reddit but not quite. I'd like to know how to add or remove importance to a variable in my ranking algorithm. For instance, what I have is a time (a timestamp, so a huge value) and a number of upvotes (a smallish value, under 50). How do I give more importance to the upvotes and less to the time?


What's wrong with comments that explain complex code?

A lot of people claim that "comments should explain 'why', but not 'how'". Others say that "code should be self-documenting" and comments should be scarce. Robert C. Martin claims that (rephrased to my own words) often "comments are apologies for badly written code". My question is the following: What's wrong with explaining a complex algorithm or a long and convoluted piece of code with a descriptive comment? This way, instead of other developers (including yourself) having to read the entire algorithm line by line to figure out what it does, they can just read the friendly descriptive comment you wrote in plain English. English is 'designed' to be easily understood by humans. Java, Ruby or Perl, however, have been designed to balance human-readability and computer- readability, thus compromising the human-readability of the text. A human can understand a piece of English much faster that he/she can understand a piece of code with the same meaning (as long as the operation isn't trivial). So after writing a complex piece of code written in a partly human-readable programming language, why not add a descriptive and concise comment explaining the operation of the code in friendly and understandable English? Some will say "code shouldn't be hard to understand", "make functions small", "use descriptive names", "don't write spaghetti code". But we all know that's not enough. These are mere guidelines - important and useful ones - _but they do not change the fact that some algorithms are complex._ And therefore are hard to understand when reading them line by line. Is it really that bad to explain a complex algorithm with a few lines of comments about it's general operation? What's wrong with explaining complicated code with a comment?


Would you rather make private stuff internal/public for tests, or use some kind of hack like PrivateObject?

I am quite a beginner in code testing, and was an `assert` whore before. One thing worrying me in unit testing is that is often requires you to make `public` (or at least `internal`) fields that would have been `private` otherwise, to un-`readonly` them, make `private` methods `protected virtual` instead, etc... I recently discovered that you can avoid this by using things like the PrivateObject class to acces anything in an object via reflection. But this makes your tests less maintainable (things will fail at execution rather than compile time, it'll be broken by a simple rename, it's harder to debug...). What is your opinion on this ? What are the best practices in unit testing concerning access restriction ? edit : consider for instance that you have a class with a cache in a file on disk, and in your tests you want to write to memory instead.


Is there a canonical book on C Programming in GNU/Linux?

I am looking for a good ebook (or two) for learning the C programming language, specifically programming in a GNU/Linux environment. I'm not a beginner programmer, but I have almost no experience in this particular area. I need to learn both the fundamentals of C and the GNU toolchain (gcc, gdb, and make). For the C language side, I know K&R comes highly recommended, but it doesn't seem particularly practical for me given that it won't describe modern best practices, current libraries, or any particulars about GNU/Linux programming. Is there a book out there that's the de-facto standard for describing best practices, design methodologies, and other helpful information on C Programming in GNU/Linux and covering the GNU toolchain? What about that book makes it special?


Bluetooth or Bump API for membership card functionality?

I am looking to implement membership card functionality inside a mobile application for a local coffee shop. The idea is to make payments at the point of sale, and deduct the amount from the client's prepaid account. I was looking into NFC functionality, but only a few devices support them (and most are not available in Montreal yet). The other idea is to use the Bump API, which would work great for iOS and Android. The last resort would be to use Bluetooth somehow. Any thoughts on any of these approaches, or for those who have tried this, any pros and cons for these ideas.


Implementing basic data structures in programming interviews

I have been preparing to do my first technical interview in a month, and I have a question about implementing common data structures like stacks or linked lists. I plan to do the interview in either Python or Java but I am not sure which one to use yet. I was practicing and tried to implement a stack in Python, using already built-in lists. However, lists in Python already have all stack methods, while there is still some work to do when arrays in Java are used to implement a stack. If I am asked to implement a stack and my language of choice is Python, what should I do? Should I define Node class? Would I not even be asked to implement such low-level data structure in Python anyway?


Is duplicate syntax for defining named functions a bad language design decision?

I am modelling a programming language for fun, and the syntax is heavily influenced by Scala - specifically function definitions. I have encountered a design problem because my language **does not differentiate** between functions defined via the `def` syntax (class methods) and anonymous functions assigned to values (created using `=>`) - it removes the differences in both implementation and behaviour. The result is that the following two definitions mean the same thing:               def square(x: Int) = x*x          val square = (x: Int) => x*x      There is no reason for the latter form (immediate anonymous function assignment) to be used in any normal situation - it's simply _possible_ to use it instead of the `def` form. **Would having such duplicate syntax for defining named functions hurt the orthogonality of the language or some other design aspect?** I prefer this solution because it allows for short and intuitive definitions of methods and named functions (via `def`), and short definitions of anonymous functions (using `=>`). Edit: **Scala _does_ differentiate between the two** \- anonymous functions are not the same as methods defined with `def` in Scala. The differences are relatively subtle though - see the posts I linked before.


How to handle sorting of complex objects?

How would one sort a list of objects that have more than one sortable element? Suppose you have a simple object `Car` and car is a defined as such:               class Car {         public String make;         public String model;         public int year;         public String color;         // ... No methods, just a structure / container     }      I designed a simple framework that would allow for multiple `SortOption`s to be provided to a `Sorter` that would then sort the list.               interface ISorter<T> {         List<T> sort(List<T> items);         void addSortOption(ISortOption<T> option);         ISortOption<T>[] getSortOptions();         void setSortOption(ISortOption<T> option);     }          interface ISortOption<T> {         String getLabel();         int compare(T t1, T t2);     }      Example use               class SimpleStringSorter extends MergeSorter<String> {         {             addSorter(new AlphaSorter());         }              private static final class AlphaSorter implements ISortOption<String> {             // ... implementation of alpha compare and get label         }     }      The issue with this solution is that it is not easily expandable. If car was to ever receive a new field, say, currentOwner. I would need to add the field, then track down the sorter class file, implement a new sort option class then recompile the application for redistribution. Is there an easier more expandable/practical way to sort data like this?


What is the benefit of switching on Strings in Java 7?

When I was starting to programme in Java, the fact that switch statements didn't take strings frustrated me. Then on using Enums, I realised the benefits that you get with them rather than passing around raw values — type safety (which brings easier refactoring) & also clarity to other developers. I'm struggling to think of a situation where with SE7 I'll now decide to use a switch with strings as inputs rather than Enums. If they are implemented via switching on whole strings (e.g. rather than partial or regex matches), it doesn't seem to offer less reason for the code to change. And with IDE tools and the read-write ratio of coding, I'd be much happier auto-generating an extra Enum than passing around string values. What benefit do they bring to us as programmers? Less boiler-plate? It doesn't feel like the language was crying-out for this feature. Though maybe there's a use-case I'm overlooking.


Real-World node.js

I am 14 years old, and have been studying web/app/software development. I am trying to learn a backend language, and am considering node.js. I have heard awesome things about it, plus I like that fact that I can already use the JS I know in it. However, I am concerned that it may just be a "trendy/hip" technology, and that it may not be being used in the real-world that much. Are people really applying node.js in production? Or is it just hip right now?


What do you call a cron that cksums all your files and writes them to a database?

It is a way to take inventory of many cgi scripts and web applications in a Software Service environment. It will be a way of creating changelogs and to keep track of which customers have which programs and will use diff and cksum to notice, compare and identify versions. It "takes inventory", but we actually have inventory systems for non software companies (distributors, etc). So I would prefer not to have confusing names. Edit: We do not use a code repository. So this is not as much for compromised file checking (although it is pretty cool that will be covered), but it is really more as a replacement for a repository and as a way to keep track of which customers have what products to make sure we don't get out of sync with billing. We actually make most of our modifications live. Since these are not public systems, it does not matter that much. If it is public, we either create copies of the program or we run the program on a PC and then test it and then upload it to be live.


Unit testing data access objects

I have recently started using test-driven development and unit testing, and it has paid off immensely in the areas where I have aplied it. One area that it has been helpful in is database access. When I abstract away the data access, the testing of methods that need the data become almost ridiculously easy. However, I haven't been able to find or figure out a way to test the DAOs themselves. (It would be self-defeating to abstract them out!) A DAO should in theory just move data back and forth between the database and the application; can this be considered too simple to test? I have experimented with setting up a Derby database on my local machine for tests, but it's difficult to automate starting the server, creating the databases, and creating the tables. Is there any way to automate testing of data access objects?


Why does the Scrum guide say no testers?

I have been reading the Scrum Guide from scrum.org and it says: > Development Teams do not contain sub-teams dedicated to particular domains > like testing or business analysis. In its literal translation this means that there are no testers which is confusing. How can they be suggesting this?


When using an ORM should mappings be defined in the code file?

Doctrine offers three ways to define the object mapping properties: in XML, in YAML and as inline docblock annotations in the code. The Doctrine documentation doesn't give any advice on choosing among them, but I'm specifically wondering if there is a generally accepted for best practice with regard to keeping mapping metadata for an ORM system in the file where the objects are defined versus keeping it in a separate data file. Is there?


How to create in Python Tkinter a widget that would act like a choice tree?

I would like to know if there is such widget in tk (or in any different standard Python 3 module), or how to create it: ![enter image description here](http://i.stack.imgur.com/sg5g9.png) Of course it doesn't have to look like this, but it should offer same functionality. Unfortunately PyQT, wxWidgets or any other non standard modules I cannot use.


What unit test frameworks exist for Java?

I've used TestNG and JUnit. What other frameworks are out there? What makes them special and/or different from the rest?


FP and OO orthogonal?

I have heard this time and again and I am trying to understand and validate the idea that FP and OO are orthogonal. First of all, what does it mean for 2 concepts to be orthogonal ? FP encourages immutability and purity as much as possible. and OO seems like something that is built for state and mutation(a slightly organized version of imperative programming?). And I do realize that objects can be immutable. But OO seems to imply state/change to me. They seem like opposites. Does that meant they are orthogonal ? A language like Scala makes it easy to do OO and FP both, does this affect the orthogonality of the 2 methods ?


Test Driven Development: A good/accepted way to test file system operations?

I am working on a project at the moment that generates a table (among other things) based on the contents of a file-system, and and in turn does some meta-data modifications on the things it finds. The question is: how should tests be written around this, or set up? Is there a easy way to mock this out? Or should I setup a "sandbox"?


Solution organisation

I have been working on asp.net applications for 6 years but almost all of it has been extending and maintaining existing applications. I now have the need to develop a new application and I am scratching my head :( There is a lot of material on Software Design principles and patterns but not much content on organisation. Should the various layers be in separate namespaces, folders or projects? I do have plan to create WCF in future so having Service layer as project makes sense but I am unsure of how many projects I should have? By default, MVC 3 web site has Models and Controllers in the same project does it make sense to separate them to different projects? I would be very very appreciative if someone can post screen shot of well organised MVC 3 solution. I understand this probably depends on personal preference and project size but I need some kind of guidance. Our main application has over 70 projects in a mammoth solution...Please help me avoid this. Many thanks.


Does a License Change for OSS cover all versions, including previous releases?

If we decide to use a piece of open sourced software that is currently released under a license that allows inclusion in an internal closed source system, what protection are we offered if the owners of the open source software decide to change the license? Typically I'm thinking of where the new license does not allow inclusion in closed source software (I think the PDF generation api iText did this back in 2009). Can the new license be applied retrospectively to the old versions? I'm guessing it can, but often isn't. We are just looking at worst case scenario, would we be in a position where we could just continue using an old version for as long as it suited and then make a decision about the future - or would we be in a position where we'd have to decide to either pay the commercial fee that is often available or find a different "free" alternative.


If I want my client program to be free software, do I also have to release the server software as free software?

Imagine I've written a game and I want to make it free software. Am I also required to make the game server software free software because the game uses it to connect to other players to play against? Imagine I've written a stock ticker and I wish to make it free software. Can I charge for the subscription to the stock information, even though the software serves little purpose without paying for such a subscription? I'm also interested in revenue sources for free software that go beyond charging for distribution or support, that counteract one person purchasing your software and then distributing it themselves and undercutting your prices.


Does understanding functional programming help in understanding popular javascript libraries?

I am not experienced in javascript. I try to use some popular javascript libraries such as jQuery, Angular.js and Meteor.js. I wonder if understanding the logic of functional programming (in javascript of course) will help in understanding and using these libraries better?


Unit test strategy for layered (or derived) method calls

Forgive the title -- it needs work. I am struggling to find better English to express my issue. Edits encouraged. Example to describe my issue: ## Checker Method I have an argument checking method called `public static void StringArgs.checkIndexAndCount(String, int, int)`. Given a string, an index, and a count, confirm the string is not null, and the index & counts are reasonable. Unchecked (runtime) exceptions are used to report errors. There is a battery of unit tests written to check all angles of this method. ## Layered (or Derived) Method The checker method is called by other methods, such as `public static String removeByIndexAndCount(String, int, int)`. The first line of this method checks the arguments by calling the above checker. ## Unit Test Strategy When I write unit tests for the second/layered/derived method, how do I account for the existing set of unit tests for the checker method? It seems to violate duplication/copy-paste principles to simple re-add the same unit tests (modified slightly) from the checker method to the second method. Please advise. My code is Java, but I don't think that particularly relevant, as this same issue could occur in any language.


How do we call database table entity in Java?

For each database table, I create an entity (object) which contains all columns of the database as Class fields. Now, how do we call these entities in Java? I could not find an official term so I read on forums that people refer to them as `entities`, `models`, etc. I'd like to know either Java standardized term or Java community accepted term.