How should I handle measurement logging in my Discrete Event Simulation engine?

I'm attempting to build a Discrete Event Simulation library by following this tutorial and fleshing it out. **_How should I handle logging metrics in my Discrete Event Simulation engine?_** If you don't want/need background, skip to _The Design_ or _The Question_ section below... **Simulation** The goal of a simulation of the type in question is to model a process to perform analysis of it that wouldn't be possible or at least feasible in reality. Take the canonical example of a simulation of this kind is a Bank:   * Customers enter the bank and get in line with a statistically distributed frequency   * Tellers are available to handle customers from the front of the line one at a time with a certain distribution   * As the line grows longer, the number of tellers available may have to be increased based on certain business rules You can break this down into generic objects:   * Entity: These would be the customers   * Generator: This object generates Entities according to a distribution   * Queue: This object represents the line at the bank. They find much real world use in acting as a buffer between customers and a limited service.   * Activity: This is a representation of the work done by a teller. It generally processes Entities from a Queue **Discrete Event Simulation** Instead of a continuous tick by tick simulation such as one might do with physical systems, a "Discrete Event" Simulation is a recognition that in many systems only critical events require process and the rest of the time nothing important to the state of the system is happening. In the case of the Bank, critical events might be a customer entering the line, a teller becoming available, the manager deciding whether or not to open a new teller window, etc. In a Discrete Event Simulation, the flow of time is kept by maintaining a Priority Queue of Events instead of an explicit clock. Time is incremented by popping the next event in chronological order (the minimum event time) off the queue and processing as necessary. **The Design** I've got a Priority Queue implemented as a Min Heap for now. In order for the objects of the simulation to be processed as events, they implement an ISimulationEvent interface that provides an EventTime property and an Execute method. Those together mean the Priority Queue can schedule the events, then Execute them one at a time in the correct order and increment the simulation clock appropriately. The simulation engine is a basic event loop that pops the next event and Executes it until there are none left. An event can reschedule itself to occur again or allow itself to go idle. For example, when a Generator is Executed it creates an Entity and then reschedules itself for the generation of the next Entity at some point in the future. **The Question** _How should I handle logging metrics in my Discrete Event Simulation engine?_ In the midst of this simulation, it is necessary to take metrics. How long are Entities waiting in the Queue? How many Acitivity resources are being utilized at any one point? How many Entities were generated since the last metrics were logged? It follows logically that the metric logging should be scheduled as an event to take place every few units of time in the simulation. The difficulty is that this ends up being a cross-cutting concern: metrics may need to be taken of Generators or Queues or Activities or even Entities. Consider also that it might be necessary to take derivative calculated metrics: e.g. measure a, b, c, and ((a-c)/100) + Log(b). I'm thinking there are a few main ways to go:   1. Have a single, global Stats object that is aware of all of the simulation objects. Have the Generator/Queue/Activity/Entity objects store their properties in an associative array so that they can be referred to at runtime (my chosen language doesn't support reflection). This way the statistics can be attached as needed `Stats.AddStats(Object, Properties)`. This wouldn't support calculated metrics easily unless they are built into each object class as properties somehow.   2. Have a single, global Stats object that is aware of all of the simulation objects. Create some sort of ISimStats interface for the Generator/Queue/Activity/Entity classes to implement that returns an associative array of the important stats for that particular object. This would also allow runtime attachment, `Stats.AddStats(ISimStats)`. The calculated metrics would have to be hardcoded in the straightforward implementation of this option.   3. Have multiple Stats objects, one per Generator/Queue/Activity/Entity as a child object. This might make it easier to implement simulation object-specific calculated metrics, but clogs up the Priority Queue a little bit with extra things to schedule. It might also cause tighter coupling, which is bad :(.   4. Some combination of the above or completely different solution I haven't thought of? Let me know if I can provide more (or less) detail to clarify my question! I may be in error using the Aspect-Oriented tag, but I suspect that people of that background would have good advice for this situation.


Fixing a spelling mistake in a method name

One of the methods that I commonly use in our codebase is misspelled (and it predated me). This really irritates me not simply because it is mispelled but more importantly it makes me ALWAYS get the name wrong the first time I type it (and then I have to remember "Oh, right, it should be mispelled to this...") I'm making a few changes around the original method. Should I take the opportunity to just rename the freaking method?


Good books to learn distributed computing

Are there any good books to learn about distributed computing ? I work on large scale java applications. Recently my colleagues started talking about things like distributed cache, load balancing, BigMemory (Terracotta thing),parallel processing etc., Is there any good book that gives an introduction to these concepts.


Restricting object types that can be added to each other using the Composite Pattern

**_The Situation** :_ I am building a custom PHP application framework. I have implemented a composite pattern so I can build a object tree representing the page to be rendered. Example:               abstract class \Block\BlockAbstract {          protected _blocks = array();          public function __construct($properties);          public function getBlocks();          public function addBlock($block);               ...               public function render();          }      All of my "block" object inherit from this abstract class which is working out great and rendering has been a snap with the help of a little recursion. **_The Problem** :_ I need a way to validate what classes of blocks can be added to other blocks. For example I have 4 distinct block types I have to consider. Keep in mind that ALL blocks inherit from a single block abstract, these are classifications of behavior of the concrete classes, not to be confused with additional abstracts:   * Generic - Generics can have any other block type added to it    * Final - Can not have any child blocks added to it.   * Parent - A parent is a block that can only have a specific type child added to it, but can be added to any Generic    * Child - Can only be added to a specific parent. This block can also share the properties of a Generic, Parent or Final **To sum the goal up:** Given a concrete block class name, generate a list of all concrete block classes that can be added to it. **_Solutions Proposed So Far** :_ _Add a property called "blockClassification" to the block abstract that defines it as a Generic, Final, Parent or Child and hard code the logic into a validate function that gets called in the from the addBlock($block) method._ I don't like this solution for a number of reasons, but mainly it still doesn't give me a clear path for defining what the concrete parents and children are that can be allowed. For instance, I have a concrete class _\Block\Tabs_ that is a parent. It can only have _\Block\Tabs\Panel_ blocks added to it, and _\Block\Tabs\Panel_ can only be added to _\Block\Tabs_. Additional properties would have to be added to build those relationships, and those properties could be examined to derive the "block classification" making this approach impractical. _Add allowedChildTypes property to the block that defines a list of concrete classes that can be added. For ease of use 2 values have specific meaning, a * that represents all block types, and NULL value that means no blocks can be added. For all other cases a coma delimited string of class names is provided and only those classes or classes that inherit from them are allowed_ I'm leaning towards this direction because PHP gives me the InstaceOf operator. I can use this to do the checks, when I have new concrete classes that extend the base set, that check will return the same results as its parent class. My only hesitation is that while this method definitely solves the problem of "Given a concrete block class name, generate a list of", I feel like it limits me in the future in that I can only do the search down the tree and not back up. I.e. "Given a child block class name, generate a list of parent blocks it can be added to" I'm sure that I am not the only one to ever run into the problem, so my question to the masses is: What is the best way to approach/solve this problem? **Additional Information:** If you where wondering how I'm getting a list of all the classes in the first place, the framework implements PSR-0 so I am scanning the directory tree to derive all of the class names, then dynamically instantiating them.               $allClassNames = scanDirectories(); // Returns array of strings ex: array('\Block\Classname1','\Block\Classname2');      foreach($allClassNames as $className){       $object = new $className();     }


Object Oriented Design of a Small Java Game

