Why does the new ADT create a static inner class Fragment by default?

Honestly, I can't help but feel that this is done merely to confuse newcomers. Most of the errors on Stack Overflow by complete Android newbies mostly stem from that they have a static inner class Fragment that they don't understand how it works, why it's there, and try to use Activities even though they don't fully understand the concept behind what is happening. I must admit, I had trouble understanding the "PlaceholderFragment" approach too, and using static inner classes isn't really extensible at all. The first thing you'd have to do is create an actual class outside - but why do newbies have to do that? I think this could be much more efficient if they used a project structure similar to the following simple fragment-based android project structure:   * src      * wholepackagename        * activity          * MainActivity       * fragment          * FirstFragment         * SecondFragment   * res      * layout     * values     * ... With the code of src/wholepackagename/activity/MainActivity:               public class MainActivity extends FragmentActivity implements FirstFragment.Callback     {         @Override         protected void onCreate(Bundle savedInstanceState)         {             super.onCreate(savedInstanceState);             setContentView(R.layout.activity_main);                  getSupportFragmentManager().addOnBackStackChangedListener(new OnBackStackChangedListener()             {                 public void onBackStackChanged()                 {                     int backCount = getSupportFragmentManager().getBackStackEntryCount();                     if (backCount == 0)                     {                         finish();                     }                 }             });                  if (savedInstanceState == null)             {                 getSupportFragmentManager().beginTransaction().add(R.id.main_container, new FirstFragment()).addToBackStack(null).commit();             }         }              @Override         public void firstFragmentCallback()         {             getSupportFragmentManager().beginTransaction().replace(R.id.main_container, new SecondFragment()).addToBackStack(null).commit();         }     }       src/wholepackagename/fragment/FirstFragment.java:               public class FirstFragment extends Fragment implements View.OnClickListener     {         private Callback callback;              private Button firstFragmentButton;              public static interface Callback         {             void firstFragmentCallback();         }              public FirstFragment()         {             super();         }              @Override         public void onAttach(Activity activity)         {             super.onAttach(activity);             try             {                 callback = (Callback) activity;             }             catch (ClassCastException e)             {                 Log.e(getClass().getSimpleName(), activity.getClass().getSimpleName() + " must implement Callback interface!", e);                 throw e;             }         }              @Override         public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)         {             View rootView = inflater.inflate(R.layout.fragment_first, container, false);             firstFragmentButton = (Button) rootView.findViewById(R.id.fragment_first_button);             firstFragmentButton.setOnClickListener(this);             return rootView;         }              @Override         public void onClick(View v)         {             if(v == firstFragmentButton)             {                 callback.firstFragmentCallback();             }         };     }      src/wholepackagename/fragment/SecondFragment.java:               public class SecondFragment extends Fragment implements View.OnClickListener     {         private Button secondFragmentButton;              public SecondFragment()         {             super();         }              @Override         public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)         {             View rootView = inflater.inflate(R.layout.fragment_second, container, false);             secondFragmentButton = (Button) rootView.findViewById(R.id.fragment_second_button);             secondFragmentButton.setOnClickListener(this);             return rootView;         }              @Override         public void onClick(View v)         {             if(v == secondFragmentButton)             {                 Toast.makeText(getActivity(), "This is an example!", Toast.LENGTH_LONG).show();             }         };     }      Android-Manifest.xml:               <?xml version="1.0" encoding="utf-8"?>     <manifest xmlns:android="http://schemas.android.com/apk/res/android"         package="wholepackagename"         android:versionCode="1"         android:versionName="1.0" >              <uses-sdk             android:minSdkVersion="8"             android:targetSdkVersion="19" />         <application             android:allowBackup="true"             android:icon="@drawable/ic_launcher"             android:label="@string/app_name"             android:theme="@style/AppTheme" >             <activity                 android:name="wholepackagename.activity.MainActivity"                 android:label="@string/app_name">                 <intent-filter>                     <action android:name="android.intent.action.MAIN" />                     <category android:name="android.intent.category.LAUNCHER" />                 </intent-filter>             </activity>         </application>          </manifest>      res/layout/activity_main.xml:               <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"         xmlns:tools="http://schemas.android.com/tools"         android:id="@+id/main_container"         android:layout_width="match_parent"         android:layout_height="match_parent" />      res/layout/fragment_first.xml:               <?xml version="1.0" encoding="utf-8"?>     <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"         android:layout_width="match_parent"         android:layout_height="match_parent" >              <Button             android:id="@+id/fragment_first_button"             android:layout_width="wrap_content"             android:layout_height="wrap_content"             android:layout_centerInParent="true"              android:text="@string/first_button" />          </RelativeLayout>      res/layout/fragment_second.xml:               <?xml version="1.0" encoding="utf-8"?>     <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"         android:layout_width="match_parent"         android:layout_height="match_parent" >              <Button             android:id="@+id/fragment_second_button"             android:layout_width="wrap_content"             android:layout_height="wrap_content"             android:layout_centerInParent="true"             android:text="@string/second_button" />          </RelativeLayout>      res/values/strings.xml:               <?xml version="1.0" encoding="utf-8"?>     <resources>         <string name="app_name">Application name</string>         <string name="hello_world">Hello world!</string>         <string name="action_settings">Settings</string>         <string name="first_button">First Button</string>         <string name="second_button">Second Button</string>     </resources>            To me, it seems that the static inner class Fragment doesn't really support any kind of maintainability, it's hard to see what is going on, and the overall functionality is not obvious as the Activity and Fragment (display of fragment and logic) are mixed together, which makes it hard to see and oversee for a newbie. I believe it would provide an easier entry into developing for the Android platform to have an example like above. Are there any benefits to the current approach, providing a static inner class as a Fragment?


How to build an API on top of an existing Rails app with NodeJs and what architecture to use?

## The explanation I was recently hired by a company that has an old RoR 2.3 application with more than 100k users, a strong SEO strategy with more than 170k indexed urls, native android and ios applications and other custom-made mobile and web applications that rely on a not so good API from the same RoR app. They recently merged with a company from another country as an strategy to grow the business and the profit. They have almost the same stats, a similar strategy and mobile apps. We have just decided that we need to merge the data from both companies and to start a new app from scratch since the RoR app is to old and heavily patched and the app from the other company was built with a custom PHP framework without any documentation. The only good news is that both databases are in MySQL and have a similar structure. ## The challenge I need to build a new version that:   * can handle a lot of traffic,   * preserves the SEO strategies of both companies,   * serve 2 different domains,   * and have a strong API that can support legacy mobile apps from both companies and be ready for a new set of native apps. I want to use RoR 3.2 for the main web apps and NodeJs with a Restful API. I know that I need to be very careful with the mobile apps and handle multiple versions of the API. I also think that I need to create a service that can handle a lot IO request since the apps is heavily used to create orders for restaurants at a certain time of the day. ## The questions With all this in mind:   * What type of architecture do you recommend me to follow?   * What gems or node packages do you think will work the best?   * How do I build a new rails app and keep using the same database structure?   * Should I use NodeJS to build an API or just build a new service with Ruby? I know that I'm asking to much from you guys, but please help me by answering any topic that you can or by pointing me on the right direction. All your comments and feedback will be extremely appreciated! Thanks!


Combining version numbers of app components

I have an app that is made up of multiple different components, each with their own version number and history. I would like to create a version number of the entire application, preferably somehow based on the version numbers of the components. I am not sure if this is possible at all, but I would like:   * The version number be unique for each version of the components, so that when I upgrade the version number of one of the components, the version number of the whole app will change as well, and the number must not be ambigous so that it could refer to some other constellation of components.    * It would be nice if there was a way to reverse the process to go from a combined version number to see what versions of components it consists of.    * It is also nice if the combined version number is not too long to remember   * It's a plus if the combined version number always increases with the increase of a component version number.  I am aware that some of these desires are not possible to accomodate together (such as short AND reversable since you would lose information when shortening) The easiest approach is of course to just add the version number together in a long row, but that would be too long to be practical. Another is to create some kind of hash, but it would not be very readable. Is there a standard way of doing this? Or will I have to name the major version manually and take note of what component versions it consists of?


Are the National Computer Science Academy certifications worth it?

I have a question regarding the real value of having NCSA's certifications. Today I reach their site and I easily passed the JavaScript certification within minutes, but I never reach questions related to Literal Javascript Notation (Json), closures or browser specific APIs. This facts let me to doubt a bit of the real value of the test (and the proper certification you can have if you pay them $34), but maybe Im wrong and just earned a respected certification within the States for easy questions... in which case I can spend some time doing other certifications on the same site. Did you have an NCSA certification and think is worth having it in your resume, or you know of a better certification program?


Opera for web development

Many developers recommend Firefox for web development for a variety of reasons. But, after looking at Opera, it seems to me that Opera has all of the same web development functionality that Firefox has built into it. So what is wrong with Opera for web development?


Should I start a project I am hoping to recruit others to?

I have an idea for a program that I think is a good one (Don't we all?). I am an amateur programmer and would like to recruit some more advanced programmers onto the project since there are some aspects that I am not skilled enough to do myself. Is it better to a) Develop the software on my own as much as I can, even though it will be amateurish, and then show a demo to potential recruits or b) Try and recruit some more advanced programmers and seek their advice and guidance before I get started so that it is done correctly from the beginning? I would especially love it if someone has any experience of being in a similar position, but sage speculation is welcome too.


Not Invented Here - what does it take to not succumb to it?

I will start with one, which however did not work the way I wanted. Vendor Evaluation:   In the beginning of the project, we spent some time to do a survey of existing open-source libraries that can be used as building blocks for a larger library. Despite our efforts, there were a number of libraries which we did not come across until several months into the project. Had we found out those missed libraries earlier, we might have made our design decisions differently. Architecture Compatibility:   It was understood from the very beginning that no single library could have satisfied all requirements, so several existing libraries are needed, along with some custom implementation to fill the gaps. These libraries would have to be wrapped into a single architecture so that the users will not need to know the internal construction of the library. Efficiency (in multiple aspects; can be summarized as "no CPU time, RAM nor Disk space can be wasted") was the main driving force in the architectural design; so the wrappers need to be equally efficient. In the beginning we did not know which open-source library would be _compatible_ with the design (in the sense that the wrapper does not introduce any inefficiency of its own), as that would have required some pioneering work to find out. Code quality:   One of the open-source library was about 20 years old. Another library was about 10 years old. In the prevailing thinking of open-source library, the older library is supposed to be more stable and have fewer bugs. Eventually we discovered that the opposite was true, and we ended up having to fix a number of bugs in the older library. My original hypothesis is that "Does it take a lot of intelligence to not succumb to it? Does it take a lot of experience?" but after reviewing the project, I came to the conclusion that software reuse is like matchmaking - any notion of "missed opportunity" occurs naturally due to chance, and no amount of intentional effort will reduce missed opportunities. What does it take to not succumb to Not Invented Here syndrome, in order to achieve the highest degree of software reuse and at the same time satisfying the software requirements perfectly? **Added (2010/12/18)** One of the reason we missed a good candidate library was that it was ruled out very early in the process. When there are more than 10 libraries in the initial list, there is some pressure to find rules that can quickly eliminate some of the candidates, because otherwise we would have spent too much time analyzing (analysis paralysis). However, this fast-track elimination caused the undesirable effect of rejecting one good library. (just like hiring?)


Is this a valid implementation of the repository pattern?

I've been reading up about the repository pattern, with a view to implementing it in my own application. Almost all examples I've found on the internet use some kind of existing framework rather than showing how to implement it 'from scratch'. Here's my first thoughts of how I might implement it - I was wondering if anyone could advise me on whether this is correct? I have two tables, named CONTAINERS and BITS. Each CONTAINER can contain any number of BITs. I represent them as two classes:               class Container{         private $bits;         private $id;         //...and a property for each column in the table...              public function __construct(){             $this->bits = array();         }               public function addBit($bit){             $this->bits[] = $bit;         }              //...getters and setters...     }          class Bit{         //some properties, methods etc...     }      Each class will have a property for each column in its respective table. I then have a couple of 'repositories' which handle things to do with saving/retrieving these objects from the database:               //repository to control saving/retrieving Containers from the database     class ContainerRepository{              //inject the bit repository for use later         public function __construct($bitRepo){             $this->bitRepo = $bitRepo;         }              public function getById($id){             //talk directly to Oracle here to all column data into the object                   //get all the bits in the container             $bits = $this->bitRepo->getByContainerId($id);             foreach($bits as $bit){                 $container->addBit($bit);             }                  //return an instance of Container         }              public function persist($container){           //talk directly to Oracle here to save it to the database             //if its ID is NULL, create a new container in database, otherwise update the existing one                  //use BitRepository to save each of the Bits inside the Container             $bitRepo = $this->bitRepo;             foreach($container->bits as $bit){                 $bitRepo->persist($bit);             }         }     }          //repository to control saving/retrieving Bits from the database     class BitRepository{         public function getById($id){}         public function getByContainerId($containerId){}         public function persist($bit){}     }      Therefore, the code I would use to get an instance of Container from the database would be:               $bitRepo = new BitRepository();     $containerRepo = new ContainerRepository($bitRepo);     $container = $containerRepo->getById($id);      Or to create a new one and save to the database:               $bitRepo = new BitRepository();     $containerRepo = new ContainerRepository($bitRepo);          $container = new Container();     $container->setSomeProperty(1);     $bit = new Bit();     $container->addBit($bit);     $containerRepo->persist($container);      Can someone advise me as to whether I have implemented this pattern correctly? Thanks!


Where did Java go wrong on the client?

Not talking about the recent Java/Oracle debacle here, but something I've been wondering recently. When I first started programming, Java was the big thing client-side, however these days you hardly ever see a Java applet whereas Flash and Javascript are ubiquitous. Where did Java go wrong? Did Sun decide to concentrate on the server-side and let client-side stagnate? How did Flash become dominant over Java? Flashy (no pun intended) graphics? Marketing? Never having been a Java developer, I've not followed this closely so I'm interested to hear your thoughts.


Does anyone else feel that iterator syntax sugar is a must have in a modern language?

I work with C# professionally and I write code like this all the time.               private IEnumerable<Something> GetAlotOfSomething()     {         if (somethingA.IsReady)             yield return somethingA;          if (somethingB.IsReady)             yield return somethingB;          if (somethingC.IsReady)             yield return somethingC;               // ... More complex logic     }          var specialSomethings =          GetAlotOfSomething()         .Where(s => s.IsSpecial);       Then one day I have to write a bit of VB6 or JScript and I end up writing so much boilerplate just to get things done. Anyone thoughts?


How much does the calibre of a Masters program matter to an employer?

The following two examples are hypothetical, but have a possibility of both becoming real (I'm a recent graduate with no CS work experience). In both situations I would be going for my Masters in computer science. **A** : I work for a pretty well-known insurance company writing software. They pay for me to go to school, and the school I would be going to does research in fields I'm interested in (though, with a full time job, I'm not sure how much research I'd be able to participate in), but they are not ranked highly (in fact, I can't find their ranking at all). **B** : A decently ranked school (top 75) offers a research or TA position that covers tuition and a stipend. The school does research in areas that I am interested in. In both situations tuition isn't a problem. The benefit of A is that I get work experience, but the school isn't highly ranked in CS (although it is quite well-known for other majors) and I'm not sure how much research I'd be able to participate in while working full time. With B I would get to do research, and the school is more well-known, but I would forfeit work experience. If my ultimate goal is to end up working for a high-end software developer (Microsoft, Google, Apple, etc.), would option A or B be better?


How important is membership in industrial or professional organizations?

I recieved free membership to the Australian Computer Society when they granted me a scholarship/arranged an internship. With that internship, I have my first real world experience as an software engineer. I haven't yet taken advantage of my membership in any real way, other than enjoying their periodical, which is semi-nontechnical. Now, I'm considering joining something more international and/or serious, such as the Association for Computing Machinery (ACM) or IEEE. How important is it as a software engineer to be a member of an industrial or professional organization? What benefits do such memberships grant you, in terms of exposures to new technologies and connections with future employers?


How will C# 5 async support help UI thread synchronization issues?

I heard somewhere that C# 5 async-await will be so awesome that you will not have to worry about doing this:               if (InvokeRequired)     {         BeginInvoke(...);         return;     }     // do your stuff here      It looks like the callback of a await operation will happen in the original thread of the caller. It has been stated several times by Eric Lippert and Anders Hejlsberg that this feature originated from the need to make UIs (particularly touch device UIs) more responsive. I think a common usage of such feature would be something like this:               public class Form1 : Form     {         // ...         async void GetFurtherInfo()         {             var temperature = await GetCurrentTemperatureAsync();             label1.Text = temperature;         }     }      If only a callback is used then setting the label text will raise an exception because it's not being executed in the UI's thread. So far I couldn't find any resource confirming this is the case. Does anyone know about this? Are there any documents explaining technically how this will work? Please provide a link from a reliable source, don't just answer "yes".


Would a computer engineering degree involve complex event processing?

I've recently discovered the awesomeness of Complex event processing. Just reading the wikipedia page gave me chills on how this technology could be used and evolved into something very powerful. I'm currently a second year computer engineering student, and I was wondering if what I'm doing could ever get me a job involving complex event processing. If not, can one "have" omplex event processing as a hobby or does it require way too much power and resources?


What kinds of projects is SCRUM considered to be suitable for?

I have been using SCRUM in three different projects over the last four years. One of SCRUM's advantages seems to be its flexibility and adaptability, e.g. wrt to changing customer requirements. Another advantage is that management can easily track the progress of a project. SCRUM's flexibility can be an advantage e.g. when implementing a web application, where the requirements change very fast and the customers really understand what they want after they've seen a prototype. On the other hand there are other kinds of software projects (e.g. in aerospace industry) where the requirements are pretty fixed: you get a requirement specification document and you have to come back six months later with working software and complete documentation. For this kinds of projects I doubt that the flexibility offered by SCRUM is needed (in the sense that you do not need to build prototypes and show them to the customer to get feedback on the requirements): you rather need a very structured and systematic approach, which is probably repeated over and over again for each project with little room for surprise. So is SCRUM considered by its proponents a general-purpose software development methodology or is it considered especially suited for certain categories of projects or application areas? For example, I recently looked at the website of a company producing software for the aerospace industry and noticed that they are using the V-model. Would a SCRUM proponent say that SCRUM is less suited for this kind of projects or rather suggest that this company should try switching to SCRUM? **Note** that I am not asking for the opinion of the readers of this forum, but I want to know what is the established opinion among SCRUM proposers: is SCRUM considered general-purpose or rather suitable for certain classes of projects only? In the latter cases, for what kinds of projects?


What makes resources "expensive"?

I am reading hibernate and I came across statements like "JDBC connections open across multiple requests is not a good thing because it is an expensive resource ". What is meant by expensive resource ? Edit : I am adding what user unknown has added as a comment below . If establishing a database connection is expensive , then why not use the same thing again and again (not caching) , instead of closing it and opening it everytime ?


Serverless protocol

Ok programmers, here's one for you. I'm writing an open source IM client/protocol as a learning exercise and to scratch my itch about some problems with current protocols. However, I'm poor. I do run a server but off the back of my own low-bandwidth residential connection (which I would rather -not- saturate by running an IM server on it). I was thinking about the problem and looked into various alternatives (this was before I considered writing my own client/protocol) but there's nothing which doesn't require -any- server hardware. The reason for this is fairly obvious, in order to keep contact lists persistent and synchronous, the simplest solution is to store them remotely and have the user download their contact list each time they log in. One solution I did consider was storing the contact list information on USB flash drives but that is far from ideal (not least because I don't have one myself). Another option would be to implement a peer discovery network similar to bonjour, but that would not provide a contact list of your friends, just a contact list of everyone else who's online. More feasible than the USB idea, but the function isn't ideal in this case. Does anybody have any other ideas for a serverless IM protocol?


Generic decorator implementation

I have the following pattern, which I would like to implement using some kind of generic programming, but I do not see how I can do it. I have an interface I containing many methods with different signatures. Each method has a return type of some class type and any implementation should return null on failure, or a concrete object on success. Now I have a concrete implementation A of I, and a decorator class D of A. For each method               T m(T1 p1, ..., Tn pn)      defined by the interface I, the implementation of m in D follows a fixed pattern:               class D     {         private A impl = ...;              ...              T D.m(t1 p1, t2 p2, ..., tn pn)         {             init();                  T result = impl.m(p1, ..., pn);             if (result != null)                 successCode();             else                 failureCode();                  return result;         }     }      The calling code uses the decorator as follows:               I instance = DecoratorFactory.createIDecorator();     T r        = instance.m(p1, ..., pn);      Question: Is there a way to implement this kind of decorator in a generic way (without writing the same boilerplate for each method)? Can this be done in Java? If it is not possible to implement this pattern in Java, is there an elegant way to implement it in another language?


Non-trivial get function, should it be named differently

For example I have this code.               class Command {              var $responseFactory;         var $service;              /**          * Returns the class name of the responseFactory if it is set           * or the default class name for the responseFactory of the service if it is set.           */         public function getResponseFactory(){             if ($this->responseFactory != null) {                 return $this->responseFactory;             }                  if ($service != null) {                 return $service->getResponseFactory();             }                  return null;         }     }      Although it is fine by itself it could lead to someone being surprised in the future if they cloned a Command object, changed it's `service` property which then 'magically' changes the results of `getResponseFactory`. The counter argument for why it should be named just `getResponseFactory` is 'duh, of course the internal behaviour of the class should be a black box`. Should non-trivial `get` functions be called differently to indicate that they are not a trivial getter? _Edit_ Just to clarify the return type is the same if it is the `Command` responseFactory that is returned or the `Service` responsefactory.


bug: deviation from requirements vs deviation from expectations

I am not clear on this one. No matter the terminology, in the end the software fault/bug causes (according to a lot of sources): > Deviation from requirements   >  Devation from expectations But if the expectations are not in requirements, then stakeholder could see a bug everywhere as he expected it to be like this or that..So how can I really know? I did read that specification can miss things and then of course its expected but not specified (by mistake).


Creating experimental database

This question is about databases but I prefer to post it here and not in dba.stackexchange. The reason is that I have concerns with the application as well as database design. Programmers can better assist in this regard. My four year old .NET application is using MySQL 5.1 database server as back- end. The database is running well. There are no performance issues to make us worry about. But I want to try out advanced database features like Partitioning, Replication and Clusters. I have never used these concepts before and I can definitely give these features a try on existing database, but I have some other plans. I want to use IBM DB2 express-C as an experimental database. Records from MySQL need to be synchronized into DB2 database and I want to use the DB2 database for reports in my application. Is there any free tool to synchronize the two databases? Do I need to use two connection strings, the first one involving MySQL for Inserts/Updates/Deletes and the second one involving DB2 for Reporting? Is this type of foolish approach used in real world in certain scenarios?


Is it okay to use a short EULA?

I need to add an EULA to my (commercial) software but I cannot afford a lawyer. Also I had a look at various EULA examples on the internet but they are all for specific software or countries, and are probably copied from other commercial software. So I'm thinking about using a short custom EULA which would just mention the essential. Something like:   * You may redistribute the trial version of this software   * If you buy a license, you may not redistribute it or sell it   * You may not sue me for any financial or material loss arising from the use of this software   * This software is copyright XXX, all rights reserved. Would that kind of EULA protect me in most cases? Also do you know of any company that use short EULA?


BDD based on 1-liner requirements

In our team, the product owner only gives us a 1-liner summary. The developers then come up with a PoC, which the product owner reviews and the cycle repeats. The challenge here is 2-fold:   1. Time: We have to create the PoCs asap, so that they can be reviewed   2. The Developers are actually defining the look and feel of the product - a lot of UI PoC and some controller development to back it up. But BDD doesn't gel into the "creative" process of product envisioning. Typically, BDD requires you to take a product specification, and then codify it using Jasmine etc.  Can any BDD experts please suggest a way to blend the creative thinking process with BDD?


What needs to change for Software Engineering to become a formal profession?

Unlike other professions (such as Accounting, Law, Medicine, etc.), there is no profession-wide certification for Software Engineering. I am well aware of the multitude of technology and methodology specific certifications that aim to serve as proof of specialisation and experience, but there is no public Software Engineering society / governing body that sets (and has the power to legally assess) generally accepted professional standards. I understand that software is a dynamic beast - that is part art, part science - but I'm wondering whether Software Engineering has the potential to become a formal profession. What needs to change for this to happen, and would it even be a good thing? (If anybody knows of formal research into this topic I'd greatly appreciate references)       ## Update I agree with many of the good points raised below regarding the current level of certification in Software Engineering. I also find it very interesting that some countries treat Software Engineering as a profession whilst others don't. There does however seem to be a bit of shroud surrounding the term "formal profession", and how it would apply to Software Engineering. I think the key issue with Software Engineering - and the primary reason it is not a full- blown profession - is that if you're a certified Software Engineer, and - for example - some software you wrote for an elevator malfunctions and kills people, your certification and / or membership to a formal professional body won't get revoked. Sure, your company might get sued for millions, and you personally might lose your job and earn a bad reference, but generally speaking, you personally are protected by the shield of limited liability as a result of being employed by said company. In other words, and as far as I know, there is no legal assessment / enforcement in place (unlike other formal professions and their governing societies) which have the mandate to officially bar you from trading once you've made a colossal stuff-up. I quite liked the answer that touched on the fact that Software Engineering - as it stands - is a meritocracy, which doesn't need to be a formal profession, and that this is a good thing that shouldn't change. At the same time, I think we need to make a clear distinction between Software Engineers of mission- critical software versus developers of miscellaneous / non-critical software. To those of you who work / have worked on mission-critical software - is there any personal liability? Surely there is a need for formal repercussions in the event of the Software Engineer making a costly mistake?


Optimal "if-else" tree algorithm to minimize duplicate code

I'm having trouble formulating this problem as an algorithm: I have a set of conditionals (combined with `&&`) and operations, for example:               if (A && B)         execute C     else if (D && A)         execute E      I want an algorithm to find the optimal "if-else" tree that minimizes the amount of duplicate code. The optimal branching for the example above would be:               if (A){         if (B)             execute C         else if (D)             execute E     }      The cost of duplicate conditionals will be different for each conditional, but it is at least `1`. The cost for duplicate operations (e.g. `execute C`) is `3`. This smells like a minimum spanning tree problem, to me. Or maybe some other known graph theory problem. But I can't figure out how to represent the problem as a graph to begin with. Here is a comparison of the two "if-else" trees from the example: ![example graph](http://i.stack.imgur.com/nOEkQ.jpg)


Helper static methods in TDD

I am creating an application which will be testable(unit + integration). In this application I have a FileHelper static class,               public static class FileHelper     {         public static void ExtractZipFile(Stream zipStream, string location)         {             ..................................         }          public static void CreatePageFolderIfNotExist(string directory)         {             .................................................         }              .......................................................         .......................................................     }      But due to static I think it is not testable. How to make this class testable?


How to access clipboard data in chrome and firefox using flex

I want to access the clipboard data in flex appication. How to implement this functionality in Chrome and FF?


Choosing a suitable language and framework

I'm writing a small webpage that will allow the user to download small tools to run locally, I'm thinking what might be a suitable choice of language for the small tools. There will be a rather large amount of fairly specific small tools, so I'm interested in cutting down the development time for each one as much as possible. Requirements:   * The tools will have graphics, nothing fancy mainly 2D-shapes.   * Can be run offline.   * Preferably no installation at all, just run. Some of the users will not be very technically at all.   * Cross-platform, primarily Windows and OSX but also a bit of Linux. My current thoughts:   * Python. Easy to write in but can be a hassle for the user to get to run if using libraries like PyGame. I can't count on the user already having python installed on windows or osx.    * I'm discounting .NET and Mono for more or less the same reason as Python, they'd need installers, or is there a way to ship everything needed in the same folder?   * C++. Takes a slightly longer time to write things in, but does support the requirements. I thought about using a scripting language(Lua, Angelscript or similar) on top of SDL to get the benefits of both c++ and shorten the development time once the middleware is well developed enough. Do you have any other suggestions? EDIT: Please leave a comment as to why if you vote negatively.


Whats an Ideal way to pass rules/options to methods that build SQL

We're trying to come up with a way to handle code that builds dynamic SQL for our application, which is very database centric. Things like Linq to SQL and Entity Framework are out of the question, so please no suggestions of that sort, our path has been defined for us. Our main goal is seperation of the SQL from the rest of the code (business logic etc). Right now, we're thinking of using extension methods to house the SQL, and coming up with some sort of configuration object that developers can use to define how the query should be built (dictated by business logic, outside of the Extension class) So for example, I have some prototype code below. The developers would setup the Configuration Struct (as per business rules), and pass that to GetSQL.               public static class LocationSql2Extension     {              public enum SelectFields         {             Default,             DefaultAnd_Description_LocationSize         }              public enum FilterBy         {             Default,             DefaultAnd_Description         }              public enum OrderBy         {             Default,                         DefaultAnd_LocationType_LocationID_Description         }              public struct Configuration         {             public SelectFields SelectFields;             public FilterBy FilterBy;             public OrderBy OrderBy;         }                   public static string GetSQL(this LocationService2 service, Configuration config)         {                  string sqlSelectFields = string.Empty;             string sqlWhere = string.Empty;             string sqlOrderBy = string.Empty;                  if (config.SelectFields == SelectFields.DefaultAnd_Description_LocationSize)             {                 sqlSelectFields = ", Description, LocationSize";             }                  if (config.FilterBy == FilterBy.DefaultAnd_Description)             {                 sqlWhere = "WHERE L.Description = ?";             }                  if (config.OrderBy == OrderBy.DefaultAnd_LocationType_LocationID_Description)             {                              sqlOrderBy = ", L.LocationDescription";             }                  string sql = string.Format(@"                                            SELECT L.LocationType, L.LocationId                                                   {0}                                            FROM Location AS L                                            INNER JOIN GroupLoc AS GL                                            ON  L.LocationType = GL.LocationType                                                 AND L.LocationId = GL.LocationId                                                 AND GL.SecLocLevel >= 4                                                 AND GL.GroupId = ?                                            {1}                                            ORDER BY L.LocationType||L.LocationId                                            {2}                                           ", sqlSelectFields, sqlWhere, sqlOrderBy);                  return sql;              }            }      and to call the above code, we have this:               public class LocationService2     {         public string BuildSql()         {             var config = new LocationSql2Extension.Configuration();                  //TODO: Add Business Logic to drive these values             config.SelectFields = LocationSql2Extension.SelectFields.Default;             config.OrderBy = LocationSql2Extension.OrderBy.DefaultAnd_LocationType_LocationID_Description;             config.FilterBy = LocationSql2Extension.FilterBy.DefaultAnd_Description;                  return this.GetSQL(config);                          }     }      Developers would be free to setup the Enum's any way they like, and this is just a simple example. We're not comfortable with this Enum/Struct approach, and are looking for something more generic thats easy for developers to work with, but isn't so generic that it won't catch any errors at design time. This is a simple example, and we have some very large and complex queries in our system. Any suggestions?


How can I improve my technical writing?

Writing documentation is part of programming, and writing _well_ is part of what makes the documentation useful. So, what are some hints or guidelines for good writing in the technical realm? What are some resources (on-line or on dead trees) which might help me to improve my documentation?


Having a Git repo and mercurial in the same directory

Ill explain my problem, I am currently using an in-house install of gitorious using git. I would like to begin testing FogBugz and Kiln from Fog Creek which uses mercurial. I would like to for at a least a short while continue development using both solutions. Does anyone know of any long term serious effects of having a git and a mercurial repo in the same directory. Or is there a better way of keeping git and mercurial server in sync. Ive tried it with a test repo and I haven't seen any issues. Thanks for any help.


How can I translate ML code to F#?

Recently I found a book, _Purely Functional Data Structures_ and all the examples in this book are given in ML with Haskell versions in its appendix. But I only know one programming language with the functional paradigm: F#. And after a bit of research, I found out that F# is (or was) the .NET port of CAML, which is derived from ML. I've heard it mentioned that CAML is just a dialect of ML. Given that, is it possible to translate ML to F# without a lot of knowledge of ML? What are the key differences from the languages? Or is my best bet to just learn ML instead?


Shared memory multiprocesses

I'm building an multi processes application and I need to save session ID, the sessions ID is 32 bit, and of course it can't be used twice in its lifetime, I'm currently using DB that saves all the ID in a table, and I do the following, ID table is (int key, char used(1)) //1 is used, 0 is not 1\. lock table 2\. get one key for one sessions 3\. update used field in it to used 4\. unlock After the session is finished the process use below to free key, 1\. lock table 2\. update used field in it to not used 4\. unlock I'm really wondering whether this is a good/fast implementation. and please note it's multi processes application.


Which tool to use to manage a project?

Some time ago I watched these video casts, and I liked how the project was managed. Is there a tool for linux similar to target process (target process's webpage)?   If not, what tool are you using for managing an agile project (linux, or cross platform)? Thanks


What is a "Process Canary"

In the book "Hard Code" by Eric Brechner, he states, > Lying is one of a handful of valuable process canaries that can warn you of > trouble. I've heard a dev or two toss around the old "canary". What is it? [Google didn't answer it for me. Perhaps my keywords were a poor choice.]


Ignoring unit tests - good and bad reasons when and why?

Recently I began a new project to re-implement a core part of automation. Since it is very important, I'm TDDing it so that I can tests various basic scenarios as well as things we know the old system doesn't do. In doing this, I find myself creating a few "sandbox" tests, which exercise "candidate" algorithms in complete isolation so I can choose the one that best meets requirements. I've also created some tests to figure out why other tests are failing, which again are coded in a "sandbox" manner and don't test actual production code (they instead have a simplification of the production environment that I can alter until I find the problem/cause/solution). Neither of these has continuing value for regression; once I pick an algorithm I may never use the others, and once a test shows why another test is failing, I can correct the initial test (or its exercised production code) and verify correctness, and I no longer care that the other test's hard-coded exercise environment still fails. When learning TDD I was taught that you NEVER delete a unit test; even if the test's original purpose has become irrelevant, the code within the test can be of use to other developers as a model, or the test can be refactored for some other purpose later. Instead, if a test has become redundant or irrelevant and should no longer be run, pass or fail, it should be ignored. Is this the "generally-accepted" stance on ignoring tests? Does this have the potential for abuse (e.g. "I don't _think_ it matters anymore, and it fails, so I'll just ignore it")?


How can I explain the difference between NULL and zero?

Working on a problem that uses the percent change formula:               percent change =  100 * [(new value - old value) / old value]      How would I explain the difference if `new value or old value = NULL`, rather than `0` to someone who might not be a programmer? My boss is wondering why there is an empty string in the TextBox rather than a value, because we have the old value, but not the new value.


Is there any static analyzer for code contracts for Java 1.6?

I have used Java Modeling Language (JML) with its runtime assertion checker jml4c for writing code contracts in java. However, it would have been great to have a static checker in place as well that provides suggestions as to where a contract is possibly broken during the build process, something like the code- contracts library developed for the .NET platform. Esc/Java2 does this for java version 1.4. Is there any such tool that supports java 1.6?


Attempt at understanding the double-dispatch pattern

I've been trying to grok the double-dispatch pattern and having a hard time. I finally attempted a sample program to help myself understand. Here's the gist. But then I decided to attempt it without Double dispatch and the solution didn't look any more terrible than usual. What am I doing wrong?


What's the difference between "use case", "User Story" and "Usage Scenario"?

Is there an exact, but simple and understandable defintion of the distinction between "use case", "User Story" and "Usage Scenario"? there are quite a bunch of explanation, but right now, I see no one that explains the differences in a single sentence, or two... (e.g. http://c2.com/cgi-bin/wiki?UserStoryAndUseCaseComparison very long and hard to get, full of discussion)


What are the Agile initial conditions?

First let me say that I think that an agile process can work because of the following underlying principles:   * It brings focus   * Limits the noise which really brings focus Secondly I am wondering what are the initial conditions needed so that an Agile process can succeed? For example do we need to have:   * No existing bugs   * Fully automated test process or at least a highly automated test process   * People dedicated to the project   * More clearly defined new development   * Development that is not _make it faster or more stable_   * ? So what do you need to make it successful? Are there different Agile implementations that better handle not having some of these initial conditions?


usefulness of PNG checksum vs. lack thereof in other FourCC formats

PNG is one of a family of container formats generally called FourCC or OSType. [A]IFF and WAV are two other common instances of the format. I want to develop a new format for a specialized data type. I modeled the format closely on PNG. PNG is unusual for the FourCC family in that each block ends with a checksum. In theory this can be used to check for corrupted data. Is that checksum useful for practical cases? New formats, like Google's WebP (based on RIFF), don't have a checksum. I can't find guidelines on what to do with it, including:   * should all readers verify the checksum, or do most readers ignore it?   * what should a reader do if it's wrong? Since I'm not convinced it's useful, and supporting the checksum makes things more complicated, I'm going to omit the checksum in the next revision. But since it's in PNG, I figure there's a good reason, I wanted to get some feedback about how people actually use that field and its relative importance.


Is it possible to make something open-source without publishing it?

I've been working on some piece of software while being "employed" by company A. I now want to continue working on the same software while being employed by company B. Company B wants the software to become open-source to prevent any future legal issues between company A and them. I will consult company A's lawyer to make sure it's fine by them, but I suspect it will be alright as company A is actually a public university which looks favorably on industry connections. However, I am concerned by potential competitors getting access to that code before we make its results public. **Is it possible to make the software open- source without sharing it with anyone but company B** (neither in binary nor source form), **or do I have to publish the software the minute it is made open-source or shared with anyone?** If the answer depends on the specific open-source license used, please be kind and provide details about the differences.


Software Lifecycle Methodologies for One Man Teams

I am building a software system for my masters project and was looking for advice on particular methodologies that would suit a "one man team"...


Does writing a programming blog reduce your learning speed, compared to reading other people's blogs only?

If I want to concentrate on improving my skill or knowledge, should I be writing my own programming blog in order to consolidate my knowledge or I should I just concentrate on reading other people's blogs/videos/podcasts/books?


What are the practical benefits of LISP like syntax which Clojure uses over Java like syntax of Scala?

I spent couple of months learning Scala and got overwhelmed by number of different constructs it had, After looking at partial functions, partially- applied functions, pattern matching, actor syntax, I gave a thought to learning Clojure which doesn't have too much in terms of syntax but looking at the how Java inter-operability is handled, it looks very difficult to get use to. for example: things like `doto, new and .` Every time I start typing a function, there are times I write `(1 + 2)` instead of `(+ 1 2).` It looks like I will have to completely forget how I write regular programs to get use to this syntax. Also finding it difficult to deal with side-effects that do and let form have. Aren't they similar to what functions with void type are ? Things like registering a callback,things normal I/O, how can such things be side-effects free. Till now all I really liked about Functional Programming is that, immutability makes concurrency easier when dealing with shared data, functions as first class objects and having higher-order functions, apply,map and reduce with functions and lists . I wanted to know, are there practical benefits I will get once I am use to this syntax ? I f I continue to learn Scala and avoid using var, and always use recursion instead of loops. I can do all the above things and still write understandable code.


What are the cases where keeping source code secret is justified?

When I worked as a freelancer, I encountered lots of cases where customers were protecting their ideas and source code of their projects (such as web applications) as much as possible, no matter how unimportant, uninteresting and unoriginal were the projects and the concepts behind. I've already posted a question about keeping the ideas secret, and received many great answers. Now, my concern is more about source code secrecy. According to my observations of:   * The codebases I had to work on during my career,   * My own willingness to keep some of my own source code secret, and:   * A few articles like, for example, Open response to Simon Stuart by the popular Programmers.SE contributor Mason Wheeler, I conclude that source code is kept secret mostly for those reasons:   1. Because the author is ashamed of the code of such a bad quality, or the company fears losing reputation if somebody sees such bad codebase, or that given the low quality of the codebase, it will not bring anything useful to anybody to open source it: even if somebody would be interested, he would hardly be able to run the solution (or, often, even compile).   2. Because parts of the code are stolen (mostly from open source projects covered by a license which restricts its usage in a given situation),   3. Because the code relies on security by obscurity and the author doesn't care about Kerckhoffs's principle.   4. Because the product is so breakable that showing the code would cause too much harm: if a closed-source app with all those security leaks would withstand a newbie hacker, the same open sourced app would have far smaller chances, because even the beginner hacker would just have to study the code to discover all the holes. If it's not clear what I'm talking about, here's an example:              if (credentials.password === 'masterPassword12345')     {         isLoggedIn = true         currentUser = credentials.userName     }     else     {         authenticate(credentials)     }        5. Because the author over-estimated the source code (and his own skills and expertise). Example: believing that a home-made cryptography-related algorithm (which was never reviewed by anybody) is better than any well-known one.   6. Because the author believes that the idea behind the code is great, and that it would be stolen.   7. Because of the "It's not perfect enough" syndrome. In other words, the developer is willing to release the source code to public when the code is "good enough", but day after day, there are still things to improve, so the code would never be released. All of those reasons give a rather negative image of people who are against publishing the source code. Are there valid cases to not release to the public the high-quality code which follows Kerckhoffs's principle?


Developing on a production server

Today I got yelled at for developing an application on a production server. Quote, " _developing on a production server is not acceptable - ever!_ " Here is the situation.   1. I set up a development instance: `http://example.com:3000`   2. The production instance is: `http://example.com`   3. I complete all my development work on `http://example.com:3000` and when the client is pleased with the changes, I move them over to `http://example.com`. The application I am working with is an old Ruby on Rails application, and I have to say that initially, I did try to set up an development environment locally, but I could never get it running. After trying for a while, I gave up and decided to develop on the production server. Again, am I an idiot? Probably so, but I've been doing web development for a couple of years now, and I have never encountered a situation like this. Who is right and why?


Is this a candidate for Singleton?

I have an external thermometer connected via USB that is controlled by my SW. Different parts of my system will use it but never at the same time (all in one thread). However, it is a single device communicating over an established connection so for some reason I think either its method (GetTemperature) should be static or I could do it as Singleton. I will be happy for suggestions. Thanks


Is there a difference between "self-plagiarizing" in programming vs doing so as a writer?

I read this Gawker article about how a writer reused some of his older material for new assignments for different magazines. Is there any similar ethical (societal?) dilemma when doing the same thing in the realm of Programming? Does reusing a shared library you've accumulated over the years amount to self-plagarizm? What I'm getting at is that it seems that the creative world of software development isn't as stringent regarding self-plagarism as say journalism or blogging. In fact on one of my interviews at GS I was asked what kind of libraries I've developed over the years, implying that me getting the job would entail co-licensing helpful portions of code to that company. Are there any cases where although it's legal to self-plagarize, it would be frowned upon in the software world?


How to approach the ol' "this will just be a small application"? Yeah right?

Ok I have run into this many times, but here is the worse case scenario slightly exaggerated. **A client says** "hey can you make us this small module to do this small task"?   **Me:** "Sure no problem". So based on budgets and constraints etc., I skip some of the architecting and dive right in and make it no sweat. Then they ask for another module. And another. And some enhancements. And this all happens very slowly mind you, over years. And before you know it, you have this monster application that is horribly architected. What do you do when you are asked to do something small? You don't know if it will keep growing...if the client will keep asking for additions (and neither do they). You can't over-architect the thing, because it's just a small application after all, and they will go somewhere else if you say (in that I know all voice) "Well just in case, let's architect this thing into layers with top-o- the-line security and separation of concerns. In fact let's go with a dependency injection tool that will really make this thing fantastic blah blah blah". They will say "yeah right" and go to someone else. Budget, time, and perception are as important as architecting the application itself. How should this be approached? I guess the question really boils down to "When you don't have all the information for the final outcome of what appears to be a small application, how do you avoid (or mitigate) making architecural and design decisions early on that will be completely innapropriate later?


Can I use GPLd code I wrote on the job as code samples without permission?

I'm currently employed by a business to do website development in Wordpress. I've written a number of custom plugins specifically for a number of clients over the time of my employment. Today, I asked my boss what I would be allowed to use as code samples because I'm quitting. My boss has forbidden me from taking any of the custom plugins I coded (which is all of the programming work I've done). However, all of those custom plugins I coded are currently licensed under the the GPL (though they were never released or shared). If I was to take this custom code that I wrote under the GPL (but never released) and provide it as code samples anyway, would my current employer be able to take any kind of legal action against me?


Architecture for a template-building, WYSIWIG application

I'm building a `WYSIWYG` designer in `Ember.js`. The designer will allow users to create campaigns - think MailChimp. To build a campaign, users will choose an existing template. The template will have a defined layout. The user will then be taken to the designer, where he will be able to edit the text and style, and additionally change some layout options. I've been thinking about how best to go about structuring this app, and there are a few hurdles. Specifically, the output of the campaign will be dynamic: eventually, it will be published somewhere, and when the consumers (not _my_ users, but the people clicking on the campaign that my user created) visit the campaign, certain pieces of data will change, depending on the type of consumer viewing the campaign. That means the ultimate output of the designer will be a dynamic site. The data that is dynamic for _this_ site - the end product - will not be manipulated by the user in the designer. However, the data that will be manipulated by the user in the designer are things like copy, styles, layout options, etc. I'll call the first set of variables server-side data, and the second client-side data. It seems, then, that the process will go something like this:   * I'll need to create templates for this designer that have two dynamic segments. For instance, the server-side data could be `Liquid` expressions, and the client-side data `Handlebars` expressions.    * When the user creates a campaign, I would compile the template on the back end using some dummy data for the server-side variables, and serve up a `handlebars` template to the `Ember` app.   * The user would then edit the template, and the `Ember` app would save all his edits to the JS variables that were powering the template. This way he'd be able to preview the template.   * When he saves, he'll send back the selected template, along with all the data and options he's made.   * When it comes time to publish, the back-end system will have to do two things:      * compile the template with `Handlebars` using the campaign data, and then     * compile the template with `Liquid` using the server-side data * * * Is my thinking roughly accurate about this, or is there a simpler way?


Best practice for remotely resetting a mobile app's content/settings

What would be the best approach to reset a mobile app's content/settings? Lets say the app is cross platform: apple/android using javascript/phonegap. The current way this is designed is to have an admin area that can see mobile devices (users which have logged in). The admin has the ability to flag a device for reset. The app regularly polls the server to see if it should be reset. Resetting will be rare, but the polling is not. The polling doesn't cause any performance issues but it seems off to constantly be asking the server whether or not to blow up the app. A push rather than a pull method would be nice but I'm not sure what this would look like. Does anyone have any alternative design suggestions? Are there any drawbacks to the current design?


Does dress code affect your programmers performance

Do you believe forcing programmers to not wear what they like affects their performance? I can extend the question to what they want put on their desk or hung on their wall. Do you have experience that proves giving programmers more freedom in personal matters can increase their productivity? Personally, I feel it should have an impact.


What is the difference between Quantum annealing and simulated annealing?

In both algorithms objective functions, that will be executed with non quantum computers, are used. Both algorithms are methods for finding the global minimum of a given objective function. From wikipedia: > Quantum annealing can be compared to simulated annealing (SA), whose > "temperature" parameter plays a similar role to QA's tunneling field > strength. What is meant by "tunneling field strength"? The choice of next candidate state seems to be the only difference between the algorithms, is that correct? Finally, what are the advantages of Quantum annealing? Is it faster, or is it just better at handling local minima?


optimizing webapp workflow

I have a debug and a live server running a LAMP setup with some python scripts. By now I'm working with eclipse and Expandrive (via SSH) on the debug server. Whenever I want to release new code on the live server, I copy and paste the code via windows explorer from debugdrive to livedrive. I think this environment really sucks, what are good alternatives?


Refactoring code smells in ASP.NET Web Forms Code Behind Files: Is it risky? Is it wise? Is it a waste of time?

Given a long method with Pac-Man ifs, would it be wise to:   1. Break down code blocks into regions.   2. Then refactor code blocks into methods. Or would it be best to leave it alone? Would it be risky?   Would it be a waste of time? In the absence of automated unit-tests, I'm trying to understand the risk- reward relationship associated with this manuever.


Inspecting the model in a Rails application

I am learning some Ruby on Rails, and am a newbie. Most of my background is in ASP.net MVC on the back end. As I play with a basic scaffold project, I wonder about this case: you jump into an established Rails project and want to get to know the model. Based on what I have seen so far (again, simple scaffold), the properties for a given class are not immediately revealed. I don't see property accessors on the model classes. I do understand that this is because of the dynamic nature of Ruby and such things are not necessary or even perhaps desirable. Convention over code, I get that. (Am familiar with dynamic concepts, mostly via JS.) But if I am somewhere off in a view, and want to quickly know whether the (eg) Person object has a MiddleName property, how would I find that out? I don't have to go into the migrations, do I?


I do not have a degree but have 7 years of experience with ASP.NET, C#, can a institute offer me a degree?

I couldn't find time and money to study due to financial issues,however I managed to land some good jobs and projects and 2 multinational and my portfolio now has good clients on it too, however I still feel that I lack something important so was wondering if someone knows an college/university that offers degrees if you are a qualified professional, I'm also willing to study for few weeks if required. _Update_ Thanks for the answers guys, in my area as far as I have looked, there are no evening or weekend classes for undergrad studies, however there are some for Masters and few of my working friends are studying on weekends (thats actually where my motivation came from).


The emperor's new code, or: how to communicate code efficiencies

So you've made some code changes that should hopefully speed up some part of an application. But there is just one problem - you don't know how it will perform in live. Different networks, different machines, different memory, different configuration, different times of day, different users, different server loads etc etc etc So... (a) Do you ask them if that bit of the application has got faster? (b) Do you ask them to monitor that part of the application? Or... (c) Do you just ask them to see if they notice any difference in the application in general? After all, you can't be 100% sure you haven't affected something else. Each of these approaches would seem to have problems (I know this as I've tried them all): (a) You're asking a leading question. Before such a fix goes life, there is an emperor's new clothes scenario. The developer believes the code should be faster so there is some kind of crusade to get everyone believing it before it goes live. So...it goes live. Some people say it is faster, some slightly slower and others about the same. What then? (b) Again: Some people say it is faster, some slightly slower and others about the same. What then? (c) You're no longer asking a leading question, but you start getting hit with a whole torrent of issues that people have known about for months (maybe years) but you've now opened Pandora's box. How can you be sure which if these (if any) are new issues? Or maybe I should be asking different questions entirely. Any thoughts? **EDIT:** No doubt there are processes leading up to this point that could potentially be improved. But the nub of the question is this: The change is tested and has been put live. You have a myriad of stats to prove the changes should improve performance. Your boss has given the stats a once over but now wants to make sure the users are happy before signing off the release. What question(s) should you be asking the users?


Bridging the gap between computer science research and software engineering

Do you believe there is a gap between computer science research and software engineering problems? For example, do software engineers ever have to worry about "factoring and graph isomorphism" or some complex computer science problems if they have to....say build a shopping cart website? Probably not. And if there is a disconnect between computer science and the engineers that build applications? Is that the way that engineering and science should exist? Will engineers dive through years and years of research papers to solve a particular problem that they have? Edit-1: After thinking about it, general science probably has the same problem. I am sure there are top chemists working at companies like McDonald's and Taco Bell that are tasked with making a better, easier to manufacture burger.


As an iOS developer, what type of technical interview questions should you be prepared with?

I just finished a technical interview yesterday and the interviewer asked about graph theory, data structure, and traversals. This has nothing to do with iOS stuff. So I came un-prepared. This was actually for a social mobile gaming company, is this the reason why they ask these kind of stuff instead of iOS stuff? Now it seems to me that I am just overwhelmed by the materials to review and study for future interviews, I have to review the whole data structure/traversal/searching algorithm and at the same time iOS/objective-C fundamentals as well. Can someone guide me on how to prepare? Is my past experience just a special case as it was a gaming company?


What is the acceptable failure rate for software?

Say I produce some software with a genetic algorithm. In order to be certain that the software works correctly in all situations, I would need to test all situations, which could be prohibitively (or infinitely) many. So I evolve the software with evolving test input (some fixed, some inherited, and some random). Now, with each generation, the probability measurably increases that the fittest functions will be general solutions, not just solutions for the known data at hand. As developers, we are flawed, and our software may fail, in fact quite often. Generally speaking, we have no idea of the probability of failure at any given point, though we may be able to discern specific cases in which the software will fail. All we can do to reduce the failure rate is test thoroughly and practice good software development. But logically, we distribute flawed software all the time. Would it make you uncomfortable as a developer to know _how often_ your software might fail, but to know nothing about the specific cases in which it might? What failure rate is acceptable? 0.01%? 0.0001%? Would you hold a genetic algorithm to a higher standard than a human when it comes to failure rates?


Best way to build a hierarchy CLI menu?

I want to build a command line interface with menus and sub-menus and eventually the leafs of the tree should be operations like.. bank management -> account management -> add acount (insert account info) And I'm looking for a good way which works with the OO principles... Thanks for any piece of advice!


Is there a better strategy than relying on the compiler to catch errors?

I've been programming in C and C++ for some time, although I would say I'm far from being an expert. For some time, I've been using various strategies to develop my code such as unit tests, test driven design, code reviews and so on. When I wrote my first programs in BASIC, I typed in long blocks before finding they would not run and they were a nightmare to debug. So I learned to write a small bit and then test it. These days, I often find myself repeatedly writing a small bit of code then using the compiler to find all the mistakes. That's OK if it picks up a typo but when you start adjusting the parameters types etc just to make it compile you can screw up the design. It also seems that the compiler is creeping into the design process when it should only be used for checking syntax. There's a danger here of over reliance on the compiler to make my programs better. Are there better strategies than this? I vaguely remember some time ago an article on a company developing a type of C compiler where an extra header file also specified the prototypes. The idea was that inconsistencies in the API definition would be easier to catch if you had to define it twice in different ways.


As a code monkey, how to discuss programming with a guy who almost has a doctorate in computer science

A friend of my wife's is coming over for dinner tonight and he is a lot smarter than me. What do we have in common, well... A Bachelor's in Computer Science, and that should be enough of a conversation starter. But he's nearly completed his doctoral studies and is light years ahead of me in his particular area, which I find fascinating but don't have any legit reason to care about (except for maybe a better way through heavy traffic - he's a combinatorics guy specializing in that I think) and I got married and had some kids and am a professional programmer for medical records software. We've got a lot in common, but there's a point where neither of us care or understand each other - although I really want to learn from him and I'm not certain he'd even want to talk about his work. So for all you doctors or code monkeys, what's a good conversation starter!


Are nullable types preferable to magic numbers?

I have been having a little bit of a debate with a coworker lately. We are specifically using C#, but this could apply to any language with nullable types. Say for example you have a value that represents a maximum. However, this maximum value is optional. I argue that a nullable number would be preferable. My coworker favors the use of zero, citing precedent. Granted, things like network sockets have often used zero to represent an unlimited timeout. If I were to write code dealing with sockets today, I would personally use a nullable value, since I feel it would better represent the fact that there is NO timeout. Which representation is better? Both require a condition checking for the value meaning "none", but I believe that a nullable type conveys the intent a little bit better.


What was SOAP invented for?

This question is inspired by this one. What was the initial goal of inventing SOAP? Why was it invented when we had old kind HTTP and REST?


Disadvantages of scoped-based memory management

I really like scope-based memory management (SBMM), or _RAII_ , as it is more commonly (confusingly?) referred to by the C++ community. As far as I know, except for C++ (and C), there's no other mainstream language in use today that makes SBMM/RAII their main memory management mechanism, and instead they prefer to use garbage collection (GC). I find this rather confusing, since   1. SBMM makes programs more deterministic (you can tell exactly when an object is destroyed);   2. in languages that use GC you often have to do manual resource management (see closing files in Java, for example), which partly defeats the purpose of GC and is also error prone;   3. heap memory can also (very elegantly, imo) be scope-bound (see `std::shared_ptr` in C++). Why is not SBMM more widely used? What are its disadvantages?


Can a Code Review help in learning the code-flow and/or technology of a large code-base?

I'm new to VC++, and so am not very familiar with COM, ActiveX, IDL etc. When I mentioned this to my tech-lead, he assigned me the task of doing the code review of files he felt were important, in terms of the code that I'll soon be working with.   The actual code-base is approx. 10000 files. I'm a bit skeptical that doing a code review can help in understanding VC++ (I've already worked with C++ on Linux extensively for 2 years and have plenty of experience in Actionscript, Processing and many other languages). Since the code yet has to be built and run on my system (I'd prefer putting breakpoints and finding the code-flow), my tech-lead gave me the code review work. Is there a better way?


Are there programming languages that their programs don't run on a VM or natively, but rather on an interpreter?

In this question I presented an idea I have for a simple programming language. The way programs written in this language will be run, is inside an interpreter written in Java, which will interpret the source code directly and execute it. I would say that there is no doubt that this language would be considered a 'programming language'. It is capable of producing programs that can run, and there exists a platform for them to run on (the interpreter). However, most answers on my question said that this interpreter won't be considered a VM. I am used to thinking that all programming languges create programms that are most commonly either compiled to machine code and executed natively, or compiled to some kind of bytecode or IL and interpreted (executed) on a VM. (Or like in the rare case of the Dart language, interpreted and executed by a VM which interprets the source-code directly, no IL or bytecode). But in my case - **if it's true that my interpreter isn't considered a VM** \- programs written in my language do not run on a VM, and do not run natively, but rather run on an interpreter. My question: Are there programming languages in existence, that their programms are most commonly executed similarly? Not on a VM, and not natively, but **rather run on an interpreter? (which is not considered a VM** \- _although I must add I still don't understand why an interpreter that's used as a platform for other programs to run on isn't considered a VM_ ).


Is it okay to hire a programmer of an open source software for a (closed source) fork?

I want to fork an existing open source project to implement a certain major feature based on a research project. I am not sure yet if the changes will end up being open or closed source (the original project is BSD licensed). The point is that I can provide the code for the new feature, but it would take me quite some time to dive into the project and design the interface between the existing application and my new feature. So it would be cool to have a programmer who knows the project already. The question is now if I should just ask among the current developers (dev mailing list) if one of them would be willing to implement the fork (on a paid basis). Is this a generally accepted practice in the open source community? Do you know case histories / examples? (Where has it been known to happen? Where was it known to be refused, and why?)


What subject do you discuss with your manager during a one-on-one?

Every week, I have a 30 minutes meeting scheduled with my manager to talk about pretty much anything. So far, I haven't taken those one-on-one very seriously. As a new year resolution, I would like to take more seriously my one-on-ones with my manager. One way I though I could do that is to plan in advance (come up with a list of questions and/or agenda) my one-on-one. With the exception of the status report, what subject do you discuss with your manager during a one-on-one? Have you ever seen an agenda for one-on-one?


Feedback on a Kanban Board for Solution Architectects

Before I get started I need to issue a pre-emptive apology: > _It is very likely that some of the terminology / vocabulary I use in this > post is plain wrong there is also a good chance I have entirely > misinterpreted some of the keys aspects. I am new to this so don't be too > critical, more than welcome constructive feedback ;)_ # Background We are currently transitioning a development department of 200 people from multi-methodology into "Agile". The whys, wherefores, pros and cons of this are well beyond the scope of this question. This development department contains an Architecture Service team that is made up of 10 people that are officially known as "Solution Architects". In reality they cover more than just the solution, these are technical people that cover every technical architectural aspect of a project (i.e. hardware, software, security, governance etc). They also provide ad-hoc functions to the development team (code reviews, standards guidance etc) and wider business (technical input into tenders, pre contract technical preview of customer requirements) As part of this transition I have been tasked with creating a Kanban board for the purposes of getting a view of the work activities that the Architecture Service team are accountable for. There are a myriad example boards for development / coding teams, but none that I can find for Architecture. So I have taken from various sources and created "something", I would really appreciate genuine feedback on it. It is also worth noting that this will be presented to the team as a starting point / work in progress. It is their board and I want them to own it, all I am doing is setting a foundation for the guys to build on (and change if necessary) So far I have something like this # The Main Board The main board is where we hold all active / backlog projects - all active work will be on this board. This will be short reviewed in the daily architectural scrum with a more in-depth review at the end of every week.                          ------------------------------------------------------------------------                | Evaluation            | Implementation       | Ad- Hoc               |                | Todo  | Doing  | Done | Todo  | Doing | Done | Todo  | Doing  | Done |         -------------------------------------------------------------------------------         Person |       |        |      |       |       |      |       |        |      |         --------       -----------------       ----------------       -----------------         Person |       |        |      |       |       |      |       |        |      |         --------       -----------------       ----------------       -----------------         Person |       |        |      |       |       |      |       |        |      |         --------       -----------------       ----------------       -----------------         Person |       |        |      |       |       |      |       |        |      |         -------------------------------------------------------------------------------      The column descriptions / purposes are: **Evaluation** : Projects where the person is doing an initial technical analysis, i.e. running through technical options with a product owner, determining the size of the project. As an example an Evaluation project may be the Architect evaluating a new technology or working with a customer to produce a mutually agreed technical solution. **Implementation** : Projects that are actively in development (coding, testing etc) and the person is acting in an SA function for the wider project team. As an example this could be the development of coding aspects of the "mutually agreed technical solution" mentioned above, equally it could also be architecturally overseeing the implementation of some new hardware. **Ad-Hoc** : All the weird and wonderful stuff that comes up that can't be put into the other two columns. As an example in a strange recursive world there is a card for me in the ad-hoc column to create a KanBan board :). **Person** : Fairly self explanatory, the person who "owns" the cards in that row. To make things a little more fun this actually contains an avatar of that persons choice. **Todo** : Is effectively our backlog, the cards in here are ordered top to bottom in priority. As space in a persons doing cell becomes available we take from the top of todo. **Doing** : Fairly self explanatory **Done** : Items that have been completed since the last full board review (Friday afternoon every week) ## WIP Limits Rather than do what we do now (i.e. give out work until somebody squeals), I would like the main board to work with objective / evidence based WIP limits. The intention is to size each of the board cards with:   * XS (Extra Small) : 3 points   * S (Small) : 5 points   * M (Medium) : 8 points   * L (Large) : 13 points   * XL (Extra Large) : 21 points The size is very much from an Architects workload perspective, for example a project that requires 1 year of coding for 10 people but minimal Architectural input would be XS or S. However a project that has massive Architectural input but minimal coding could be an XL. Over time we should be able to work out the WIP limit for each person. So we know that Jonny Smith can work with a velocity of 42 points and therefore allocate projects up to that level. As we have not done this before my intention is to set the initial limit high, the idea being that when a person squeals we can (as a team) look at this objectively and determine if it is genuinely too much or is it because our processes etc are too onerous and should be streamlined.   * **NOTE** : Of everything here these WIP calculations are the bit that "feel" the least right* # The Funnel Board In order to keep track of all the random things that fly through the team we also have a funnel board. This is a relatively simple board that looks like this:                   ------------------------------------------------------------------------         | Evaluation            | Implementation       | Ad- Hoc               |         ------------------------------------------------------------------------         |                       |                      |                       |         |                       |                      |                       |         |                       |                      |                       |         |                       |                      |                       |         |                       |                      |                       |         ------------------------------------------------------------------------      As the team is made aware of a "project" but this is not yet officially sanctioned (i.e. can be put into the Todo columns on the Main Board) then it goes onto the funnel board. Items here are not allocated to a person. The idea being that we can track those random things that come through and ensure they are not forgotten. Also, as the person completes an evaluation project this then moves from Main Board Evaluation Done to the Implementation funnel board (unless it immediately becomes an implementation project) A member of the team will occasionally be tasked with following up everything on the funnel board, i.e. quick phone call to the product owner asking if this is still relevant (this would be an ad-hoc project on the main board) # The Successes Board This is just a simple board to track what we have done over the last X months. It holds the cards that have been through the Funnel and / or Main boards                   ------------------------------------------------------------------------         | Successes                                                            |         ------------------------------------------------------------------------         |                                                                      |         |                                                                      |         |                                                                      |         |                                                                      |         |                                                                      |         ------------------------------------------------------------------------      The idea being that we can occasionally get around this board and give each other mutual pats on the back :) # Board Cards The cards that are on the boards contain the following information:                   ------------------------------------------------------------------------         | SIZE (XS,S,M,L,XL)          | OWNING TEAM MEMBER             |  RAG  |          ------------------------------------------------------------------------         |                                                                      |         |                         PROJECT TITLE                                |         |                                                                      |         ------------------------------------------------------------------------         |                                  |                                   |         |        DEPENDENTS                |          DEPENDENCIES             |         |                                  |                                   |         ------------------------------------------------------------------------         |                                                                      |         |                         MISC INFORMATION                             |         |                                                                      |         ------------------------------------------------------------------------         |                WIDER PROJECT TEAM (AS APPLICABLE)                    |         | Other Architects, Project Manager, Principal Developer, Business     |         | Analyst, Scrum Master                                                |         ------------------------------------------------------------------------      As you will notice the granularity of the card is at a fairly high "Project" level, I am not planning on doing a developer style board that is split into tasks (thoughts on this welcome). Also worth mentioning that depending on where the card is not all sections will be applicable. I am also planning on colour coding the cards, as a first stab I have: Yellow : Anything that is customer contractual Pink : Anything that is internal (i.e. not end user facing) Green : Anything that is a company group project The cards will be magnetic rather than post-it, I am hoping to find some that are like mini white boards as this will make life easier as things change # Other Stuff   * If its not on a card on a board then as far as the team is concerned it doesn't exist   * The boards themselves are Whiteboards with Wheels, we can take them wherever we want   * We may consider going to a virtual whiteboard in the future (physical whiteboards are easier to change when we decide that the X column is best on the left of Y not the right) # Questions   1. After reading my newbie Kanban War and Peace what are your thoughts? (please go easy on me :))


Designing interfaces and async

Suppose I have created interface `IFolderRepository` with methods like that:               IEnumerable<Folder> GetAllFolders();     Folder GetFolderWithId(int id);     void AddFolder(Folder newFolder);     void ModifyFolder(Folder folderToModify, Folder folderAfterModification);     void RemoveFolder(Folder folderToRemove);      and I've implemented `DatabaseFolderRepository` and lets say `CacheFolderRepositoryDecorator`. Now 'hundreds of lines later' I'd like to add SkyDrive folders functionallity so I'm ready to add `SkyDriveFolderRepository`. Unfortunately while `DatabaseFolderRepository` implementation used synchronous methods to talk with database, skydrive one uses a lot of `async` and `await`. What to do in such case? In case of void methods marking it async is not a solution (need to exception handling). Should I change interface to return `Task<T>`? Sure it will work in above example but they're just 2 interface implementation classes. Or should most of my interfaces have `Task` return types (against you aren't gonna need it rule)?


Replacement for instanceof Java?

So I'm fairly new to programming in the real world (outside of academic projects) and have come across lots of posts saying that using `instanceof` is a bad thing to use to determine what class a specific object is. My situation is that I have three classes, a base product class, one that extends off that and another that extends off that. These are all stored in the same table in a database and I have some code that needs to use the methods on each to pull data off them. What is the best practice to get around this way of doing it? I have read some things about polymorphism but I can't find any examples that fix the issue I have. They all usually override a method which for me won't work as I need to pull different things from the different objects. Is there a better way to do this or am I stuck with using `instanceof` or some sort of reflection to get the fields specific to the objects?


TDD workflow for (implementation specific) edge cases

When developing features with TDD, I create a test for each combination of feature and case. So, one test for creating user successfully, one for validation errors, and one for database errors. I don't test each one with many different types of data, in general, as I write the tests to flesh out features, less to catch errors. I don't think it's time-effective to write out several cases (even with a "data provider") for every single feature I develop in order to validate that the feature works correctly in all cases. Sometimes, though, there are certain implementation specific bugs to be wary of when implementing the feature. After writing the feature test that allows me to write the implementation, I'll notice that certain edge cases need to be tested more carefully because of the implementation. How does one organize these tests with the rest of the feature-specific tests? Are the tests I'm describing regression tests? **Edit:** I guess I wasn't clear about what I meant with "different types of data" and "works well in all cases." My main issue is in writing implementation-specific tests--specifically the workflow and organization. We _are_ testing the interface. We're specifically testing the feature only, at first. But a certain implementation requires more tests.


Software requirements analysis or requirements engineering?

I've been looking around for some articles regarding to requirements analysis, but I'm a bit confused with the term, because based on Wikipedia requirements analysis is a stage of requirements engineering. But once you search more, many of the websites use them interchangeably as in they mean the same, can you please help me clarify this?


Custom search engine

I have made a web application and now I would like to add a search option to it. Since it is a learning project, I can't afford to buy some Google license. That is why I consider creating my own search engine. From what I have read, there are two major ways to do it: using `Apache Lucene` or using `Apache Solr`. I have read a bit about both, but I really don't understand what is the difference between them. Which one should I choose? I am looking for something free which is easy to learn and use, so you have other suggestions please let me know.


Test bed application for executing LinQ queries against AdventureWorks

I am looking for a "test bed" application which will help me to learn Linq by writing queries and immediately executing them against the AdventureWorks database. Why AdventureWorks? Because it is a sample database Microsoft uses in their documentation?


How to draw a class diagram where a class contains either 6 other classes or mupltie different

I know the basics but do not how to model this (it is an exercise with no solution provided): > An order can contain 1 or more cartons of beer. Each carton contains 6 beers > of the same kind but there are some consisting of 3 different beer types > (still 6 in total) Also having a "Carton" class, how can I make it the way it either 6 beers (same ones) OR 6 beers of 3 various types?