![enter image description here](http://i.stack.imgur.com/VBqAi.png) This is the problem i am dealing with. I have to make a simple game of NIM. I am learning java using a book so far i have only coded programs that deal with 2 classes. This program would have about 4 classes i guess including the main class. My problem is i am having a difficult time designing classes how they will interact with each other. I really want to think and use a object oriented approach. So the first thing i did was design the Pile CLASS as it seemed the easiest and made the most sense to me in terms of what methods go in it. Here is what i have got down for the Pile Class so far.               package Nim;          import java.util.Random;          public class Pile {              private int initialSize;                   public Pile(){              }              Random rand = new Random();              public void setPile(){                  initialSize = (rand.nextInt(100-10)+10);         }                   public void reducePile(int x){                  initialSize = initialSize - x;         }                   public int getPile(){                  return initialSize;         }                   public boolean hasStick(){                  if(initialSize>0){                      return true;             }                  else             {                 return false;             }         }          }      Now i need help in designing the Player Class. By that i mean i am not asking for anyone to write code for me as that defeats the purpose of learning i was just wondering how would i design the player class and what would go on it. My guess is that the player class would contain method for choosing move for computer and also receiving the move human user makes. Lastly i am guessing in the Game class i am guessing the turns would be handeled. I am really lost right now so i was wondering if someone can help me think through this problem it would be great. Starting with the player class would be appreciated. I know there are some solutions for this problem online but i refuse to look at because i want to develop my own approach to such problems and i am confident if i can get through this problem i can solve other problems. I apologize if this question is a bit poor but in specific i need help in designing the Player class.


How do I move away from the “for-loop” school of thought?

This is a rather conceptual question, but I was hoping I could get some good advice on this. A lot of the programming I do is with (NumPy) arrays; I often have to match items in two or more arrays that are of different sizes and the first thing I go to is a for-loop or even worse, a nested for-loop. I want to avoid for-loops as much as possible, because they are slow (at least in Python). I know that for a lot of things with NumPy there are pre-defined commands that I just need to research, but do you (as more experienced programmers) have a **general thought process that comes to mind when you have to iterate something?** So I often have something like this, which is awful and I want to avoid it:               small_array = np.array(["one", "two"])     big_array = np.array(["one", "two", "three", "one"])          for i in range(len(small_array)):         for p in range(len(big_array)):             if small_array[i] == big_array[p]:                 print "This item is matched: ", small_array[i]      I know there are multiple different ways to achieve this in particular, but I am interested in a general method of thinking, if it exists.


In which stage of compilation is "typedef" resolved by the compiler?

There are different stages of compilation Such as   * Preprocessing stage   * Syntax analysis   * Semantic analysis   * Intermediate Code generation   * Machine Code generation   * Optimization   * Linking My question here is in which stage of compilation _"typedef"_ is resolved.


Input to program without command-line arguments

Let's assume that there are no command-line arguments. How do you pass input data to a program? I'm thinking you'd write the input to a file with a specific name, such that the program knows to open and read it as input. However, how would one discover the name of that file? Usually, running a command-line program without arguments or with some standard help argument (e.g. `\?`) produces some instruction on how to use it. But given an environment with no command- line arguments, how does one discover how to operate a program?


Windows Service or Windows Task Scheduler?

I am planning to create a utility, which will query the database and store some information (on another table in the database). Its a multi-threaded utility and require to run for every 5 or 10 minutes/later may be thrice in a day. I see two options to achieve this in C#/DotNet programming.   * creating windows service having timer approach inside it.   * a console program and schedule it using windows task scheduler. Which one do you prefer and why?


Is there evidence that developers working remotely are less productive then when they work onsite?

So I was speaking to one of the folks I work with here a few days ago, and they were complaining that their company no longer allows workers to work remotely at all any more due to the decrease in productivity. As someone that has heard this excuse used for justifying onsite only staffing in my search for remote opportunities, I'm wondering if there's any empirical evidence that confirms this at all or if I and others that I know in the industry are being told a tale.


What is the best approach for database design with lots of columns?

I am writing a query based financial application. It lets the user to write complicated equations (much like WHERE part of an SQL query) and find companies matching those criteria. For the above, I currently have more than 500 columns in the database table (each column representing a financial field). Example of Columns are: company_name, sales_annual_00, sales_annual_01, sales_annual_02, sales_annual_03, sales_annual_04, protit_annual_00, profit_annual1...(over 500 such columns). The number of rows is around 5000. Going forward, I would like to further increase the number of columns/financial-fields. For the above I would like to get help regarding: 1) What is the best database design approach? Is it ok to have these many number of columns? 2) How can it be normalized? (User can use any of these fields in search criteria). 3) Is it ok to stick with MySQL, or modern document based databases like MongoDB should be better for it? P.S. (Update): I have been using MySQL till now and a running example of the usage is at: http://screener.in/companies/89/Formula-- In above there around 500 fields/columns to create your query on, however, I seek to increase that number to much more in future.


Extra class for writing data to some backend?

What is the common practice to write classes which take some data class and store it to some backend? In my case I have table classes (columns, headers, etc.) which are written to Excel. So I have a class Table with the data and a class ExcelDocument with access operations and basic writing (cells, ...). Where would I put the code which knows how to deal with Table data and knows how to write that the ExcelDocument? Both might be subject to refactoring at some point. Do I use `Table.write_to_excel(excel)` or `ExcelDocument.write_table(table)` or even some need intermediate class? With the concept "a class should serve just one purpose" I'd most likely write an intermediate class?


Reporting Logic vs Domain Logic

Should the reporting logic to extract domain data in a certain format reside in domain objects or separate reporting objects? The reporting logic needs to:   1. select entities/data which match selection criteria e.g. date range   2. apply data validation rules e.g. date range, boundary values, missing values   3. apply type of reporting specific validation rules a. The rules will vary depending on type of domain object i.e. a certain domain object will require additional rules or different rule validation logic   4. transform data in certain format              a. Depending on domain object, number of fields may vary in the output      Solution Design   1. Should there be parallel hierarchy between reporting classes and domain classes?   2. The reporting classes will interact with domain classes through domain class interface   3. A context object would be needed to create domain object specific validator objects so that report generator can have generic logic Does this look like a good approach or am I approaching it incorrectly? ![Class Diagram](http://i.stack.imgur.com/QrCSY.png)


How to convince management of making our project open source?

Xamarin 3 was released last week with a great new addition: Xamarin.Forms . This triggered our attention because we've been using such a system for a couple of years now. We've developed it by ourselves and used it for a bunch of projects. We've been looking for a way to make this project open source but we didn't manage to convince the management. They believe we should not make it open source because we won't win anything with it and all that will happen is that the competition will be able to build apps quicker with our library. We believe open sourcing our library will make the world a better place and that it will make our library much more stable and complete. So my question to all you people out there: How can we convince the management to open source our library?


Was .NET's IObserver<T> intended for subscribing to multiple IObservables?

There are IObservable and IObserver interfaces in .NET (also here and here). Interestingly, the concrete implementation of the IObserver does not hold a direct reference to the IObservable. It doesn't know who it's subscribed to. It can only invoke the unsubscriber. "Please pull the pin to unsubscribe." **edit:** The unsubscriber implements the `IDisposable`. I think, this scheme was employed to prevent the lapsed listener problem. Two things are not entirely clear to me, though.   1. Does the inner Unsubscriber class provide the subscribe-and-forget behavior? Who (and when exactly) calls `IDisposable.Dispose()` on the Unsubscriber? Garbage collector (GC) is not deterministic.   [Disclaimer: overall, I've spent more time with C and C++ than with C# .]   2. What should happen if I want to subscribe an observer K to an observable L1 and the observer is already subscribed to some other observable L2?              K.Subscribe(L1);     K.Subscribe(L2);     K.Unsubscribe();     L1.PublishObservation(1003);     L2.PublishObservation(1004);      When I ran this test code against MSDN's example, the observer remained subscribed to L1. This would be peculiar in real development. Potentially, there are 3 avenues to improve this:     * If the observer already has an unsubscriber instance (i.e. it’s already subscribed), then it quietly unsubscribes from the original provider before subscribing to a new one. This approach hides the fact that it’s no longer subscribed to the original provider, which may become a surprise later.     * If the observer already has an unsubscriber instance, then is throws an exception. A well-behaved calling code has to unsubscribe the observer explicitly.     * Observer subscribes to multiple providers. This is the most intriguing option, but can this be implemented with IObservable and IObserver? Let’s see. It is possible for the observer to keep a list of unsubscriber objects: one for each source. Unfortunately, `IObserver.OnComplete()` does not provide a reference back to the provider who have sent it. So, the IObserver implementation with multiple providers would not be able to determine which one to unsubscribe from.   3. Was .NET's IObserver intended for subscribing to multiple IObservables?   Does the textbook definition of the observer pattern require that one observer has to be able to subscribe to multiple providers? Or is it optional and implementation-dependent?


Create Database To Fit Data vs Make Data Fit The Database

I'm newish to programming and would like to know what people have found to be the most supportable option or rather what people find more understandable. I'm the only one writing code at my firm, but gradually will hand this off to someone else in the future. **The Project** The project I'm working on is parsing a huge text file that comes in once a day. The data file uses previous day's data file as a reference so each data file builds upon the previous data file. Using documentation I'm able to parse the text file and populate a MySQL database. Once the text file has been read, the data in the database is manipulated and then dumped into many Excel workbooks. The text file has a huge amount of data and I only need a fraction of it for the Excel workbooks. **My Question** My question is what is the proper structure for this program? I see that I have two options.   1. Is it better to construct a database that fits the data. So create a database with more tables and fields then is actually needed and possibly a little cryptic in it's layout.   2. Is it better to manipulate the data while it's being parsed and put it into more readable, human database? **What I've Done So Far** When I wrote the first version of this program, I went for option 2. Since I didn't know much about relational databases at the time and wanted it very easy for me to understand, visualize, etc. However, now that I'm looking to expand the data that I parse from the text file and since each data file builds on the previous day's data file I'm leaning towards option 1 so later down the line I won't have to spend a day reconstructing the database. Does this make sense? Please comment if it doesn't. Any help would be greatly appreciated. thanks, Justin **Update** Let me start by saying the answers so far have been very helpful. Thank you. After reading some comments though I find that I have been a bit vague in my question. Let me try to be a bit clearer. I'm dealing with financial data of clients. Each account has its own Excel workbook that is used by the financial advisors to make projections and investment decisions. Additional worksheets in the the workbook are used to display the account's holdings and projected future to the client. The data that I get in each data file is separated by a record. Each record has a type...there are something like 13 different record types. Each record type is marked by a particular letter or number. Then after that letter or number there are a specific number of characters that represent that particular record. The record layout differs per record type and there is redundant information between record types which makes it additionally aggravating. Another point of contention is that if the financial advisor buys a new security, one that s/he hasn't bought before then the next business day, only in that day's data file, will the security's information show up (such as the name, security type, etc) and not again unless there's a change in that security. So if I ever need to rebuild the database I would have to start from day one. So I'm taking this data file, parsing it and writing it to a MySQL database separated into about four tables. I use EF6 to work with the database, and so that was a reason I started with a simple, readable fields and tables. Hope this expanded explanation helps.


Practical size limits of a DataTable in c#

I have to query a large data-set (~500 MB) using a sqlDataReader but I have to save the data in three different formats. Instead of querying the database 3 times I'm thinking about saving the data to an in-memory table and then save the data from there. Is there a practical limit to a table size in memory? Any ideas for a better approach? Thanks!


In general, which is better: Nested Grids, or Grids that include controls using Column/Row Spans?

This question has been in the back of my mind since I started with WPF and Silverlight. **In general, is it better to use nested grids, or just set the Column/Row Span properties in a single Grid?** Better could be measured in many ways (not limited to these): * Easier to read * Easier to maintain and/or extend * Better performance * Quicker to implement/type For example, consider that I want to divide my view into three regions. One region spans the width of the top half of the page. The other two regions each span half of the bottom of the page. I'll attempt to draw it in text:               ---------     |   1   |     ---------     | 2 | 3 |     ---------      The heart of the question is, "which of these two solutions to the example is better and why?" Solution 1:               <Grid>       <Grid.RowDefinitions>         <RowDefinition />         <RowDefinition />       </Grid.RowDefinitions>       <Grid.ColumnDefinitions>         <ColumnDefinition />         <ColumnDefinition />       </Grid.ColumnDefinitions>            <TextBlock Grid.Row="0" Grid.Column="0" Grid.ColumnSpan="2">1</TextBlock>            <TextBlock Grid.Row="1" Grid.Column="0">2</TextBlock>            <TextBlock Grid.Row="1" Grid.Column="1">3</TextBlock>     </Grid>      Solution 2:               <Grid>       <Grid.RowDefinitions>         <RowDefinition />         <RowDefinition />       </Grid.RowDefinitions>            <TextBlock Grid.Row="0">1</TextBlock>            <Grid Grid.Row="1">         <Grid.ColumnDefinitions>           <ColumnDefinition />           <ColumnDefinition />         </Grid.ColumnDefinitions>            <TextBlock Grid.Column="0">2</TextBlock>            <TextBlock Grid.Column="1">3</TextBlock>            </Grid>     </Grid>      I realize that there probably is no "correct" answer. Both solutions work, and are not greatly different. My hope is to gauge which one is more often done in the community at large. If there is a convention that is often followed I hope to learn it.


Is it okay if we use an arbitrary string as UUID?

I found the **tutorial of client (android) and server (pc) bluetooth** tutorial from here. But my question is **about the UUID.** **Is that okay if we define it randomly without the proper format**? Because I heard UUID is generally for ID for each devices just like IP address used right? For example like this, instead of the following code:               UUID.fromString("00001101-0000-1000-8000-00805f9b34fb");      I define my own UUID               UUID.fromString("myDeviceName009");      Is it okay? I mean is it if i tested on both android device using the above code, they could communicate each other?


Did concept of ViewModel exist before MVVM?

Today I was having a discussion with a colleague that ViewModel is a general concept and existed before MVVM pattern. I believe ViewModel term is used anytime you create a class with Model like properties for showing on View that supports data binding like in ASP.NET and even in WinForms. Is the opposite true? Did Microsoft name it the first time with MVVM?


equivalence in callback and non-callback javascript

I'm pretty sure that the following two snippets are equivalent but I wanted to double check: **CALLBACK STYLE**               function foo(input, callback) {         // do stuff with input              callback();     }          function bar(input, callback) {         // do stuff with input              callback();     }          foo("hi", bar("bye", function() {                            // do something cool                          }));      _Note that the callbacks take no arguments._ **PLAIN STYLE**               function foo(input) {         // do stuff with input     }          function bar(input) {         // do stuff with input     }          foo("hi");     bar("bye");     (function() {         // do something cool     })();      Of course if they are equivalent it would make sense to me to use **PLAIN STYLE** as it's simpler and cleaner. I realize the scope of the anonymous function (who does something cool) is different in the two cases.. I'm not concerned with that aspect of "equivalence". **UPDATE** I'm working on some legacy code and find quite a bit of it confusing. This is the original code that prompted this question. Specifically the noted 6 or so lines of code.               var CoolNamespace = (function () {         var container_element,             keysLength = 0;              //         // THE FOLLOWING 6 OR SO LINES IS WHAT I'M CURIOUS ABOUT         //         _createCoolObject(function (coolObject) {             _appendFrameToContainer(coolObject, function () {                      // Post form                 _sendForm(function (form) {                     container_element.appendChild(form);                     form.submit();                 });             });          });              function _sendForm (callback) {             // Sends client data via post.             if (keysLength != 0) {                 var form = _createForm();             } else {                 throw new Error("error message stub");             }             callback(form);         }              function _appendFrameToContainer (frame, callback) {             if (typeof container_element != "undefined") {                 container_element.appendChild(frame);             } else {                 throw new Error("error message stub");             }             callback();         }              function _createCoolObject (callback) {             var coolObject = { level: "very cool" };                  callback(coolObject);         }              function _handleMessage (event) {             // it's not really about this function         }              function _createForm() {             // it's not really about this function either             var form;             return form;         }     })();      When stepping through the code, it seemed to be the case that the body of `_createCoolObject` was invoked _before_ the argument (which is a function). I think my confusion was that a the argument to `_createCoolObject` is a function literal which evaluates to a function but that function _is not itself evaluated_ until the line `callback(coolObject)`. Thanks for the clarification!!


Is ClickOnce Deployment deprecated?

One of my internal users is having a problem with an application built by one of our long-retired developers. The application works fine on Windows XP, but in Windows 7 there is a problem with it. The application was originally developed as a ClickOnce application in .NET 2.0, something neither I nor any of our current devs know anything about. The question is, should we try to continue keeping this app as ClickOnce, or has it been deprecated in some way? Apparently ClickOnce applications can still be developed in VS2013, so it is do-able. But SHOULD we do it? I'd rather make this a web application, actually, and put it out on our intranet.


Which hashing algorithm is best for uniqueness and speed? Example (good) uses include hash dictionaries. I know there are things like SHA-256 and such, but these algorithms are **designed** to be **secure** , which usually means they are slower than algorithms that are less _unique_. I want a hash algorithm designed to be fast, yet remain fairly unique to avoid collisions.


Finding duplicate files?

I am going to be developing a program that detects duplicate files and I was wondering what the best/fastest method would be to do this? I am more interested in what the best hash algorithm would be to do this? For example, I was thinking of having it get the hash of each files contents and then group the hashes that are the same. Also, should there be a limit set for what the maximum file size can be or is there a hash that is suitable for large files?


Command line options style - POSIX or what?

Somewhere I saw a rant against java/javac allegedly using a mix of Windows and Unix style like               java -classpath ... -ea ... Something      IMHO, it is no mix, it's just like `find` works as well, isn't it? AFAIK, according to POSIX, the syntax should be like               java --classpath ... --ea ... Something      and `-abcdef` would mean specifying 6 short options at once. I wonder which version leads in general to less typing and less errors. I'm writing a small utility in Java and in no case I'm going to use Windows style `/a /b` since I'm interested primarily in Unix. What style should I choose?


Things to do to get better as a Software Development Group

What are some of the things that a team should do to get better as a Software Development group? The group is involved in doing intranet development/general support for various internal groups within the company?


How do I read API documentation?

I've been trying to read through the RoR API to try to learn things that the tutorial missed, and I haven't been able to follow it at all. The only time I've read documentation was when I needed to look up a Python module, and that was easy to understand, but I can't understand the docs for Rails. How do I read through API documentation?


Intellectual Property for in house development

My company is a sub contractor on a major government contract. Over the past 5 years we've been developing in house applications to help support our company and streamline our work. Apparently in 2008 our president of the company at that time signed a continuation of services contract with the company we subcontract with on this project. In the contract amendment various things were discussed such as intellectual property and the creation of new and existing tools. The contract states that all the subcontractor's tools/scripts/etc... become the intellectual property of the main contractor holder. Basically all tools that were created in support of the project which we work on are no longer ours exclusively and they have rights to them. My company really doesn't do software development specifically but because of this contract these tools helped tremendously with our daily tasking. Does my company have any sort of recourse or actions to help keep our tools? My team of developers were completely unaware of any of these negotiations and until recently were kept in the dark about the agreements that were made. Do we as developers have any rights to the software? Since our company is not a software development shop, we have created all these tools without any sort of agreements or contracts within the company stating that we give our company full rights to our creations? I was reading an article by Joel Spolsky on this topic and was just wonder if there is any advice out there to help assist us? Thank you Joel Spolsky's Article


Dynamic Permissions for roles in ASP.NET MVC

We have been developing a web application in ASP.NET MVC. We have scenarios where many actions on web page are dependent upon role of a specific user. For example a memo page has actions of edit, forward, approve, flag etc. These actions are granted to different roles and may be revoked at some later stage. What is the best approach to implement such scenarios?


Does anyone know of a simple (free?) feature request tracking system we could use internally for sales people?

I sometimes hear about pain points of customers using our app from sales people, but there really isn't a good way for us to currently keep track of these. I was going to write one myself but figured I would ask first. I was thinking something so simple it would literally just be a small form for adding a new feature, and then it would appear in the list, like stackexchange questions. Then users can upvote them, or even record each time a user complains about something related to the request so we can order them in priority based on real data. Then I can easily go look every few days and see what's going on. That's really it, nothing more complicated than that. Know of anything?


What makes Web crawling legal?

* When Google, Bing or Yahoo are crawling content from Web sites, what makes it legal? Is there a public registry of only allowed crawlers?    * When researchers are crawling Deep Web, what makes their efforts legal?   * When tester automate their tests with Selenium or JMeter and hit same site multiple times, what makes their effort illegal? In each of those cases, an automate is consuming Internet bandwidth of the Web site, and copying their content. But some are considered legal, and other are not.


"A good programmer can be as 10X times more productive than a mediocre one"

I had read an interview with a great programmer (it is not in English) and in it he said that "a great programmer can be as 10 times as good as a mediocre one" giving reason for why good programmers are very well paid and why programming companies give many facilities for their employees. The idea was that there is a very large demand for good programmers, because of the above reason and that's why companies pay very much to bring them. Do you agree with this statement? Do you know any objective facts that could support it? Edit: The question has nothing to do with experience; if you talk about one great programmer with 1 year experience then s/he should be 10 times more productive than a mediocre programmer with 1 year experience. I agree that from certain experience years onwards, things start to dissipate but that's not the purpose of the question.


What is the easiest way to migrate your current programming environment to a new laptop?

I have a WinXP based laptop with pretty basic hardware configuration by today's standards. I am planning to upgrade to a WinXP based laptop with a lot better hardware. The problem: My current laptop has truck loads of software like cygwin, perl, ruby etc. Installing each software manually is going to be pretty cumbersome. Not to mention customizing the packages. Is there any software (freeware or commercial, both okay) that can migrate my current programming environment with minimum fuss?


Giving a presentation on "code style and design patterns"

My company (small, about 40 people across 3 offices) occasionally does "developer workshops" online where one of the devs hosts a presentation about some tech topic. It's not necessarily about our work, but just to help everyone improve their skills and understanding. I've been asked to host the next one, and the topic (chosen from a list I provided) is code style and design patterns. I know those things aren't that closely related but bear with me. I have seen many places in our code base that could be improved, some which may even qualify for DailyWTF, so I want this presentation to be as effective as possible. The problem is that I just don't know exactly what to cover in one hour. My first idea is to use our own code as an example, to drive home the point of "please actually apply this to your work." But the topic is so broad. Some things wrong with our code (PHP) include:   * Minimal OO. It's been improving lately, but there are still tons of global functions. It takes me a while to find things.   * Global config (opinion I guess). You can find $GLOBALS['blah'] scattered in just about every file.   * Inconsistent brace style. Sounds minimal, but this actually caused a syntax error to be pushed to origin five days ago, which still wasn't corrected as of yesterday.   * Inefficient constructs. I was able to do some basic improvements that cut running time in some areas by 70%. I want this thing to be as useful as possible, without sounding condescending to my coworkers. So what aspects of "style" should I focus on, and which design patterns might be most useful to explain?


Data Structures: What are some common examples of problems where "buffers" come into action?

I was just wondering if there were some "standard" examples that everyone uses as a basis for explaining the nature of a problem that requires the use of a buffer. What are some well-known problems in the real world that can see great benefits from using a buffer? **Also, a little background or explanation as to why the problem benefits from using a buffer, and how the buffer would be implemented, would be insightful for understanding the concept!**


What's a good simple way to combat the n+1 problem?

I'm trying to better understand performance in PHP. One issue I'm thinking about is the n+1 problem. By n+1 I mean something like this:               $posts = Posts::getPosts();          foreach($posts as $post) {       $comments = Comments::getComments(array('post_id' => $post->id));       // do something with comments..     }      It's quite inefficient as we have to do many queries for every post to get the comments. Is something like this better? It's more PHP code but only two queries will be executed:               $posts = Posts::getPosts();          // get the ids into an array     $post_ids = array();     foreach($posts as $post) {       array_push($post_ids, $post->id);     }          // get comments for ALL posts in one query by passing array of post ids (post_id IN (...))     $comments = Comments::getComments(array('post_id' => $post_ids));          // map comments to posts     foreach($posts as $key => $post) {       foreach($comments as $comment) {         if($post->id == $comment->post_id) {           $post->pushComment($comment);         }       }     }          foreach($posts as $post) {       $comment = $post->comments;       // do something with comments..     }      This is much more PHP, and kinda messy too, but this time I'm only using two queries (one for posts, the other for fetching ALL comments of those posts in one query). Is this a good proposal to tackle the n+1 problem in PHP? Also, how do frameworks generally deal with this under the hood?


At what point/range is a code file too big?

I'm finding lots of 2-3k line files, and it doesn't really feel like they should be that big. What is a good criteria to objectively call a source code file "too big"?, is there such thing as a maximum amount of lines a source code file should have?


"Cross-cutting" domain in DDD

I've recently started studying Domain Driven Design and so far it looks like it will help tremendously with my team's current project. I'm running into a bit of a problem though actually determining _what_ the domains are in our project. After my inital pass, I ended up with something like this: ![Domains D & E overlapping A,B,C](http://i.stack.imgur.com/aJJYe.png) I have three domains: A, B, and C for different areas of the business. However, for each of those I need to track current data as well as create plans for the future. This led me to add a **Planning** domain, but I don't see a clear way to separate Planning from the other domains. Either A, B, and C need to have detailed knowledge of Planning or vice versa. Example: Let's say Domain A is "inventory". The implementation has messages for things like ItemsAdded and ItemsRemoved and it tracks quantities of various products. Then if I want to allow for planning of future quantities of items I need to add classes to the model which will allow me to associate future product info with various time windows. This kind of feels like a new domain except the same planning and time window logic also applies to Domain B and C. Essentialy, I have a cross-cutting domain. I feel like I must be looking at this the wrong way. Maybe I actually have 6 domains and a library used by 3 of them?


Is C# becoming harder to read?

As C# has progressed, many language features have been added. It has come to the point where it's becoming unreadable for me. As an example, consider the following code snip from Caliburn.Micro code here:                           container = CompositionHost.Initialize(                        new AggregateCatalog(                           AssemblySource.Instance.                                  Select(x => new AssemblyCatalog(x))                                    .OfType<ComposablePartCatalog>()                     )                 );      Now, this is just a small example. I have a number of questions:   * Is this a common or known problem?    * Is the C# community finding the same?    * Is this an issue with the language, or is it the style used by the developer? Are there any simple solutions to better understand others code and avoid writing code in this way?


Which ASP.Net programming model is closer to PHP?

I've been using ASP.Net WebForms for the last year or two at work for development, but I've used PHP for personal projects for 10 years. So, I'm far more adept at developing with PHP. When it comes to ASP.Net MVC, I have no experience with it because I've avoided it because I assumed it would just be a more complicated form of WebForms. Recently, I've been doing more research and it's sounding like MVC might be closer to what what I want. But, something I'm still not clear on is which ASP.Net programming model is closer to developing with PHP.   * My biggest complaint about ASP.Net WebForms is the "magic boxes." Namely the View State, and ScriptManager.   * I don't like that WebForms messes with my client side HTML/JavaScript/CSS. WebForms does a lot of this including, but not limited to:      * Inserting JavaScript that I can't modify and have to rely on Microsoft to ensure cross-browser compatibility.      * Forcefully changing the `name` attributes of tags that make use of `runat="server"`.      * Wrapping the contents of a `<form>` with a `<div>` tag.      * Forcing wrapping everything inside one big `<form>` tag.   * Everything in WebForms feels like it's catered to in-experienced web-developers who only know how to write Windows applications with .Net.      * Standard names for tags and attributes are changed when using `<asp:xxx>` tags. For example, instead of an anchor (`<a>`) tag, it's a "hyperlink" (i.e. `<asp:HyperLink>`). Instead of `href=` it's `NavigationUrl=`.      * The event driven model.    * I also don't like the complete separation of server side code from the client side code. I miss being able to do things like this...

              Name	              Age
          <? foreach( $people as $person ) { ?>
              <?= $person->name ?>	              <?= $person->age ?>
          <? } ?>
      So, with these points in mind, which programming model is closer to development with PHP (i.e. do the annoyances of WebForms that I've listed here exist in MVC)? * * * _Note: I have found ways around many, if not all of these annoyances, but did not feel the solutions I use are revelent to the question at hand._


Matching weighted unbalanced Bipartite graph

I am looking for a way to solve an assignment problem, but I am having some problems finding the correct algorithm to use. I have 2 list of nodes A and B, and in my problem may the length of A not be equal to B. In addition, the node a in A may not be a potential match with all nodes in B. The preference is given by a double where 0 is not interested to 1 that is very interested and then remove all matches with an edge of 0 after (As there might be matches that is impossible). If a have a preference of x to b, will b have the same preference to a. Example graph: ![Example graph](http://i.stack.imgur.com/at6uT.jpg) I am interested in creating the most optimal matching, meaning that to sum of the edges are the largest possible. In the example above would I be interested in the matching (1,1) and (3,2) leaving 2 in the left row unmatched, with a total edge weight of 1.9. I have been looking at the stable marriage and the Hungarian algorithm but both these algorithm requires there to be an equal amount of nodes on each side, and they do not find the greatest total edge weight. (Greatest or lowest is fines as I can just invert the edge weight) Can any of you point me towards an algorithm that will solve this problem for me?


ftp plugin for sublime text with active editing support

i use notepad++ with npp ftp plugin for editing webpages.I would like to have a similar plugin for sublime text. what i want to achieve by ftp plugin for sublime text is same functionality of npp ftp plugin.   1. Npp ftp plugin provides sidebar view of files.   2. npp ftp plugin allows to download file and make changes , whenever file change is made , the file in ftp server is also updated by just saving the file. issue with sublimetext ftp plugin is it doesnt allow active editing of ftp files. file i download is not linked to server.so i have to manually upload every time to see change.


HTTP resource bundling/streaming practice

Our SPA (plain HTML and Javascript) makes use of huge volume of javascript and other resources that are downloaded via XHR. Given the sheer number of components and browser simultaneous request limits, we're thinking for ways to deliver our resources in a more efficient manner. A method we're considering is bundling several resources that logically form a coherent group into a single file; thus reducing down to only one XHR (per group). Furthermore to make it more responsive, we'd like to constantly inspect the partial responseText during the LOADING state, determining if a usable chunk (atomic resource) has already been downloaded, and make it available for deserialization/processing even before the XHR is DONE. (a stream-like experience) We're thinking surely somebody else would've considered roughly the same approach before, but haven't really come across any library/framework or container file format that is suitable for our scenario. Anybody else know of something similar?


Agile - Spikes and the Overall Timeline

Team is starting on their first capital-A Agile project, and the project seems like it will fall in line nicely with the methodology (i.e. we can probably just grab an agile book and follow it like a recipe), with one bit of confusion: The project involves three things that nobody on the team has any experience with: Integrate with the Foo Payroll System, be able to handle the file type XYZ89 (where "XYZ89" = some file type you've never heard of), and convert some other files so they can be handled by the Frobnobdicator. As I understand it, standard Agile practice would be to schedule spikes for each of these, after which we can determine how long they're going to take (I'm not sure there's much of a chance that the client will decide not to do them, as they're pretty much solid requirements of the project) So my questions are:   1. Do we do all the spikes up front in the first iteration to get a better estimate of the time it's going to take to do them and/or get a "walking skeleton" up and running?   2. If not, wouldn't the total project schedule be at the mercy of one of these spikes coming back with data that this particular story will take way longer than we ballparked? **What is the best practice way to handle multiple spikes when they are basically non-negotiable requirements of a project?**


Hyperlinked, externalized source code documentation

Why do we still embed natural language descriptions of source code (i.e., the reason _why_ a line of code was written) within the source code, rather than as a separate document? Given the expansive real-estate afforded to modern development environments (high-resolution monitors, dual-monitors, etc.), an IDE could provide semi- lock-step panels wherein source code is visually separated from -- but intrinsically linked to -- its corresponding comments. For example, developers could write source code comments in a hyper-linked markup language (linking to additional software requirements), which would simultaneously prevent documentation from cluttering the source code. What shortcomings would inhibit such a software development mechanism? A mock-up to help clarify the question: ![Dual Editor Mockup](http://i.stack.imgur.com/JlUiE.png) When the cursor is at a particular line in the source code (shown with a blue background, above), the documentation that corresponds to the line at the cursor is highlighted (i.e., distinguished from the other details). As noted in the question, the documentation would stay in lock-step with the source code as the cursor jumps through the source code. A hot-key could switch between "documentation mode" and "development mode". Potential advantages include:   * More source code and more documentation on the screen(s) at once   * Ability to edit documentation independently of source code (regardless of language?)   * Write documentation and source code in parallel without merge conflicts   * Real-time hyperlinked documentation with superior text formatting   * Quasi-real-time machine translation into different natural languages   * Every line of code can be clearly linked to a task, business requirement, etc.   * Documentation could automatically timestamp when each line of code was written (metrics)   * _Dynamic_ inclusion of architecture diagrams, images to explain relations, etc.   * Single-source documentation (e.g., tag code snippets for user manual inclusion). Note:   * The documentation window can be collapsed   * Workflow for viewing or comparing source files would not be affected   * _How_ the implementation happens is a detail; the documentation could be:      * kept at the end of the source file;     * split into two files by convention (`filename.c`, `filename.c.doc`); or     * fully database-driven   * By hyperlinked documentation, I mean linking to external sources (such as StackOverflow or Wikipedia) and internal documents (i.e., a wiki on a subdomain that could cross-reference business requirements documentation) and other source files (similar to JavaDocs). Related thread: What's with the aversion to documentation in the industry?


How to get the average of an array?

Please correct the method "ave".               public class methods{         public static void main (String[] args){         int[] a = {1,2,3,4,5,6,7,8};         System.out.println("Sum is: " + sum(a));         System.out.println("Average is: " + ave(a));         System.out.println("Minimum is: " + min(a));         System.out.println("Maximum is: " + max(a));         System.out.println("Minimum appears: " + countmin(a) + " times");         System.out.println("Maximum appears: " + countmax(a) + " times");     }     //sum of the arrays     public static int sum(int[] array){         int sum = 0;         for (int i = 0; i < array.length; i++){             sum += array[i];         }         return sum;     }     //average     public static int ave(int[] array){             double ave;             for (int i = 0; i < array.length; i++){                 ave = sum(array)/array.length;             }             return ave;     }     //displays the smallest number     public static int min(int[] array){         int min = array[0];         for (int i = 0; i < array.length; i++){             if (array[i] < min)                 min = array[i];         }         return min;     }     //displays the biggest number     public static int max(int[] array){         int max = array[0];         for(int i = 0;i < array.length; i++){             if (array[i] > max)                 max = array[i];         }         return max;     }     //displays how many times the min appeared     public static int countmin(int[] array){         int countmin = array[0];         for(int i = 1;i < array.length; i++){             if (array[i] == min(array))                 countmin++;         }         return countmin;     }     //displays how many times the max appeared     public static int countmax(int[] array){         int countmax = 0;         for (int i = 1; i < array.length; i++){             if (array[i] == max(array))                 countmax++;         }         return countmax;     }     }


Immutable structures and deep composition hierarchy

I'm developing a GUI application, heavily working with graphics - you can think about it as a vector editor, for the sake of the example. It is very tempting to make all data structures immutable - so I could get undo/redo, copy/paste, and many other things almost without effort. Fot the sake of simplicity, I will use the following example - application is used to edit polygonal shapes, so I have "Polygon" object, which is simply list of immutable points:               Scene -> Polygon -> Point      And so I have only one mutable variable in my program - the one which holds current Scene object. The problem which I have starts when I try to implement point dragging - in mutable version, I simply grab a `Point` object and start modifying its coordinates. In immutable version - I am stuck. I could have stored indices of `Polygon` in current `Scene`, index of dragged point in `Polygon`, and replace it every time. But this approach does not scale - when composition levels go to 5 and further, boilerplate would become unbearable. I'm sure this problem can be solved - after all, there is Haskell with completely immutable structures and IO monad. But I just cannot find how. Can you give me a hint?


Would this be a good web application architecture?

**My problem** Our MVC based framework does not allow us to cache only part of our output. Ideally we want to cache all static and semi-static parts, and run dynamic parts. In addition, we need to consider data caching that reacts to database changes. **My idea** The concept I came up with was to represent a page as a **tree of XML fragment objects**. Some of the fragments are dynamic, and can pull their data directly from models or other sources, but most of the fragments are static scaffolding. If a subtree of fragments is completely static, then I imagine that they could **unfold** into XML that would then be cached as the text representation of their parent element. This process would ideally continue until we are left with a root element that contains all of the static XML, and has a couple of dynamic XML fragments that are resolved and attached to the relevant nodes of the XML tree just before the page is displayed. In addition to separating content into dynamic and static fragments, some fragments could be dynamic and cached. A simple expiry time which propagates up through the XML fragment tree would indicate that a specific fragment should periodically be refreshed. A newspaper section or front page does not need to be updated each second. Minutes or sometimes even longer is sufficient. Other fragments would be dynamic and uncached. Typically too many articles are viewed for them to be cached - the cache would overflow. Some individual articles may be cached if they are extremely popular. **Functional notes** The folding mechanism could be to be smart enough to judge when it would be more profitable to fold a dynamic cached fragment and propagate the expiry date to the parent fragment, or to keep it separate and simply attach to the XML tree when resolving the page. If some dynamic cached fragments are associated to database objects through mechanisms like a globally unique content id, then changes to the database could trigger changes to the output cache. If fragments store the identifiers of parent fragments, then they could trigger a refolding process that would then include the updated data. A set of pure XML with an ordered array of fragment objects (that each store the identifying information of the node to which they should be attached), can be resolved in a fairly simple way by walking the XML tree, and merging the data from the fragments. Because it is not necessary to parse and construct the entire tree in memory before attaching nodes, processing should be fairly fast. The identifiers of each fragment would be a combination of relevant identity data and the type of fragment object. Cached parent fragments would contain references to these identifiers, in order to then either pull them from the fragment cache, or to run their code. The controller's responsibility is reduced to making changes to the database, and telling the root XML fragment object to render itself. I would just like to make it clear that while I say XML, what I really mean is XHTML. The design generates and folds XHTML from the very start, without trying to add an additional step to transform the XML to XHTML. It's just functionally equivalent to XML. **UPDATE:** ![Modified MVC](http://i.stack.imgur.com/6rRmu.png) The design is still essentially MVC. Traditionally in Web applications, controllers make changes to models directly, _then_ load all the data from models, and send it to the view. The problem with this is that it's hard to do partial page caching. Most web applications spend most of their time in the DB. If the controller has to load the data from models _each time_ , then caching the view has no point, unless you cache the whole view and do no database queries. However, in Smalltalk, where the MVC pattern originally came from, views pulled data from models directly. " _The view gets its own data from the model._ " - MVC on Wikipedia If views pull their data from the models, and views are composed of other views, then it becomes trivial to cache the _output_ of views. If it does not need loading again, then it doesn't load, and it doesn't contact the DB. I am treating view output as XML/XHTML because we have a couple of tools that allow us to manipulate XML quite well, making the interweaving of static and dynamic fragments fairly simple. **The Question** My question has two parts:   1. Is this a good design? Are there any obvious flaws I'm missing?   2. Has somebody else thought of this before? References?   3. Is there an existing alternative that I should consider? A cool templating engine maybe?


Which license for commercial software?

At the moment we are writing modules for an open source cms. We would like to sell these with a license. But which are the best options? Any suggestions and experiences.


What is the possible disadvantage of putting declarations in inner blocks, instead of at beginning of function?

At the place where I work, there are explicit guidelines for placement of declarations of variables. According to that, it is required to put them at the global level and / or at the beginning of functions, and not in inner blocks (such as a for loop). Since they've been specified by persons more experienced than I am, I'm sure that there must be a good reason for it, but I cannot figure out what that might be. It would be nice to know if there are any compile time / run time advantages at having them declared at a bigger scope.


future in iphone development?

i have done btech,nw i am searching job but one big question arise me in front of me several times that as a **iphone developer** i can survive or not ? i learned nowdays iphone development but my seniors said to me after learn iphone development you become miniority developer why dont you start from java or .net or php plateform. but i feel my future safe in i phone developer?m i right or not ?i am totally confused?please help me and give valuable suggestions


Is it OK to use dynamic typing to reduce the amount of variables in scope?

Often, when I am initializing something I have to use a temporary variable, for example:               file_str = "path/to/file"     file_file = open(file)      or               regexp_parts = ['foo', 'bar']     regexp       = new RegExp( regexp_parts.join('|') )      However, I like to reduce the scope my variables to the smallest scope possible so there is less places where they can be (mis-)used. For example, I try to use `for(var i ...)` in C++ so the loop variable is confined to the loop body. In these initialization cases, if I am using a dynamic language, **I am then often tempted to reuse the same variable** in order to prevent the initial (and now useless) value from being used latter in the function.               file = "path/to/file"     file = open(file)          regexp = ['...', '...']     regexp = new RegExp( regexp.join('|') )      The idea is that _by reducing the number of variables in scope I reduce the chances to misuse them_. However this sometimes makes the variable names look a little weird, as in the first example, where "file" refers to a "filename". I think perhaps this would be a non issue if I could use non-nested scopes               begin scope1        filename = ...     begin scope2        file = open(filename)     end scope1        //use file here        //can't use filename on accident     end scope2      but I can't think of any programming language that supports this. **What rules of thumb should I use in this situation?**   * When is it best to reuse the variable?   * When is it best to create an extra variable?   * What other ways do we solve this scope problem?


Unit Testing and .Net

Coming from a native development background, I'm used to my unit test runners outputting the file and line that caused the test failure. This allowed me to run the tests as a post-build step, and if any test failed the build would fail. Also, I could press the hotkey and jump directly to the offending line. What I'm discovering in the .Net world is that no one appears to work this way. I'm willing to admit that perhaps there is a different, better way of doing things in this alternate universe, but I would like to know what that is. I don't want to need an external tool (awful), and I don't want to have to remember to compile and then run my tests. What I really want is what I used to have: failing tests also fail the build, and a quick press of a hotkey would jump me to the test that failed. Edit: I should add that I'd like to see some sort of integration with Visual Studio's csproj file format. Having a custom MSBuild Task would be great, but I'd be perfectly happy with a console command that I put inside an Exec or AfterBuild.


how to start with ASP.NET MVC 3 razor

I going to start a new project in my company in which are involved the use of MVC 3, now this is the first time that we are using this framework, and i have a couple of questions,   1. It's recommended to start with MVC3 and not from the MVC2?   2. Any Tutorials in specific that you can recommend?   3. This framework have full integration with jQuery?


When it comes to hosting your personal throw-away projects, does one service and project structure stand out?

I'm looking at Google Code, SourceForge, BitBucket, and GitHub, since they seem to be the big players. Now, I haven't broken down all of the features that they provide yet, but I'm really looking for a place to put various code that I write (my solutions for Project Euler, code that I might write for the Code Golf/Programming Puzzles Stack Exchange, and so on) in a centralized location. So, my first question is: For a situation like this, does one service stand out among the others? * * * Once I've chosen a service, I then need to choose how I'm going to distribute the code. There are a few options that I see for setting up the repositories and projects. A single repository can hold any number of projects - for example, I could have a "Tom Owens's Project Euler Solutions" repository for all of my various solutions to Project Euler, with projects for each language and environment in directories within this repository, another repository for my various Code Kata solutions and so on. Or I could break something like that down by language (have Project Euler solutions in Python in one repository, PE solutions in Java in another repository, and Code Kata C++ solutions in a third repository). My second question: Are there any limitations or conventions that exist for determining how you should share your code samples that you choose to make open, especially in terms of how you create your repositories? My thought is that this might be dictated by the service that you choose (based on the conventions of the community).


What should you leave behind for your successors?

Assume that you're a sole developer leaving a job. What kind of information/material, outside of the code itself, should you create and leave behind for your replacement? An obvious answer is "whatever you would want at a new job" for sure, but it's been a while since I started a new job, and I forget what the most important things that I needed were back then. I'm thinking:   * accounts/passwords   * location of equipment, backups, software CDs What else?


What makes documentation good?

I need to write documentation for several projects I worked on. I was wondering what, according to your experience, makes documentation useful and complete. What part should I include, how deep should I go in my explanation, etc? My target audience is developers. The purpose of the documentation is to make it easy to update or finish projects.


Rule of thumb for cost vs. savings for code re-use

Is it a good rule of thumb to always write code for the intent of re-using it somewhere down the road? Or, depending on the size of the component you are writing, is it better practice to design it for re-use when it makes sense with regards to time spent on it. What is a good rule of thumb for spending extra time on analysis and design on project components that have "some probability" of being needed later down the road for other things that may or may need this part. For example, if I have the need for project `X` to do things `A`, and `B`. `A` definitely needs to be written for re-use because it just makes sense to do so. `B` is very project specific at the moment, and I can hack it all together in a couple days to finish the project on time and give everyone kudos for being a great team, etc. Or if we say, lets spend a whole friggin' 2 weeks figuring out what project `Y/Z` might need this thing for and spend a load of extra time on on part `B` because someday we might need to use it on project `Y/Z` (where the savings will be realized). I'd imagine a perfect world situation would be a nicely crafted combination of project specific vs. re-use architected components given the project. However some code shops might feel it would be a great idea to write everything for the intention of using it at some point down the road.


Design for future changes or solve the problem at hand

While writing the code or during design do you try to generalize the problem at the first instance itself or try to solve that very specific problem. I am asking this because, trying to generalize the problem tends to complicate the things (which may not be necessary) and on the otherhand it will be very difficult to extend the specific solution if there is a change in the requirement. I guess the solution is to find the middle path which is easier said than done. How do you tackle this type of problem ? If you start generalizing it at what point of time you know that this much of generalization is sufficient ?


Agile: When to re-factor and when to extend while accruing technical debt?

Consider the following scenario. You currently have a feature set `A` you wish to extend to include feature set `B`. In the near feature there's a high possibility that you wish to extend this even further to include feature set `C`.   * Option 1) Cost to extend `A` -> `B` is minimal, but high maintenance costs.   * Option 2) Cost to refactor `A` and `B` to make more logical sense is moderate, but low maintenance costs. Extending to include feature set `C`:   * Cost to extend refactored(`A` & `B`) -> `C` is minimal, again low maintenance costs.   * Cost to extend A,B -> C is high, (both to refactor and extend). Assuming the inclusion of feature set `C` is beyond the scope of the current sprint, how do you go about choosing an option? How does this change if the addition of feature set C is several (2 or more) sprints out?


How to Know When to Stop Designing?

First some backgrounds, I'm interning at a company that makes parallel processing hardware. We're currently working out the design for a component of our driver that is supposed to evolve over a few generations of our products. The next gen is still in simulation phase and the specification we have now may change when we actually get the hardware. Our module is supposed to work on the current gen and all future gens. I've always been under the impression that a design should be as future- proofing as possible. In this case, we know exactly what to do for current gen hardware but are unclear on some fronts for the next gen. So my question is: **When do you know that you should stop designing for the future and just keep it simple and correct for what you know right now?**


Agile estimation with tech-debt

When estimating (story points) a story that consists on extending a current functionality with a known tech-debt, should we consider the effort that will be spent to refactor the current code or should we estimate independently of this tech-debt?


Built in Scala library slow?

I found this question and accepted answer on StackOverflow. It's related to the slow JSON parser in the standard Scala library. The consensus as it were, is that the build-in JSON library is slow, and, in the words of DMC: "it's like that, and that's the way it is" Maybe I'm just being naive here, but that sounds like a bad approach to grow the language. Shouldn't the _built-in_ libraries be perfect? They don't have to be everything for everyone, and I accept that Scala is extendable. But, if there is a built-in library, then surely it should be rock solid and as fast as the language have to offer. I'm lodging a complaint with Star Command ;-) Does anyone know where or how a normal guy like me can voice my opinion on this, i.e. where we can go to help shape the Scala language? Update: This question was not intended in any negative way. Scala, it's creators and the Scala community is choc-full off goodness. I was simply surprised to see that something like the built-in JSON parser was far from optimal (according to the question in the link provided)


Writing scripts for Visual Studio project

What is the best way to write and run small scripts and tasks that are specific to a particular .Net project? Such things as configuring a database or confirming proper connections to servers. In Ruby, I would build rake tasks for this sort of thing. I am currently using unit tests for these tasks as they are easy to run within VS and they have access to all the necessary libraries and project code. However, this is not really their intended purpose and, with the dropping of Test Lists in VS 2012, it does not work nearly as well as it used to. Is there a better solution than writing a console project to handle these little code snippets I need to run periodically?


Define which tests are run after build in Visual Studio 2012

Visual Studio 2012 has a new feature where it automatically runs your unit tests after every build. I would like to use this feature, but I have a number of tests that should not be run after every build (long running performance tests, etc). Is there a way to define which categories are run automatically? Or some other way to define which test should be run?


Methods of ordering function definitions in code

When I work on some programming project (usually command line application in Python with many switches), I'm usually creating about 30 and more functions. Most of the functions are in one file (except some helpers that I utilize in more projects). Some of the functions are called on particular switch (like -p or --print) but many functions do some helper computations, print operations or database operations because I don't want to main functions be too large. When I have an idea for a new functionality I often put new functions randomly to the file. Should I think more about it and place it to some particular place? Are there some methods for this?


Stored procedure Naming conventions?

One of our senior developers has stated that we should be using a naming convention for stored procedures with an "objectVerb" style of naming such as ("MemberGetById") instead of a "verbObject" type of naming ("GetMemberByID"). The reasoning for this standard is that all related stored procedures would be grouped together by object rather than by the action. While I see the logic for this way of naming things, this is the first time that I have seen stored procedures named this way. My opinion of the naming convention is that the name can not be read naturally and takes some time to determine what the words are saying and what the procedure might do. What are your takes on this? Which way is the more common way of naming a stored proc, and does a what types of stored proc naming conventions have you used or go by?


Could you blend java and javascript?

As a developer who spends most of my time in either Java or Javascript these days, I have this fantasy about a language that blends the two of them together. I'm always missing something from one or the other. I know neither is perfect, but to me, they both can be considered the mainstream, modern decendants of C. I know the popular opinion is that they are completely different languages with only superficial similarities (obviously the name, but also lots of syntactical similarities, especially at the statement and expression level). However, I think that in theory anyway, it should be possible to create a new language, which is essentially a superset of both Java and Javascript (non- strict, of course). Sure there would be challenges in making a language that is loosely typed in some places and strongly typed in others, compiled in some places and interpreted in others, etc.... but my gut feeling is that none of these would be show stoppers (except for those with open minds and good imaginations). Aside from issues of "where they run" (browser vs. server side, etc)....what are the issues that would come up, especially on the syntax side? How could you handle the situations where the two languages would otherwise conflict? What would it look like? I can appreciate it if you just think "it shouldn't be done" or "what a nightmare working in that language", but I'm hoping for responses from people with open minds and that have more to say than that...


What should I ask a prospective client during initial meeting?

I'm about to branch out into taking on some contracts on the side. What would be some good questions to ask of a potential client during a first meeting? I've thought of a few things that seem pretty obvious:   * What is the project?   * What are the deadlines?   * What's the budget?   * What/how do they want me to deliver the completed work?  Is that it, or are there any tricky things to watch out for?


What are the advantages of obfuscating release code?

The specific example I have in mind involves the currently-alpha game Minecraft, but this is a general question that I think warrants some conversation. Minecraft is written in Java, and stack traces usually look like this (real example):               java.lang.NullPointerException         at d.a(SourceFile:247)         at gi.b(SourceFile:92)         at bd.a(SourceFile:33)         at bn.a(SourceFile:69)         at bn.e(SourceFile:115)         at bn.d(SourceFile:103)         at net.minecraft.client.Minecraft.i(SourceFile:1007)         at net.minecraft.client.Minecraft.run(SourceFile:596)         at java.lang.Thread.run(Unknown Source)      Obviously these are not the real package and method names that the developer uses when he writes. Since he is in an alpha stage, it seems that the developer should like to be able to make sense of his stack traces, especially if someone is able to provide one for a bug report. As this stands, it's mostly meaningless. What advantage could one possibly hope to gain by obfuscating his code like this that overcomes the drawbacks of more difficult bug identification?


What should happen when code is reached that shouldn't be, according to business or logic rules?

I am currently writing an application that isn't huge but will be used through-out my company of 200+ people and external customers about projects we are working on (not software projects), but there are a fair amount of business rules, along with the implied ones that go with creating, verifying, and maintaining user accounts. Semi-often I find myself writing code like this               If (A)     {        foo();     }     else If (B)     {        foo2();     }     else     {        throw new exception("Should not happen because XYZ");     }      or               foo()     {        //do stuff            if (D == F)        {            throw new exception("Method should not be called if D==F, you forgot how to use this method");        }            //do other stuff     }      Is this code-smell because it implies that my code might break? Is this good a programming practice for debugging when things WILL go wrong? Is this being paranoid?


How should I handle exception that *should* never be thrown?

What is the best way to handle errors that shouldn't ever happen? My current way to do this is to throw an exception if the 'thing that shouldn't happen' **does** happen, like so:               /*      * Restoring from a saved state. This shouldn't be       * null unless someone in the future doesn't set it properly, in which       * case they will realize they did something wrong because it may crash.      */     Object foo = bundle.getSerializable("foo");     if (foo != null) {         doSomethingWith(foo);     } else {         // This should never happen.         if (BuildConfig.DEBUG) {             throw new RuntimeException(                 "Foo is null!");         }         foo = new Object();         doSomethingWith(foo);     }      This is somewhat pointless, because this _should never happen_. But just in case the code gets screwed up and is released into production with `foo` being null, should I leave these types of checks in the code?


Software License Web Application

We are in the process of building a web application for a client and they have inquired about owning the code for the site. We would like to issue a license agreement to the client for use of the code if we for any reason we are no longer working on the project. We would like to have ownership of the code but allow them use wherever they see fit, the only limitation we would like to have is the sale of the code. The are a company with several employees and will only be using the application within their company. What would such a license agreement look like?


Modularity and "encapsulation" in C

This applies to C (and probably to any other similar non-object oriented language). If I have a central data store and potentially concurrent access there are two ways I can see of protecting it. Let's say I have a data store with a few data elements...               struct MyStore     {         int data1, data2, data3, ...., dataN;     } store[M];      In this example the data types are the same but let's imagine this applies to something a bit more varied with different types etc... this is just to keep the question simple. To grant other users access to the data within I could do a few things.   1. Could provide critical region functions and rely on the caller to get the protection correct.   2. I could provide a setter and getter function for each data item type in the store and manage the critical regions within the module and protect the user from having to deal with any logic. My trouble with the first method is that the burden is placed on the caller. My trouble with the second, at least in C, is that firstly I end up writing a whole load of boiler plate accessors and secondly more complex stuff like test-and-set or needing to hold a lock on the data whilst doing several operations becomes messy. E.g. for method 2 I need               int GetData1(unsigned int index) {          int data;               ENTER_CR();          data = store[index].data1;          LEAVE_CR();               return data;     }          ...     ...          int GetDataN(unsigned int index) {          int data;               ENTER_CR();          data = store[index].dataN;          LEAVE_CR();               return data;     }      And the same for all the setters. And then what if I want to set multiple items atomically? Gets hard! How to get some of the benefits of modularity and encapsulation but still have a flexible interface?


Techniques to increase logic at programming

I am into programming since last 3 years. But I seems to be lost in it. I am not able to get good at it even though I code everyday. suppose I solve one problem, I will wander from solution to solution and implement some other solution. I cant focus much. I get many defects for the code I write. I afraid of code I dont know why if I dont finish it on time my boss will fire me etc. I enjoy coding but not all the time. How to increase patience? I always wonder how do I become the best coder like many exceptional programmers. I know this sounds subjective but I think this will help programmer community to get good at it especially for average like me or beginner programmers.


How to implement a branch-and-bound in a functional programming language?

I am trying to write a branch and bound search on the set of all functions f: D -> R, where the domain size is small (|D| ~ 20) and the range is much bigger (|R| ~ 2^20). Initially, I came up with the following solution.               (builder (domain range condlist partial-map)                 (let ((passed? (check condlist partial-map)))                   (cond                    ((not passed?) nil)                    (domain (recur-on-first domain range condlist partial-map '()))                    (t partial-map))))     (recur-on-first (domain range condlist partial-map ignored)                        (cond                         ((null range) nil)                         (t (let ((first-to-first                                   (builder (cdr domain)                                            (append ignored (cdr range))                                            condlist                                            (cons (cons (car domain) (car range)) partial-map))))                              (or first-to-first                                  (recur-on-first domain                                                  (cdr range)                                                  condlist                                                  partial-map                                                  (cons (car range) ignored))))))))      Here the parameter `condlist` to the function `builder` is a list of conditions that should be satisfied by a solution. The function `check` returns nil iff any element in the list of conditions is violated by the `partial-map`. The function `recur-on-first` assigns the first element in the domain to the first element in the range and tries to build a solution from there. Failing this `recur-on-first` invokes itself to try and construct a solution that assigns the first element in the domain to some element other than the first one in the range. However, it has to maintain a list `ignored` that stores these discarded elements (like the first element in the range) as they could be images of some other elements in the domain. There are two problems that I can see with this solution. The first one is that the lists `ignored` and `range` in the function `recur-on-first` are quite large and `append`ing them is an expensive operation. The second problem is that the recursion depth of the solution depends on the size of the range. So I came up with the following solution that uses doubly linked lists to store the elements in the range. The functions `start`, `next` and `end` provide facilities to iterate over the doubly linked list.               (builder (domain range condlist &optional (partial-map nil))                 (block builder                        (let ((passed? (check condlist partial-map)))                          (cond                            ((not passed?) nil)                            (domain (let* ((cur (start range))                                           (prev (dbl-node-prev cur)))                                      (loop                                        (if (not (end cur))                                          (progn                                            (splice-out range cur)                                            (let ((sol (builder (cdr domain)                                                                range                                                                condlist                                                                (cons (cons (car domain) (data cur)) partial-map))))                                              (splice-in range prev cur)                                              (if sol (return-from builder sol)))                                            (setq prev cur)                                            (setq cur (next cur)))                                          (return-from builder nil)))))                            (t partial-map))))))      The runtime of the second solution is much better than the runtime of the first solution. The `append` operation in the first solution is replaced by splicing elements in and out of a doubly linked list (these operations are constant time) and the recursion depth only depends on the size of the domain. But my problem with this solution is that it uses `C` style code. So my question is this. Is there a solution that is as efficient as the second solution but does not use `setf`s and mutable data structures? In other words, is there an efficient functional programming solution to this problem?


Should interviews for programming positions be CS knowledge focused or behavioral focused?

It appears that many interview related questions on this site are focused on testing traditional CS knowledge, such as:   * Algorithms   * Data structures   * Programming language/environments Obviously the site is called "programmers", so that is to be expected. However, I'd also argue that there are many other aspects that may be better predictors of a candidate's success (assuming that the candidate has a degree in CS from a good school and got good grades):   * Do they have a general love for programming and a continual interest in improving their skills?   * Are they willing to learn new skills?   * Are they willing to take the time to share their knowledge with and help others?   * Do they have a track record of success?   * Will the interviewee enjoy the type of work the company is doing and be dedicated to it?   * Did they work on similar projects or for similar companies before and enjoy them?   * Will they like the company's culture?   * Are they committed to seeing projects succeed? Is there more benefit in testing CS knowledge or behavioral aspects, or a combination?


How can I deal with the cargo-cult programming attitude?

I have some computer science students in a compulsory introductory programming course who see a programming language as a set of magic spells, which must be cast in order to achieve some effect (instead of seeing it as a flexible medium for expressing their idea of solution). They tend to copy-paste code from previous, similar-looking assignments without considering the essence of the problem. Are there some exercises or analogies to make these students more confident that they can, and should, understand the structure and meaning of each piece of code they write?


Is copy & paste programming bad?

With plain Google as well as Google Code search tools it is easy to find how to program using some resource or solve certain problems (such as create a Java class, or an FTP block in Perl, etc.). So developers are tempted to just purely copy & paste the code (in a way re-use). Is this an incompetency? I have done this myself, though I think I am a better programmer than many others I have seen. Who has the time to RTFM? In this age of information abundance, I do not think that copy & paste programming is bad. Isn't that what sites like Stack Overflow do anyway? People ask - OK, here is my problem - how to solve it? Now someone will post complete code and the person who asked the question would simply copy & paste the most voted answer. No matter how small the problem is. I am working with a bunch of young coders who heavily rely on the Internet to get their job done. I see convenience in copy/pasting and modifying code to get the job done. For example, you may be quite good with algorithms and such, but you may not know how to use a `BufferedReader` in Java - would you read complete the Javadoc for `BufferedReader` or look up some example of using it somewhere? What are the real dangers of copy & paste coding that can impact their competency?


Is there an idiot's guide to software licensing somewhere?

Basically, my knowledge on the issue is zilch other than the fact that open- source and closed-source exists. I'm a web developer (not a designer in the slightest), so I look online for things like icons. I've always been a big fan of these icons, which have a Creative Commons Attribution 2.5 License. As far as I can see, this license says 'do whatever you want with them as long as you have a link back to me _somewhere_ '. Is that assumption correct? Just today I found a new icon set, with a much more confusing license (found here), and to be quite honest I have no idea if I'm allowed to use them or not.   * At the moment I want to just use them for toy stuff that might never see the light of day, but then my source code is stored on Github, is it legal to store the icons there where they're publicly accessible?   * If I put them on my personal website that might have ads on it to make me five cents every now and then, is _that_ legal?   * If I use them on a site that offers a free service to users, is _that_ legal?   * If that site then starts making money (via things like paid subscriptions) or gets bought out by someone (highly unlikely but one day possible) is _that_ legal? Is there some noob guide out there that explains all this stuff, because I would hate to start using this sort of stuff now only to have to change it all later. Even if I buy the icons, there's still licensing issues that I don't understand! :( And this sort of stuff keeps popping up more and more often...


Moving all UI logic to Client Side?

Our team originally consisted of mostly server side developers with minimum expertise in Javascript. In ASP.NET we used to write a lot of UI logic in code-behind or more recently through controllers in MVC. A little while ago 2 high level client side developers joined our team. They can do in HTMl/CSS/Javascript pretty much anything that we could previously do with server-side code and server-side web controls:   * Show/hide controls   * Do validation   * Control AJAX refreshing So I started to think that maybe it would be more efficient to just create a high level API around our business logic, kinda like Amazon Fulfillment API: http://docs.amazonwebservices.com/fws/latest/APIReference/, so that client side developers would fully take over the UI, while server side developers would only concentrate on business logic. So for ordering system you would have a high level API like: OrderService.asmx               CreateOrderResponse CreateOrder(CreateOrderRequest)     AddOrderItem     AddPayment     -     SubmitPayment     -     GetOrderByID     FindOrdersByCriteria     ...      There would be JSON/REST access to API, so it would be easy to consume from client-side UI. We could use this API for both internal UI development and also for 3-rd parties to create their own applications. With advances in Javascript and availability of good client side developers, is it a good time to get rid of code-behind/controllers and just concentrate on developing high level APIs (ala Amazon) that client side developers can consume?


What are the advantages and disadvantages to using your real name online?

As a programmer, do you see any professional or other advantage in using your real name in online discourse, versus an invented handle? I've always gone by a single username and had my real name displayed whenever possible, for a few reasons:   * My interests online are almost exclusively professional and aboveboard.   * It constructs a search-friendly public log of all of my work, everywhere.   * If someone wants to contact me, there are many ways to do it.   * My portfolio of work is all tied to me personally. Possible cons to full disclosure include:   * If you feel like becoming involved in something untoward, it could be harder.   * The psychopath who inherits your project can more easily find out where you live.   * You might be spammed by people who are not worth the precious time that could be better spent writing more of the brilliant software you're famous for.   * Your portfolio of work is all tied to you personally. It seems, anyway, that a vast majority of StackOverflow users go by invented handles rather than real names. Notable exceptions include the best-known users, who are typically well established in the industry. But how could we ever become legendary rockstar programmers if we didn't get our names out there? Discuss.


Programming language trends

Are there some statistics out there that show the approx. number of users that popular programming languages have and the rate this number increases over time?