title: Can I use Dependency Injection without breaking Encapsulation?

text: Here is my Solution and projects:   * BookStore _(solution)_     * BookStore.Coupler _(project)_       * Bootstrapper.cs     * BookStore.Domain _(project)_       * CreateBookCommandValidator.cs       * CompositeValidator.cs       * IValidate.cs       * IValidator.cs       * ICommandHandler.cs     * BookStore.Infrastructure _(project)_       * CreateBookCommandHandler.cs       * ValidationCommandHandlerDecorator.cs     * BookStore.Web _(project)_       * Global.asax     * BookStore.BatchProcesses _(project)_       * Program.cs **Bootstrapper.cs** :               public static class Bootstrapper.cs      {         // I'm using SimpleInjector as my DI Container         public static void Initialize(Container container)          {             container.RegisterManyForOpenGeneric(typeof(ICommandHandler<>), typeof(CreateBookCommandHandler).Assembly);             container.RegisterDecorator(typeof(ICommandHandler<>), typeof(ValidationCommandHandlerDecorator<>));             container.RegisterManyForOpenGeneric(typeof(IValidate<>),                 AccessibilityOption.PublicTypesOnly,                 (serviceType, implTypes) => container.RegisterAll(serviceType, implTypes),                 typeof(IValidate<>).Assembly);             container.RegisterSingleOpenGeneric(typeof(IValidator<>), typeof(CompositeValidator<>));         }     }      **CreateBookCommandValidator.cs**               public class CreateBookCommandValidator : IValidate<CreateBookCommand>     {         public IEnumerable<IValidationResult> Validate(CreateBookCommand book)         {             if (book.Author == "Evan")             {                 yield return new ValidationResult<CreateBookCommand>("Evan cannot be the Author!", p => p.Author);             }             if (book.Price < 0)             {                 yield return new ValidationResult<CreateBookCommand>("The price can not be less than zero", p => p.Price);             }         }     }      **CompositeValidator.cs**               public class CompositeValidator<T> : IValidator<T>     {         private readonly IEnumerable<IValidate<T>> validators;              public CompositeValidator(IEnumerable<IValidate<T>> validators)         {             this.validators = validators;         }              public IEnumerable<IValidationResult> Validate(T instance)         {             var allResults = new List<IValidationResult>();                  foreach (var validator in this.validators)             {                 var results = validator.Validate(instance);                 allResults.AddRange(results);             }             return allResults;         }     }      **IValidate.cs**               public interface IValidate<T>     {         IEnumerable<IValidationResult> Validate(T instance);     }      **IValidator.cs**               public interface IValidator<T>     {         IEnumerable<IValidationResult> Validate(T instance);     }      **ICommandHandler.cs**               public interface ICommandHandler<TCommand>     {         void Handle(TCommand command);     }      **CreateBookCommandHandler.cs**               public class CreateBookCommandHandler : ICommandHandler<CreateBookCommand>     {         private readonly IBookStore _bookStore;              public CreateBookCommandHandler(IBookStore bookStore)         {             _bookStore = bookStore;         }              public void Handle(CreateBookCommand command)         {             var book = new Book { Author = command.Author, Name = command.Name, Price = command.Price };             _bookStore.SaveBook(book);         }     }      **ValidationCommandHandlerDecorator.cs**               public class ValidationCommandHandlerDecorator<TCommand> : ICommandHandler<TCommand>     {         private readonly ICommandHandler<TCommand> decorated;         private readonly IValidator<TCommand> validator;              public ValidationCommandHandlerDecorator(ICommandHandler<TCommand> decorated, IValidator<TCommand> validator)         {             this.decorated = decorated;             this.validator = validator;         }              public void Handle(TCommand command)         {             var results = validator.Validate(command);                  if (!results.IsValid())             {                 throw new ValidationException(results);             }                  decorated.Handle(command);         }     }      **Global.asax**               // inside App_Start()     var container = new Container();     Bootstrapper.Initialize(container);     // more MVC specific bootstrapping to the container. Like wiring up controllers, filters, etc..      **Program.cs**               // Pretty much the same as the Global.asax      Sorry for the long setup to the problem, I have no better way of explaining this other than detailing my actual problem. I don't want to make my CreateBookCommandValidator `public`. I would rather it be `internal` but if I make it `internal` then I will not be able to register it with my DI Container. The reason I would like it to be internal is because the only project that should have notion of my IValidate<> implementations are in the BookStore.Domain project. Any other project just needs to consume IValidator<> and the CompositeValidator should be resolved which will fulfill all validations. How can I use Dependency Injection without breaking encapsulation? Or am I going about this all wrong?


title: Combination of asp.net server side + html/js/jQuery client side

text: While working with asp.net, I came to an approach that uses asp.net services for the data/business logic layer and html/javascript/jquery for the UI layer, because I could not reach the needed level of customization of the user interface with asp.net web controls. While I've seen plenty of books describing usage of asp.net web controls and their integration with asp.net server side technology, and of html/js/jQuery client side web development without connection to any server side technology, I haven't seen any book dealing with combination of asp.net server side + html/js/jQuery client side. My question is, is this approach acceptable, or have I overlooked some widespread technology which is better suited to accomplishing such tasks? My constraint is that it has to be based on asp.net/mvc server side technology, because my management urges that.


title: Should I get a Math bachelors and then go into Computer Science?

text: This is my first question. I love Mathematics; I love the logic and the problem solving. At the same time, I enjoy Computer Science and hope to go into Artificial Intelligence research after I get my Bachelors degree, i.e pursue a PhD in Computer Science. Are there any advantages of having a firm grasp of Mathematics to studying Computer Science? Also, would I be at a disadvantage in getting a Bachelors in Mathematics instead of Computer Science when applying for graduate school to study Computer Science, particularly at institutions with high quality research infrastructure, like MIT and Stanford? Also, in reference to the first question, could you please tell me the advantages of a solid grasp of Mathematics, if there are any? Thank you.


title: Where does the term "Red/Black Tree" come from?

text: A Red/Black Tree is one way to implement a balanced binary search tree. The principles behind how it works make sense to me, but the chosen colors don't. Why red and black, as opposed to any other pair of colors or of attributes in general? When I hear "red and black," the first things that come to mind are checkerboards and Les Misérables, neither of which seems particularly applicable in this context.


title: Why are there so many numeric types (bit, int, float, double, long)?

text: I've learned PHP, Java, and C. Now I'm curious as to why there are so many types of numerical data types like bit, int, float, double, and long. Why not make only one type for numericals? Is there any benefit to this? Maybe if we use integers to hold such small numbers we can save memory?


title: Strange software development terminology

text: I have been working in a professional software development environment for a short while now. Over this short period of time I have heard some terminology I never knew existed. For example, in a status call a few weeks ago one of our developers said that he had been "hand-jobbing" things left and right. A few days ago, I heard a new one again, where someone in our company wants to "dog-food" some product of ours. So what is a "strange" term with respective definition, or list of terms that you know, that can improve on a new developer's professional vocabulary to improve on their communication and understanding of processes in the workplace? My list is as follows and I will add more as I come across them!   * Hand-jobbing: When a programmer resorts to some primitive or less-than-best-practice method of getting the job done, for the sake of getting something working, usually temporarily.   * Dog-fooding: When a company uses a product for internal use that they have or are currently selling to their customers, usually to save time and money, but also to show confidence in their own products. Also as a side note, I guess they don't have to really be TRUE software terminology as I've never heard anyone ever "hand-job" something as much as he did. However it should be something you have heard used in a professional environment that you would like to share.


title: Is perfectionism a newbie's friend or enemy?

text: > **Possible Duplicate:**   >  Where do you draw the line for your perfectionism? I see that the development community is very focused on doing things the right way and personally I would like to do the same too, however, is it a good or bad idea for a newbie to focus on design principles, design patterns, and commenting code when getting started, or is it better to let creativity run wild and potentially write sloppy code. Where should a newbie draw the line?


title: Are there standard guidelines for auditing software for possible buyout?

text: We are in the process of auditing a company with a view to buying them out. One of the key parts of this decision is the software they've developed over a long period of time. We always have the option of building our own, but we are all aware that it could take us longer to get operational if we build from scratch. My question is rather specific: I come from a development / PM background, and have been asked to do a full audit of this company's software, which is a web application. We want to know as much as possible about it before we make the decision of whether to buy them out, and after a basic demo, their system seems to do what we want, but we know that we'll need to modify it to a certain extent. I am looking for a template or framework to work through in order to produce my final report. Its been really tough finding anything through Google; most of what I've found is just basic checklists at best. I would need a template or framework that deals with infrastructure, design, architecture, hosting, etc. Has anyone had experience with this? I would be very grateful if someone is willing to share their template/framework with me.


title: How to help junior programmers whose first language isn't English?

text: I've just changed jobs and am now working with a junior programmer whose first language is Cantonese. They have a computer science degree but are working in their first programming role after many years outside the computer industry. They have been working for the past two years in almost total isolation and have developed a lot of bad habits. A fellow contract programmer also speaks Cantonese, but his spoken English is quite poor, is also frustrated by the juniors approach to programming and are unsure what to do. Despite working on projects together in Cantonese the projects over run as the lack of an agreed/reviewed design means they have a merry-go-round of updates until a solution is reached. Despite gentle verbal encouragement to do so both still struggle to create even the most basic design documents, enter proper check-in comments (i.e. not just 'bug-fix','updates' etc) and contribute at all to the project wikis. At present the junior programmer doesn't read blogs, books or technical resources. When I ask how they become a better programmer they say they just think more about their own code. They are highly prone to reinventing the wheel with what I can only generously say are uniquely imaginative solutions to well solved problems. I have tried to explain the KISS principle and SRP to them but I'm not convinced they understand the benefit. I'm sure I can't have explained it very well to be honest. Since I'm not sure if English comprehension is a problem then that is a problem in itself. Can you recommend ways I can help them when;   * I can't speak any Cantonese and don't see learning any being effective in a realistic time frame   * Sending links to resources like thedailywtf.com appears to go over their heads   * The programming books we've bought remain unread I've found the following SO questions which might be useful to them but point two above applies;   * Programming information in your mother tongue   * Does “English” hinder you to enhance your programming skills? Are there some programming exercises we could work through together? What tips are there to get some basic documentation created? Are there any Cantonese resources I could point them to? I appreciate how much easier it is when English is your native language. I genuinely want to help them as much as possible and not judge what could otherwise be perceived as an unwillingness to improve as a programmer.


title: If I hire you for "a day", how many hours are expected?

text: I've seen a lot of advice for freelance programmers which advocates quoting your rates in periods of a minimum of one day. That means that when someone asks your rate, you would say "$500 per day" rather than giving the equivalent hourly rate. If I agree to do 10 days of programming work for a client at a particular daily rate, how many hours are expected of me per day? What happens if I do 6 hours of actual programming on Monday and then do 8 on Tuesday.. is that two "days" or "1.75 eight hour days" or what? What's the standard?


title: What does "deploy to a physical machine" mean

text: I was asked whether I've ever "deployed to a physical machine" and I'm seeing this terminology when googling, but not getting a definition. What does it mean? What other way could someone deploy an application if not to a physical machine?


title: How can I apply Readme Driven Development to an ongoing project?

text: I'm assigned to a project where the goal is to update an existing software. This software was developed in a totally _ad hoc_ manner, which means that any documentation generated is outdated, confused and just plain useless. I do not want to retroactivelly produce all the missing artifacts, since this would just be a waste of time. The code base is ugly, and really need some serious refactoring, but this is another story. What I want is to apply Readme Driven Development to guide this project. So, basically, I want to write a Readme, which will document every change meaningful at the user level. The problem is, I have no idea about how to structure this document. For me, it's pretty clear that it should have a different layout than the traditional Readme. I really want to document changes, and not the current state of affairs. Any ideas?


title: Which patterns/architecture to apply for "Import Data, Process Data, Export Result"

text: I was wondering which architecture/patterns to choose for the following problem divided into three steps:   1. Import TestScript Description from File (e.g. .xls, .txt)   2. Process Described TestScript   3. Export Description with processed Results as .xml Here is what I got so far:   * Importer that reads in xls and creates a hierarchical object structure   * Parser that creates an Abstract Syntax Tree (If,then,else,end,command) from the object structure   * A Processor (VisitorPattern) of the AST. This Processor instantiates the command implementation, executes the command, collects the results and controls the flow (if, then, else) Currently the imported object structure already contains a field for the result and can just be serialized out as xml. But in my opinion it's not very elegant having a result field in the input objects. The main reason I don't like it is that I can not reuse the imported object structure in order to process it multiple times. I would like to divide the whole component also into three parts:   1. Import, which creates an hierarchical object structure that describes the TestScript (containing a fileparser and a preprocessor)   2. Process, which creates an AST and processes it   3. Export, which takes the results and the descriptions and writes it out Here a few other conditions:   * Not every AST Node represents an object in the object structure (description)   * But each result object is connected to an description object   * Description and Results are hierarchical


title: Why are most GNU's software written in C

text: I am a Java developer, and I rarely write GUI program in C. However, I noticed that many GNU's projects, such as PSPP, R, Dia, etc., are written in C, instead of Java or C++. I personally don't mind this, but I am really curious why GNU favors C so much. My understanding is that C is the one that supports the least in object- oriented programming, and today's CS education really emphasizes OOP, as OOP really makes codes more reusable. In this case, why would so many developers choose to develop in C instead of C++ or Java. Does anyone know why GNU's software are so exclusively written in C? Do you think or GNU's software should be written in C++ or Java so that the source code could be more useful to people? Why or why not?


title: Boost Software License seems to extend disclaimer of warranty automatically but the author says it doesn't

text: Here is a copy of the Boost software license.               Permission is hereby granted, free of charge, to any person or organization     obtaining a copy of the software and accompanying documentation covered by     this license (the "Software") to use, reproduce, display, distribute,     execute, and transmit the Software, and to prepare derivative works of the     Software, and to permit third-parties to whom the Software is furnished to     do so, all subject to the following:          The copyright notices in the Software and this entire statement, including     the above license grant, this restriction and the following disclaimer,     must be included in all copies of the Software, in whole or in part, and     all derivative works of the Software, unless such copies or derivative     works are solely in the form of machine-executable object code generated by     a source language processor.          THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR     IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,     FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT     SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE     FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,     ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER     DEALINGS IN THE SOFTWARE.      The second paragraph of the license requires the warranty disclaimer to be retained in all copies of the software (except purely binary ones). Further, in the warranty disclaimer both "THE COPYRIGHT HOLDERS" as well as "ANYONE DISTRIBUTING THE SOFTWARE" is protected from being liable for damages. Here is a copy of the MIT license.               Copyright (C) <year> <copyright holders>          Permission is hereby granted, free of charge, to any person obtaining     a copy of this software and associated documentation files (the     "Software"), to deal in the Software without restriction, including     without limitation the rights to use, copy, modify, merge, publish,     distribute, sublicense, and/or sell copies of the Software, and to     permit persons to whom the Software is furnished to do so, subject to     the following conditions:          The above copyright notice and this permission notice shall be     included in all copies or substantial portions of the Software.          THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,     EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF     MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.     IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY     CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,     TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE     SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.      In contrast, the MIT license doesn't require the warranty disclaimer to be retained in all copies of the software and only the "THE AUTHORS OR COPYRIGHT HOLDERS" are protected from being liable for damages. It looks like the Boost Software License provides better protection against liabilities to anyone dealing with the software (even those who are simply distributing the software). Also, the Boost Software License makes it mandatory to reproduce the disclaimer in all copies. Why then does the author of the Boost license mention in http://ideas.opensource.org/ticket/45 that the Boost license _"does not extend the disclaimer of warranties to licensees, so that they may, if they choose, undertake such warranties (e.g., in exchange for payment)"_?


title: Is there anything inherently bad about mixing paradigms in an application?

text: I am currently in the process of writing a (custom) Minecraft server application in C#. I figured it's a good way to teach me a lot of important things like concurrency and especially memory efficiency (due to simply the vastness of the object space in Minecraft). While on the train yesterday, I was finding it hard to really "think" of a way to organize the network module. I wanted a simple external interface that would give out the necessaries (Let users react to a connection being received, message being received, and when a connection is dropped). However, I also wanted it to be fairly abstract such that I could allow for either real game clients to connect or simple fake clients. I started over-engineering things a la `IConnection`, `INetworkModule`, `IConnectionFactory`, `IConnectionProtocol`, `IMessageEncoder`, `IMessageDecoder` and so on. Kingdom of nouns galore. Not only that but I wasn't really getting **anywhere** \- it just felt like I was putting the fundamental problem behind other layers of abstraction in that **I had no idea how I wanted to organize the communication between all these modules**. Then I came to the thought - why don't I just use **verbs** (actions/functions/methods/whatever) instead of **nouns** (types) - let's focus on what I want to achieve for now, and split it up into nouns later! And so, I came up with something similar to this:                   private static Func<IDisposable> Listen(             Action<TcpClient> onConnectionReceived,             Action<TcpClient> onConnectionDropped,             Action<TcpClient, int, byte[]> onBytesReceived,             Func<bool> isOpen)         {             // todo: 25565 needs to be injected             // todo: give opportunity to supply listener             // todo: refactor listener into role interface             var listener = new TcpListener(IPAddress.Any, 25565);             return () => Observable.FromAsync(listener.AcceptTcpClientAsync)                 .DoWhile(isOpen)                 .Subscribe(client =>                 {                     var stream = client.GetStream();                     // on subscribe invoke the delegate first                     onConnectionReceived(client);                     // the delegate has the option to disconnect the client                     // based on whatever criteria it see fit.                     // we should now create an observable to                      // listen for messages on this client.                     Observable.Defer(() =>                     {                         // 8kb buffer for each connection                         // this is actually fairly small                         var buffer = new byte[8024];                         // we can handle the 'doing' of things with these bytes                         // inside the passed function. This function will be doing too much otherwise                         return Observable.FromAsync(ct => stream.ReadAsync(buffer, 0, buffer.Length, ct))                             .Select(n => new {Read = n, Bytes = buffer});                     }).Subscribe(a =>                     {                         // drop connection if nothing was read                         if (a.Read <= 0)                             onConnectionDropped(client);                         else                             onBytesReceived(client, a.Read, a.Bytes);                     });                 });         }      Really simple. Well, I mean, not quite, but this basically does the role of all of the nouns (except `IMessageEncoder/Decoder` that I listed earlier), but only making assumptions of the fact that we need a `TcpClient` (obviously, that isn't what I want right now, but I can work to that in iteration 2!) However, my problem with this is, is that this isn't really **typical** C# code.. and it surely breaks the SRP in that this function is returning a function for the entire execution of a server. But - it makes sense to me. So my question is, is there any real inherent downside to using a functional- esque paradigm like this as opposed to traditional Kingdom of Nouns OOP inside of C# - traditionally a multi-paradigm language? And if there are downsides, what would I face and why? For the record, I intend for this to be OSS, so there's another issue in that some developers might not understand the code style because it's simply not OOP orientated, just pure functions.


title: Retaining disclaimer is mandatory in BSD-2-Clause license but not in MIT license

text: I see a difference between the BSD licenses and the MIT license. The BSD licenses require the complete disclaimer to be retained in all redistributions of source code or binary code. MIT license doesn't require it. I am reproducing the complete BSD-2-Clause license followed by the MIT license for your convenience. Here is the BSD-2-Clause license.               BSD-2-CLAUSE LICENSE     ====================          Copyright (c) <YEAR>, <OWNER>     All rights reserved.          Redistribution and use in source and binary forms, with or without     modification, are permitted provided that the following conditions are     met:          1. Redistributions of source code must retain the above copyright        notice, this list of conditions and the following disclaimer.     2. Redistributions in binary form must reproduce the above copyright        notice, this list of conditions and the following disclaimer in the        documentation and/or other materials provided with the distribution.          THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS     "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT     LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR     A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT     HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,     SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT     LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,     DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY     THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT     (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE     OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.      Here is the MIT license.               MIT LICENSE     ===========          Copyright (C) <year> <copyright holders>          Permission is hereby granted, free of charge, to any person obtaining     a copy of this software and associated documentation files (the     "Software"), to deal in the Software without restriction, including     without limitation the rights to use, copy, modify, merge, publish,     distribute, sublicense, and/or sell copies of the Software, and to     permit persons to whom the Software is furnished to do so, subject to     the following conditions:          The above copyright notice and this permission notice shall be     included in all copies or substantial portions of the Software.          THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,     EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF     MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.     IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY     CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,     TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE     SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.      While the BSD license mentions, "must retain the above copyright notice, this list of conditions and **the following disclaimer** ", the MIT license only mentions, "The above copyright notice and this permission notice shall be included", i.e. the MIT license doesn't require the disclaimer to be included. I am not looking for legal advice. I want to understand, as a programmer, if there is any good reason to release code in one of these licenses instead of the other because of this difference.


title: What's the difference between the terms "protocol" and "standard"?

text: I find the term "protocol" confusing (in the terms of computer science that is). If the protocol is just a set of rules, wouldn't it be easier if we used the term "standard" instead (like in "HTTP standard")?


title: Applying SOLID principles

text: I am quite new to the S.O.L.I.D. design principles. I understand their cause and benefits, but yet i fail to apply them to a smaller project which I want to refactor as a practical exercise to use the SOLID principles. I know there is no need to change an application that works perfectly, but I want to refactor it anyway so I gain design experience for future projects. The application has the following task (actually a lot more than that but let's keep it simple): It has to read an XML file which contains Database Table/Column/View etc definitions and create an SQL file which can be used in order to create an ORACLE database schema. (Note: Please refrain from discussing why I need it or why I don't use XSLT and so on, there are reasons, but they are off-topic.) As a start, I chose to look only at Tables and Constraints. If you ignore columns, you could state it the following way: A constraint is part of a table (or more precisely, part of a CREATE TABLE statement), and a constraint may also reference another table. First, I will explain what the application looks like right now (not applying SOLID): At the moment, the application has a "Table" class which contains a list of pointers to Constraints owned by the table, and a list of pointers to Constraints referencing this table. Whenever a connection gets established, the backwards connection will be established as well. The table has a createStatement() method which in turn calls the createStatement() function of each Constraint. Said method will itself use the connections to the owner table and referenced table in order to retrieve their names. Obviously, this doesn't apply to SOLID at all. For example, there are circular dependencies, which bloated the code in terms of "add"/"remove" methods required and some large object destructors. So there are a couple of questions:   1. Should I resolve the circular dependencies using Dependency Injection? If so, I suppose the Constraint should receive the owner (and optionally the referenced) table in its constructor. But how could I run over the list of constraints for a single table then?   2. If the Table class both stores the state of itself (e.g. table name, table comment etc) and the links to Constraints, are these one or two "responsibilities", thinking of the Single Responsibility Principle?   3. In case 2. is right, should I just create a new class in the logical business layer which manages the links? If so, 1. would obviously no longer be relevant.   4. Should the "createStatement" methods be part of the Table/Constraint classes or should I move them out as well? If so, where to? One Manager class per each data storage class (i.e. Table, Constraint, ...)? Or rather create a manager class per link (similar to 3.)? Whenever I try to answer one of these questions I find myself running in circles somewhere. The problem obviously gets a lot more complex if you include columns, indices and so on, but if you guys help me out with the simple Table/Constraint thing, I can maybe work out the rest on my own.


title: What is a good way to reset the Primary Key?

text: We've hit an application issue with an Oracle table Primary Key exceeding the limits used by a Java Integer (2 ^ 32) and one of the suggestions is to reset this to 1000 and let it start again. OR change the code to use Java Long (2 ^ 64) instead. This has a ripple effect since this key is used as ID by a lot of other systems as well. And there can be future duplication (in the far future) Are there any suggestions on good and bad outcomes in this approach?


title: What is the minimum subset of best/well-known practices in software development for a solo programmer?

text: I've been the lonely programmer in my work for quite a long time. Usually I've read articles and posts about   * Version Control Systems   * Continuous Integration/Delivery   * Development methodologies: Scrum, Waterfall, V-Model, Agile, XP, etc.   * Software Project Management But almost all of them seem to be focused on TEAMS. I'm not a team, so what would be the absolutely minimum set of practices for just one programmer? Consider the following conditions:   * I don't have conflicts with other's people code.   * I don't need to maintain files/directory trees, my developement environment cares about versioning by itself (image-based development).   * There are no formal requirements, my users don't know what they want and they're are ok with that.   * The only one which could be interested in delivering a release or documentation it's me, basically customer want RESULTS and doesn't care about software methodologies, etc My view is that I don't want to spend (too much) time and energy in anything not directly related with the customer requirements. Any recommendations?


title: Why (most?) retro computer emulators are single threaded?

text: All real computer hardware works in parallel. So why most emulators of retro systems (like NES) are single threaded (or I'm not right?)? You have main loop and you counting CPU cycles and after certain cycles activating other hardware like PPU. Same thing applies to IBM PC and (MDA/CGA/VGA) emulation ? Thanks


title: Recommended content for layers

text: As an expansion from my previous question about using separate projects for seperate layers - Good practice on Visual Studio Solutions I now wish to know if I am putting the right functionality in the correct layers. **Background** I'm building a WPF application from scratch, that contains business logic and business objects. The database itself sits on another server on the web with access to it, restricted to web API calls using OAuth authentication. I think the following content should be in these layers. The idea being, you go from layer 1 to layer 4, you are only depending on the layers below you. To prevent circular dependencies. **1\. Presentation** WPF View (what the user will see) WPF ViewModel (how the program responds to user interaction) _No WPF Model, as it will just be the business object_ **2\. Application/Services** Repository (class used by ViewModel to load/save business objects) Utility classes to assist in saving objects, by selecting the correct API calls. **3\. Business layer** Business objects/Entities/DTO (whichever name is preferred) Factories (Used by the repositories in the creation of business objects) Other misc business class (i.e. storage of currently logged in user) **4\. Infrastructure/Data Access** OAuth client (makes authenticated calls against the web server, used by repository classes)


title: Pattern that prevents events to trigger themselves

text: I am working at the client-side part of a web application, that is responsible for getting answers from users for specific questions and storing and restoring them from the database (or cookies) and I am running into the issue that **updating the answers from the db will also trigger saving them again** (because the same method `answerQuestion` is called). Here's a simplification of my use-case (coffeescript):               class Questionnaire       constructor: ->         @prefillAnswers()         @listenToInput()         @listenToQuestionChanges()            prefillAnswers: ->         for q in @questionNames           @answerQuestion getAnswer(q)            listenToInput: ->         $('.input').on 'change', (e) =>           $input = $(e.currentTarget)           @answerQuestion $input.data('questionName'), $input.val()            listenToQuestionChanges: ->         @subscribeToEvent 'answeredQuestion', (msg, data) =>           saveAnswer(data.question, data.answer)            getAnswer: (qName) ->         # fetches answer from a database (such as cookies, but is irrelevant)            saveAnswer: (qName, answer) ->         # saves the answer            answerQuestion: (qName, answer) ->         @publishEvent 'answeredQuestion', {question: qName, answer: answer} # This part triggers unnecessary saving, but where is the best place for this?         # Change state of UI and data "model"         # ...      **My question is, is there an OOP pattern that discusses this issue and possible solutions?** I don't know how to start addressing this, and reading an entire book is not an option right now (I however have it on my todo list). Perhaps this could be rewritten with a MVC pattern, and I'm moving towards that by starting to read the book JavaScript Web Applications, but can't see right now even with MVC, how my problem is avoided in the best way...


title: What to do with a programmer that can't handle priorities?

text: One colleague in our team has multiple jobs to do, but he don't focus on the job that is currently the most important. In our team we always discuss the next steps, but he still don't focus on one thing. He always has a reason why he's NOT doing the right thing.   He's with us for 9 month, so we thought this is common with guys newly from university. But the problem gets bigger every week. But we want to give him a chance. How can we motivate him?   What would you guys do with him?


title: how to stay efficient when a build is almost always broken

text: I work in a middle sized team which shares the same source code and while have a continues integration in place, but as all of us has to work in the same branch, the build is almost always broken. As we also have a rule, which has been introduced recently to alleviate the broken builds, which states that no one is allowed to check-in while to build is red. Having said that, during a day everyone have a handful of 10-15 minutes windows where we allowed to check-in. And as the team is growing, the windows of check-in opportunities shrinking even more. That forces developers to accumulate their changes locally, which results in a bigger change sets which even more difficult to ensure that the changes are not breaking anything. You can see the vicious cycle. What can you recommend to allow me to stay effective working in environment like this. Also, please keep in mind that I am a developer, not a manager, and can't change the process or other people behavior much.


title: A question on nature of generated assembly in C++ and code Algebra

text: I wrote this code:               #include <iostream>     int main()     {         int a;         std::cin >> a;         if(a*a== 3){             std::cout << a;         }         return 0;     }      On MSVC I turned ON all optimization flags. I expected that since a*a can never be 3, so compiler should not generate code for the section:               if(a*a== 3){         std::cout << a;     }      However it generated code for the section. I did not check GCC or LLVM/CLang. What are the limits of expectation from a C++ compiler in these scenarios?


title: Subtractive color mixing algorithm

text: Here is my problem: I have a set of 'n' colors including the primary colors and their codes in hexadecimal. Now given another color 'x' I wonder if it's actually possible to come up with a mix between two or more of the colors of the set that will produce 'x'. The mix should be subtractive. Here is an example of the result of the algorithm: My set of colors is: c1, c2, c3, c4, c5, c6. I am trying to find the mix to produce the color x. The result could be: 50% of c1, 25% of c4 and 25% of c5. If anyone could point me in the right direction (or at least tell me if it is unfeasible), any help would be gladly appreciated!


title: Is it safe to just use MySQLi?

text: I have developed an open source PHP application and currently it uses both the MySQLi or MySQL extension for backwards compatibility. I'm wondering about switching it over to only be compatible with MySQLi since PHP now no longer supports the MySQL. Another reason I'd like to get away from supporting both MySQL and MySQLi is that I'm basically using MySQLi the same way I do as with the old MySQL extension. Can anyone explain to me if this is a good or bad idea?


title: Setting up Developers Conference

text: In our local city in the UK, there are as far as I am aware no developer conferences. I am confident that our region has many professional developers as well as many graduating students whom who really benefit from a conference. I would like to ask the following questions:   * What steps or advice would one take if the task was given to set up a local developers conference?   * What would the costing look like? (excluding building/hosting of website(s))   * How would one build interest and promote this?   * How would I approach, Local Companies & Universities to collaborate with them? I'm not just aiming this question to users who may have experience in setting up such conferences (but are highly welcome). Rather how would you attack this if you was tasked with this?


title: Why NoSQL (Key-Value) storage become popular these days?

text: It seems that NoSQL concept not something very new and innovative, but these days become very popular. Why it become popular recently but not happen in the time when SQL is very popular?


title: How does the Microsoft Operations Framework define the role of Architects and architecture in the SDLC

text: I have been trying to get some architecture documentation passed at work. I've spoken to my CIO and he has said to me that if I prove to him that if we stay within MOF then we can implement it. I am not an architect, I am a software developer trying to become an architect. I downloaded the MOF documentation and did some searches for "architect" or "architecture" and really only found 3 very minor references. So I'm trying to find out more about the role of "Architecture" in MOF.


title: Short Deadline and QAing Yourself

text: When you have a short deadline to being with, and you're nearing the end of development, would you rather rush through coding to dedicate more time to QAing or keep your pace and possible have VERY little QA time? I am a sole developer on this project and I am the sole QAer as well. It is an extremely short time period I have to do this, notice to release. It is a very data-driven application and the data tends to be a little......user-inputed. I could spend days searching through intermediate processes, but it will take away from the little valuable time I have left. What do you recommend? Maximize QA time by rushing to finish? Or keep steady and cross my fingers on release? I don't like the feeling of a release version and just watching a new batch of data just waiting for it to snag and fail. Thoughts? Opinions?


title: UML Class diagram confusion

text: I am learning how to draw a UML class diagram and after reading a few tutorials, I am still confused about the appropriate usages of **Association type** (The clear diamond and black diamond). I understand their usages but I haven't got a very concrete understanding on when to use them and when not to. For example in the sample class diagram below, I would have thought that if **Customer** does not exist, the **Order** will be gone too but an association diamond was not being used. Hope someone can provide me with more explaination/examples on the usages of association types. Thanks. ![Sample ordering class diagram](http://i.stack.imgur.com/HQxT9.png)


title: Staying Relevant As a Programmer

text: I am interested in hearing how various people remain in the Software Engineering industry for so long in their careers. I am at a crossroads myself as I have worked with Network Engineering, Communications, VoIP, Parking, Government Contracting, and Military related projects. **Question: How does one manage to stay relevant as a programmer while bouncing between different engineering areas (Testing, Integration, etc) and remaining motivated in the profession?** Old questions:   1. Do you bounce between pure Software Tester, Integration, and back to straight coding?    2. How do you prevent being a one-hit wonder in this economy?    3. How do you find your passion ?


title: Does a data-driven application need a database?

text: This may be a terribly stupid question, but I can't find anything even related on Google (maybe I am not searching properly). I've been a developer for around a year now. I do desktop and web apps using Visual Studio at my day job and use a WAMP setup for freelancing. For storing data I have either used a database or not. What I mean is that if the program stores data for longer than the app runs then I use a database; that's all I know. Here's the thing, I have always worked with **existing** databases for desktop apps. I have never made a desktop app from scratch (the programming part yes, but the database has just always been there and on a local server somewhere for the app to pull from). I want to develop a desktop application that would need a database. My question is how does that process work? In providing the application do I supply the database, say SQLserver, or is there another way in which that works? To be clear: The application would need to store your typical customer information, files, possibly images, payment information - which I know a database would provide, but I do not know how that works once you sell and install the application. I know other applications do these sorts of things - quickbooks, email clients, etc. How do they do it with just an install?


title: How to close a bug that is no longer relevant

text: I'm currently on a medium-sized team of web developers. We're using jira for bug tracking. We're working on a product with frequent layout changes. A lot of times bugs are filed about a bug in the layout in some browser. Sometimes, by the time we get around to dealing with a low priority bug, the layout has already changed and it is no longer relevant.   * What should we close it as?   What I mean is how we should _treat_ these issues? While Jira is the bug tracking software we use, I'm more interested in how to handle these sort of issues in general.   * Does it even matter? (We _might_ return to the layout later, but it's very unlikely)


title: Should a User class only contain attributes and no methods apart from getters/setters?

text: I'm trying to improve my OOP code and I think my User class is becoming way too fat. In my program a user has rights over "lists". Read, Write, Update, Delete. So I made a User class               class User     {     protected $_id;     protected $_email;     protected $_username;     protected $_hashedPassword;          //...Various setters/getters          public function canRead(List $list){         //Database query verifies if user has READ rights     }          public function canUpdate(List $list){         //Database query verifies if user has UPDATE rights     }     //etc...     }        * Should canRead, canUpdate, canWrite, canDelete methods be moved to another class (UserAccessCheck or something...)?   * If not, should the actual SQL be moved into the List object (listCanBeReadByUser()) ?


title: Are there any online certificate/degree programs focused on Information Retrieval or Language Processing?

text: I'm a software engineer looking to try something different in my career and get into search indexes, information Retrieval or Natural Language Processing applications and systems. Where can I learn more about this stuff under a degree or certificate program?


title: iPhone App Store Release Question

text: I am developing an Application its purpose to view uploaded files on the host server, and it has a credentials that will be entered on the Login Page to authenticate the user. When I post my application to the App Store, how suppose apple is going to test, or at least view my application, when Apple needs enter a valid credentials that I am not suppose to know? It's private to my client.


title: Optimizing lifestyle and training

text: I am a college freshman who has recently discovered a passion for computer science. Having had my first lick of formal python training last semester, I have cast aside my previously hedonist way of life and tunneled my sights on becoming the most rounded and proficient programmer I can be. I know that I'm taking strides in the right direction (I've stopped smoking, I've been exercising every day, I've taught myself C++ and OpenGL, and I've begun training in kung-fu and meditation), yet I am still finding myself struggling to achieve satisfactory results. I would like to be able to spend a good 3-4 hours every day burning through textbooks. I have the time cleared and the resources allocated. The problem lies in the logistics-- I have never taken anything seriously before. Recently I've realized that I am clueless when it comes to taking care of myself and gaining control of my mind, and it drastically hinders my productivity. My question is this: How can I learn to manage my time and take care of myself such that I can spend the maximum amount of time every day studying with steady concentration? Personal tricks would be key here: techniques you use to get yourself to sleep, a diet that yields focus, even computer break stretching routines or active reading techniques. Anything you could think of here would be great. I was a low-life in high school and I have the drive to turn my life around, I'm just quite a bit behind in the way of good habits :)


title: Simple explanation of Continuous Integration

text: How would you define Continuous Integration and what specific components does a CI server contain? I want to explain to someone in the marketing department what Continuous Integration is. They understand Source control - i.e. they use Subversion. But I'd like to explain to them properly what CI is. The Wikipedia Article never properly defines it, the Martin Fowler article only gives the following, which is basically a tautology followed by a vague explanation of 'integration': > Continuous Integration is a software development practice where members of a > team integrate their work frequently, usually each person integrates at > least daily - leading to multiple integrations per day. Each integration is > verified by an automated build (including test) to detect integration errors > as quickly as possible. **Update** : I sent them this image, I couldn't find a simpler one. ![enter image description here](http://i.stack.imgur.com/Cy2Ny.jpg) **Update 2** : Feed back from the marketing chap (for the time when there was 3 questions): > I actually like all 3 answers – for different reasons. I feel like logging > in just to thank them all! Obviously he can't - so thanks on his behalf :) **Update 3** : I've realised looking at the Wikipedia article that it does contain the principles which, when you take just the headings, is quite a good list:   1. Maintain a code repository   2. Automate the build   3. Make the build self-testing   4. Everyone commits to the baseline every day   5. Every commit (to baseline) should be built   6. Keep the build fast   7. Test in a clone of the production environment   8. Make it easy to get the latest deliverables   9. Everyone can see the results of the latest build   10. Automate deployment


title: Balancing dependency injection with public API design

text: I've been contemplating how to balance testable design using dependency injection with providing simple fixed public API. My dilemma is: people would want to do something like `var server = new Server(){ ... }` and not have to worry about creating the many dependencies and graph of dependencies that a `Server(,,,,,,)` may have. While developing, I don't worry too much, as I use an IoC/DI framework to handle all that (I'm not using the lifecycle management aspects of any container, which would complicate things further). Now, the dependencies are unlikely to be re-implemented. Componentisation in this case is almost purely for testability (and decent design!) rather than creating seams for extension, etc. People will 99.999% of the time wish to use a default configuration. So. I could hardcode the dependencies. Don't want to do that, we lose our testing! I could provide a default constructor with hard- coded dependencies and one which takes dependencies. That's... messy, and likely to be confusing, but viable. I could make the dependency receiving constructor internal and make my unit tests a friend assembly (assuming C#), which tidies the public API but leaves a nasty hidden trap lurking for maintenance. Having two constructors which are implicitly connected rather than explicitly would be bad design in general in my book. At the moment that's about the least evil I can think of. Opinions? Wisdom?


title: Evaluating JSON from popular auto-suggests

text: I was evaluating the various ways in which the big guys implement auto suggest. These are my observations.(Search string used was "ab") Questions towards the end. Yahoo tries something like this, where the response was a JSONP. Response is readable and serves the purpose. ## Yahoo's response               yasearch({"q":"ab ","gprid":"Y435dN7TRFqnYqQhnBueJA","f":["k","m"],"r":[["ab de villiers",0],["ab exercises",0],["ab king pro",0],     ["ab infi-net internet banking",0],["ab mujhe raat din",0],["ab workouts",0],["ab mp3",0],["ab meri bari",0],["ab ke baras",0],["ab meri baari",0]]})      Bing had a similar approach. Returns an "if" block, sa_inst.apiCB() seems to be a function which would process the JSON. Again response is readable and legit. ## Bing's response               if(typeof sa_inst.apiCB == 'function') sa_inst.apiCB({"AS":{"Query":"ab","FullResults":1,"Results":[{"Type":"AS","Suggests": [{"Txt":"abp news","Type":"AS","Sk":""},      {"Txt":"abbottapp.abbott.in","Type":"AS","Sk":"AS1"},{"Txt":"abt travels","Type":"AS","Sk":"AS2"},{"Txt":"abp ananda","Type":"AS","Sk":"AS3"},     {"Txt":"abhibus","Type":"AS","Sk":"AS4"},{"Txt":"abp maza","Type":"AS","Sk":"AS5"},  {"Txt":"abb","Type":"AS","Sk":"AS6"},     {"Txt":"aboutgoogle","Type":"AS","Sk":"AS7"}]}]}} /* pageview_candidate */);      Now comes Google. Response is sent as 2 JSON objects(separated by /""/). Most of it is unreadable. ## Google's response               {e:"XteVUYKqDoKHrAfdz4D4Aw",c:0,u:"https://www.google.com/s?hl\x3den\x26gs_rn\x3d14\x26gs_ri\x3dpsy-ab\x26tok\x3dvsobDhICRmdcnY7ayKTGng\x26cp\x3d2\x26gs_id\x3dd\x26xhr\x3dt\x26q\x3dab\x26es_nrs\x3dtrue\x26pf\x3dp\x26output\x3dsearch\x26sclient\x3dpsy-ab\x26oq\x3d\x26gs_l\x3d\x26pbx\x3d1\x26bav\x3don.2,or.r_cp.r_qf.\x26bvm\x3dbv.46751780,d.bmk\x26fp\x3d2647af89de6b6c61\x26biw\x3d1366\x26bih\x3d453\x26tch\x3d1\x26ech\x3d2\x26psi\x3dVteVUcYuzOGsB6LpgdgB.1368774484351.1",p:true,d:"[\x22ab\x22,          [[\x22ab\\u003Cb\\u003Ec\\u003C\\/b\\u003E\x22,0,[]],[\x22ab\\u003Cb\\u003Ec news\\u003C\\/b\\u003E\x22,0,[]],[\x22ab\\u003Cb\\u003Eercrombie\\u003C\\/b\\u003E\x22,0,[]],[\x22ab\\u003Cb\\u003Ecya\\u003C\\/b\\u003E\x22,0,[]]],     {\x22j\x22:\x22d\x22,\x22q\x22:\x22t8z6h8KhWvbkEX6xablxgYxDUq4\x22,\x22t\x22:     {\x22bpc\x22:false,\x22tlw\x22:false}}]"}     /*""*/     {e:"XteVUYKqDoKHrAfdz4D4Aw",c:-1,u:"https://www.google.com/searchdata?hl\x3den\x26gs_rn\x3d14\x26gs_ri\x3dpsy-ab\x26tok\x3dvsobDhICRmdcnY7ayKTGng\x26cp\x3d2\x26gs_id\x3dd\x26xhr\x3dt\x26q\x3dab\x26es_nrs\x3dtrue     \x26pf\x3dp\x26output\x3dsearch\x26sclient\x3dpsy-ab\x26oq\x3d\x26gs_l\x3d\x26pbx\x3d1\x26bav\x3don.2,or.r_cp.r_qf.\x26bvm\x3dbv.46751780,d.bmk\x26fp\x3d2647af89de6b6c61\x26biw\x3d1366\x26bih\x3d453\x26tch\x3d1\x26ech\x3d2\x26psi\x3dVteVUcYuzOGsB6LpgdgB.1368774484351.1",     p:true,d:"{\x22snp\x22:1}"}     /*""*/        1. Are those hex codes or what do you call them?   2. Why is there a need for 2 objects to be returned?   3. What is the need for encoding the JSON?   4. Which is the ideal format for JSON among these three? Any thoughts on this are welcome.


title: How can I keep directories in sync

text: Context: I'm developing software that reproduce the functionality of Windows Home Server Drive Extender, where users use multiple hard disks to prevent data loss.   The software exists since Dec-2009, but it has issues with renames (detailed below). I have a directory, dirA, that users can work in: they can create, modify, rename and delete files & sub-directores in dirA.   I want to keep another directory, dirB, in sync with dirA.   The goal is to have a backup of all the files in dirA, in case the drive it's on fails (dirB would be on another drive). What I'd like, is a discussion on finding a working algorithm that would achieve the above, with the limitations listed below. Requirements:   1\. Something asynchronous - I don't want to stop file operations in dirA while I work in dirB.   2\. I can't assume that I can just blindly rsync dirA to dirB on regular interval - dirA could contain millions of files & directories, and terrabytes of data. Completely walking the dirA tree could take hours. Those two requirements makes this really difficult.   Having it asynchronous means that when I start working on a specific file from dirA, it might have moved a lot since it appeared.   And the second limitation means that I really need to watch dirA, and work on atomic file operations that I notice. Current (broken) implementation:   1\. Log all file & directory operations in dirA.   2\. Using a separate process, read that log, and 'repeat' all the logged operations in dirB. Why is it broken:               echo 1 > dirA/file1     # Allow the 'log reader' process to create dirB/file1:         log = "write dirA/file1"; action = cp dirA/file1 dirB/file1; result = OK     echo 1 > dirA/file2     mv dirA/file1 dirA/file3     mv dirA/file2 dirA/file1     rm dirA/file3     # End result: file1 contains '1'     # 'log reader' process starts working on the 4 above file operations:         log = "write file2"; action = cp dirA/file2 dirB/file2; result = failed: there is no dirA/file2         log = "rename file1 file3"; action = mv dirB/file1 dirB/file3; result = OK         log = "rename file2 file1"; action = mv dirB/file2 dirB/file1; result = failed: there is no dirB/file2         log = "delete file3"; action = rm dirB/file3; result = OK     # End result in dirB: no more files!      Another broken example:               echo 1 > dirA/dir1/file1     mv dirA/dir1 dirA/dir2     # 'log reader' process starts working on the 2 above file operations:         log = "write file1"; action = cp dirA/dir1/file1 dirB/dir1/file1; result = failed: there is no dirA/dir1/file1         log = "rename dir1 dir2"; action = mv dirB/dir1 dirB/dir2; result = failed: there is no dirA/dir1     # End result if dirB: nothing!


title: How do I move a client from UI mockups to a set of real requirements?

text: Say you are given a mock-up of 25 screens of the visual states of your application. The expectation is that this is enough for us to be confident we can develop and hand it to the original stakeholder or customer as a finished application, and they will be satisfied. Naturally, you're going to end up asking the stakeholders many questions over again that were used to come up with the UI, which is wasteful. However, I have many many times found that this is very much not enough, in the course of developing the application the requirements become blurred by the fact that we are replicating an interface and in the end the customer is not as happy as they first seemed when we asked them for all the info to create the UI. I am just not sure what else to ask for, I have tried to be specific and ask for requirements and an understanding of the overall goal, but I don't know what I should ask for. If I just start now, lots of time is going to be wasted re-hashing all the info that lead up to the UI and during this phase many important reasons the customer originally had will be lost. How can I get people to understand that we cannot lock down requirements based on UI mock-ups by asking for something actionable they can create for me? What would you ideally start with in order to properly execute the task of developing an application for end users?


title: How to make your JavaScript private?

text: I wanted to know if there is a way to make your JavaScript private from client side?


title: Where to find resources to write a program like sandboxie?

text: Sandboxie is a program that will let you read from the hard drive, but when you try to write back it will redirect the file to a separate container. I would like to learn how to do something similar. I do not know what terms or libraries to look for. Is there a file redirection API in windows? Is there a open source library that can help me out with the down and dirty pieces? I know there is likely no API in windows to do this out of the box and I will likely need to write my own driver. I don't mind writing a driver, this project is to be a learning experience for me and I kind of want to learn how to do it. Any help would be greatly appreciated. * * * **Clarification:** I am trying to replicate the behavior of sandboxie, IE: launching a unmodified exe of another program and redirecting the way it handles file IO. What I want to do is basically have a launcher that will turn my SSD disk in to a cache for my spinning drive. I launch my app and it in turn launches another app. Any resources the other app requests will be passed through to the spinning disk, but also copied to the SSD. Any further reads and all writes will be done to the SSD copy of the file. Once the other program closes, my app will flush the writes from the SSD back to the spinning disk. I could technically do this through sandboxie and some scripting tricks but I want to learn the internals of file IO and how to do the redirection. * * * **Clarification 2:** I no-longer have a issue using a prebuilt library, as long as it is free (as in beer). It does not need to be open source or free (as in speech) .


title: Approaches to updating and adding features to PHP websites

text: I would like to know how people approach with developing their websites that are in production. For example:-   1. How do you manage versions, etc.   2. Also, do you create a subdirectory within the production server and work there or do you use any other environment and roll the updates there   3. Do you have any special management software where you keep notes, tips, deadlines, etc. I am asking this because I have a website which I would like to add new features to. But that website is in production. So, what are your suggestions on how you would update your websites and add new features? I use PHP with Apache on CentOS


title: At What Point Should You Start To Think About Performance?

text: As I'm building applications I find myself constantly asking if this is best way to perform or implement a certain functionality. Often, I'll post questions on stackoverflow or another forum desiring feedback only to receive comments about how not to "put the cart before the horse" regarding performance. Do most programmers really not think about performance until the application is finished, or performance is absolutely unacceptable?? I mean, I understand that development environments differ from production environments and that you shouldn't completely rely on the results from your dev laptop...but, there are practices and techniques that yield better performance than others. Is it bad practice to consider performance throughout the development process? Should I push these considerations off until performance actually is tanking?? **Update** Just to be clear, I'm talking about the situation where you are considering or just about to work on some piece of functionality. You know there are several ways to implement it, but you're not quite sure how well each implementation will scale. Also there might be several techniques you're not even familiar with. On a small scale any of the approaches would probably be adequate, but on a larger scale some will keep up and some won't. Often when I ask for opinions or guidance the response is: worry about it later...


title: Real programmers use debuggers?

text: If experienced programmers actually ever use debuggers, and if so under what circumstances. Although in the answer to that question I said "months" ago I probably meant "years" - I really don't use a debugger. So my specific answerable question is under which circumstances would you, as an experienced programmer, use a debugger?


title: COBOL program or JCL?

text: I have to perform 3 tasks: an insert, a delete, and a write I'm not sure what the best way to do this is. My mainframe program design skills aren't too tight, so I was looking for advice. Could I avoid doing a COBOL program for this? The way I see it, I just need JCL that executes SQL statements. If I design my statements correctly, then they should be able to preform tasks 1 and 2 this way. But I'm thinking I may need to have a COBOL program to write to a file? If I do, would I just run through database with a cursor, then process each row and take appropriate action based on the row? Each task seems similar, but the queries are different and produce different results, so the SQL statements are very different. But they are all working with the same table. Task 1:   * preform SQL query   * For each row that the query picks up      * Insert a new row based on that row Task 2:   * perform SQL query   * For each row that the query picks up      * delete the record Task 3:   * perform SQL query   * For each row that the query picks up      * Write that record to a file


title: What to focus on when separating a monolithic codebase into separate (NuGet) packages?

text: I work on a fairly large web application. The main solution containing the web application project has over 100 projects. The average build time of that solution is 2 minutes on a 12 GB quad-core machine with an SSD. We are looking into ways we can improve our deployment process. I am going to work on a proof-of-concept to move code out of the main source repository into separate repositories, to be built and packaged as NuGet packages. These will be hosted on an internal feed and installed into the main solution from there. For the proof-of-concept I want to focus on the most important/challenging aspects. I have some experience building stand-alone libraries, and of course the experience of working on this monolithic codebase. I would like to ask you: What should I focus on for the proof-of-concept? * * * Some areas I think I should experiment with:   * Versioning   * Assembly binding   * Unit testing   * ILMerge to merge dependencies   * Debugging   * Performance PS. Automating the building and publishing of packages to the NuGet repository is not my responsibility.


title: I'm Having Trouble Keeping Up

text: I'm almost 39 and have been developing for 17 years. The new 20-somethings seem to know newer ways of doing things and it's taking me A LOT longer to get up to speed. I used to do .NET but I took a new job where they do mostly Java and wow, it's a lot harder! What should I do?


title: How do you represent container classes in UML?

text: When drawing out quick class diagrams, I'm often at a loss how to represent classes that are used just to pass data around between various parts of the program. I've been putting them out in the middle of nowhere, so that other people can see what the class in the parameters/returns is. Is this the correct way to do it? _(They look awefully lonely out there by themselves.)_


title: Time management training programs for developers

text: My company asked me to set up a personal goal of improving time management. This means keeping up with time reporting, revising estimates and being responsive to email inquiries. Of course, I have read books on the topic and have tried numerous systems. I just get absorbed in coding to the exclusion of administrative tasks. I think most of it is an attitude or a psychological issue unrelated to actual time management. The company is willing to pay for it as professional training, so I'm looking for a recognized and effective training program. I would like something that doesn't just "fix" a problem, but potentially makes me more "promotable". I'm valued for my technical skills, but management is frustrated by my poor fit into overall planning and I understand that it's my main obstacle to handling more responsibility. What programs are out there that are tailored to effective and timely software development? I wonder if any project management training would be applicable, but something more specific to a software developer, or technical lead perspective would be great. Thank you.


title: Designing Subclasses for an abstract base class in C++

text: I'm doing a small assignment in C++ where I have to use concepts like virtual functions and inheritance in a domain of my choice. I'm implementing the prototype for a package manager in Linux. I have the base class Package, this has attributes like package_id, name, version, dependencies etc. There are two types of packages MetaPackages and ConcretePackages which differ in the way they must be installed and removed. I am thinking of declaring the methods install and remove in Package as virtual. While storing these packages in a datafile can I somehow know if the stored package is Meta or Concrete. I'm not sure as to how I should best design this. Can anybody point me to a resource so that I can better learn this stuff. We have Grady Booch in our curriculum and honestly it's a pain to read much less comprehend.


title: What are the ways to Promote android App

text: This is not kinda Tech question, But can anyone tell me what are good ways to Promote app other than Market.


title: Office arangement - comfort vs. teamwork?

text: Our team works in an open-space office. Luckily the cubicles are quite big (L shaped tables for everyone!), there is quite a lot of space so we are not sandwiched. Without going into further detail, there are comfortable spots (window), normal spots and stupid spots (near the corridor). * * * Until recently, the development team of twelve engineers was **seated** so that all types of spots were occupied and we were all **close together**. In the old arrangement, **verbal communication was very easy** \- half of the team was withing talking distance. The other half was like ten steps away. Often times I could ask, discuss, solve problems without leaving the cube. Most of the communication is work related, no bullshit or mental masturbation that would unnecessarily distract others. * * * Now we have moved to another part of the building and have larger space to occupy. At this point, everyone could pick their spot. Naturally all stupid spots are left empty (for the poor newcomers to occupy bwehaha). In the new arrangement, **the development team is stretched** across the floor and some of the key engineers are seated 'far' from each other - definitely not within talking distance. I have yet to experience how this works out but am getting concerned that team work and communication may have been traded for personal comfort. * * * Finally the questions... What do you think is better office arrangement? Such that allows for free verbal communication but trading for some developer's comfort, or such that potentially hinders verbal communication but makes developer's more comfortable in their spot? Or maybe it does not matter at all and we will evolve to be efficient in any arrangement? What is your personal experience? _Note - yes I read books and posts how workplace is important in our job. However in this case - we are all still in open space and the difference between the different spots are not really groundbreaking. So I'm thinking the little comfort that few developers gain is not worth the loss of easy communication._


title: Drawing Ellipse from a bounding box?

text: Does anyone know a good algorithm for drawing an ellipse from a bounding box?               draw_ellipse(int s1, int s2, int s3, int s4, color c);       I don't need something optimized to incomprehendable , unreadable efficiency. Just something good enough to use for a simple drawing api. You can provide the algorithm in your answer in all programming languages or even pseudocode, but I would prefer it if you use C++ or a C++-like syntax.


title: 2 closest points between 2 rectangles

text: On a 2D plane, I have 2 rectangles. I want to find the closest pair of points (one on each rectangle), which are closest to each other. By points I mean the corners of the rectangles. And no, they do not overlap. Is there any way to do that other than checking all the distances between all the combinations of points and finding the smallest one?


title: Question regarding ExtJS 4 GPL/commercial license

text: I am currently in the process of selecting a widget framework to be used for a new project. Current choices are Dojo/ExtJS4. We are leaning on ExtJS4 but might have some issues with the licensing. From the Sencha license page: > Our open source license is the appropriate option if you are creating an > open source application under a license compatible with the GNU GPL license > v3. However on the GPL FAQ: http://www.gnu.org/licenses/gpl-faq.html#UnreleasedMods > **A company is running a modified version of a GPL'ed program on a web site. > Does the GPL say they must release their modified sources?** > > The GPL permits anyone to make a modified version and use it without ever > distributing it to others. What this company is doing is a special case of > that. Therefore, the company does not have to release the modified sources. > > It is essential for people to have the freedom to make modifications and use > them privately, without ever publishing those modifications. However, > putting the program on a server machine for the public to talk to is hardly > “private” use, so it would be legitimate to require release of the source > code in that special case. Developers who wish to address this might want to > use the GNU Affero GPL for programs designed for network server use. Seems **contradicting** on what they have on **Sencha's** licensing page. Moreover, the webapp will be deployed on the cloud and will offer a subscription model. I've read that this is the so called **ASP loophole** and that the **Affero GPL** was made to address this. The project will have multiple modules, but certainly there would be backend/integration and frontend modules. The **frontend** will just **consume exposed REST services** and will be an entirely **different application**. The question is, would there be any license issues if we use the **GPL** version and willing to offer the source code ( **frontend module only** ) which uses ExtJS for our future clients?


title: Retrieving maximum value from a range in unsorted array

text: I have an _unsorted array_. I have queries in which I give a range and then the maximum value from that range has to returned. For example:               array[]={23,17,9,45,78,2,4,6,90,1};     query(both inclusive): 2 6     answer: 78      Which algorithm or data structure do I construct to quickly retrieve maximum value from any range. (There are a lot of queries) **EDIT:** This is indeed a simple version of the actual problem. I can have the array size as large as 100000 and the number of queries upto 100000. So I definitely require some preprocessing which'll facilitate a fast query response.


title: Why should I should url routes to the user in a single page application?

text: Why a single page application is a desktop client replacement why should I show certain url`s in the url bar of the browser. Why is mysite.com not enough. My question to you guys is now: What are the reasons and advantages for the user to show such an url like mysite.com/customers/3 Are there any reasons like the user wants to be able and bookmark a site and this would need an URI ?


title: Is there any situation when there's no alternative to instanceof?

text: It seems to me that `instanceof` comes from the land of functional programming and is a watered down version of _pattern matching_ and that the OO altenative to it should be dynamic dispatching. In OO languages (think Ruby), is there any situation where `instanceof` is the only solution? I can't think of any myself, especially in Ruby where you can patch any class with any methods you like.


title: need explanation on amortization in algorithm

text: I am a learning algorithm analysis and came across a analysis tool for understanding the running time of an algorithm with widely varying performance which is called as amortization. The autor quotes " An array with upper bound of n elements, with a fixed bound N, on it size. Operation clear takes O(n) time, since we should dereference all the elements in the array in order to really empty it. " The above statement is clear and valid. Now consider the next content: "Now consider a series of n operations on an initially empty array. if we take the worst case viewpoint, the running time is O(n^2), since the worst case of a sigle clear operation in the series is O(n) and there may be as many as O(n) clear operations in the series." From the above statement how is the time complexity O(n^2)? I did not understand the logic behind it. if 'n' operations are performed how is it O(n ^2)? Please explain what the autor is trying to convey..


title: Is parsing a submitted JSON object safe?

text: I have a RESTful API, built in NODE.js that does what you would expect it to: consumes data and then makes it accessible. Currently, data being submitted to my server is nested form data:               data[0][username]=...     data[0][email]=...     data[0][phone]=...     ...     data[12][username]=...     data[12][email]=...     data[12][phone]=...      or as a query string               data[0][username]=...&data[0][email]=...&data[0][phone]=...      SO when I parse it on the server, I get a JS array of objects with those particular fields. What I am wondering is, is it safe for me accept a string that I can JSON.parse and the process it?               data=(some stringified json object)      I am unsure if it's possible for malicious code or anything to be included in the JSON object that would blow up my server once run through a parser Thanks.


title: Clojure state and persistence

text: I'm learning Clojure to see if it's something I can leverage at my current job, and more importantly, how I can convince my bosses that Clojure has a 'killer feature' over java that makes it worth the investment1. The feature that I'm guessing most clojure evangelists would tout is **state management and concurrency**. The example that I see often in blogs and books is an account balance that’s being updated by multiple threads. Clojure’s state management can always cleanly ensure that the balance will be accurate regardless of the number of threads reading and writing that value. In practice, though, an application would never allow an account balance to live only in memory, it would have to be persisted outside of the JVM (probably in a database) for two hopefully obvious reasons:   1. If the app goes down the database will need to accurately reflect the latest state for recovery. For this reason the database cannot be asynchronously updated, and all reads would have to block until the database update is complete.   2. If other applications are reading or manipulating the account balance (maybe because we’ve scaled our app out to several servers), that balance would need to be kept in sync between all instances. **Can Clojure’s state management handle situations like this elegantly?** For instance, given scenario 2 above, _all_ reads of the account balance would first need to check the database to get the value, and if the database is locked, it would have to block until the correct value is available, no? It’s great that Clojure handles my in-memory concurrency very elegantly but if that elegance can’t be extended to external state then do I really gain anything? 1(note that things like expressiveness, elegance, etc. are rarely considered killer features by mgmt.)


title: Which software development practices would you recommend non-programmers implement in their fields of work?

text: Say you had to give a talk to non-programmers who were looking to learn something from software development that they could apply to their own functions. **Question** : What practices would you preach? Assume the jobs involve taking basic technical building blocks and combining them in creative ways to solve user-specific problems. **Example** : I'm a corporate financial analyst. I'd have loved it if a software development person taught me about the following ideas when I was younger:   1. **Orthogonality** has helped me think about independent analytical tools that can be reused more easily (vs. huge integrated analytics that break the second one piece of the tool is changed).   2. **Code to an interface, not an implementation** has helped me think about defining interfaces to my spreadsheets that aren't as dependent on things like independent cell locations, etc.   3. **Test-driven design** has helped me to test my analytics on test cases before I roll them out.


title: Is event chaining considered good practice?

text: From time to time I've encountered scenarios where several complex conditions need to be met prior to triggering an event. Furthermore, most listeners also run additional checks to determine the course of action. This got me thinking whether a better solution would be to think in terms of smaller events and let them trigger inside each other. Chaining events would allow me to weave in any additional listeners later on with fairly low effort (possible violation of YAGNI?). My code would consist of simple easily understood elements, which shouldn't be difficult for others to understand. However, the possible downsides to this solution would be the fact that should something happen to go wrong in the chain (e.g false event triggering due to human error), it would be quite difficult to catch the bug. Is event chaining a good ideaTM? If not, what are the alternative methods to keep event related code getting cluttered?


title: Why is spring so good for Java middleware development?

text: I'm planning on doing some Java web development in my spare time to learn a new set of programming skills, and just want to survey opinion on why Spring is so good for middleware development? What are the key features and advantages of using this over, say struts or writing server pages?


title: What are some good assignments for an introductory course on concurrent programming?

text: I am teaching a course which involves introducing the students to the concept of threads and concurrent programming. I am in search of programming assignments that can gently get them to accept the technique as a part of a programmer's essential toolkit. A good assignment would be to implement a program that   * is impossible to implement sequentially, or shows great increase in efficiency when parallel processing is introduced.   * does not overly rely on the introduction of complicated unrelated concepts. This rules out most of the Wikipedia example list of Embarrassingly parallel problems \- even the Mandelbrot set requires the students to know about imaginary numbers, which I can not assume.   * does not seem contrived. Optimally, the assignment would not seem like a stretch useful only for the introduction of the concept. What would an example of such a program/algorithm be? In case it matters, the assignment will be in Java. The students are around the age of 18, with at least a year of solving simple programming assignments behind them (they are familiar with control flow, loops, most common datatypes, OOP, simple GUIs) but so far have little experience with large software projects or usual computer science subjects (such as recursion and algorithm analysis).


title: Trace code pascal

text: I haven't worked with Pascal so far, and my problem is understanding the recursive aspects that prm assignment operators and how the final (correct) value is derived. Would someone please explain that line for me.               Program test(output);          FUNCTION prm(az:integer) : real;     begin         if az = 1 then             prm := sqrt(12)         else             prm := sqrt(12*prm(az-1));     end;          begin         writeln(prm(30):0:2);     end.


title: One Scheduler vs. Many Schedulers

text: I've been using a single scheduler to handle all my scheduled tasks (Quartz.Net). I'm starting to rethink how this operates because if I need to update 1 task, I have to stop the entire process, release the update, and start it back up. My Question: Is it better to have many Windows Services running individual tasks (or groups of similar tasks) or 1 Service running all of the tasks (my current set up)?


title: How should I prepare for a coding phone interview?

text: I'm going to write code during a phone interview in the next few weeks. The interviewer and I will use a collaborative text editor to both view the code. I have a few questions since this is my first time writing code during a phone interview:   1. What are common **questions** asked during this type of interview?   2. What are common **gotchas** in this situation? (for both interviewer and candidate)   3. Does the **interviewer** commonly **write code** too? (perhaps a function w/ an empty body) Any other tips and advice is greatly appreciated!


title: Are computers just means to an end, or can they contribute to the productivity and creativity of programmers?

text: This is not a question with a single answer, but I am fascinated by the diversity of computer set-ups in the office. Some people work on ancient machines that are absolute donkeys with CRT monitor, whereas others have really complex and elaborate configurations that would make Forex traders jealous. To add to the intrigue, in a recent job interview I had, the employer stressed several times that "modern high-spec workstations" were provided to developers, including access to latest gadgets in the mobile and tablet world. While this seems like a no-brainer, majority of large companies I encountered don't exactly pump cash into internal technology provisioning, or advertise the kind of hardware they provide to employees. What are your experiences and opinions on this? Can computers that are not up to the task really be severely detrimental to productivity of programmers? At the end of the day, for companies, it's up to the cost/benefit ratio; Does it make sense to equip IT staff with latest and greatest? Technology is becoming more and more pervasive in everyday life. If a company doesn't keep up, how does that reflect on it? This is a topic that interests me personally, but I also believe it should be examined in more detail. In addition to opinions expressed here, should you wish to help formalize some research in this area, you can take 5 minutes of your time and fill out the survey at the link below. Thanks in advance! :) http://edu.surveygizmo.com/s3/508308/Workstations-and-productivity


title: Integration tests across a 3-tier .NET solution

text: I have a 3-tiered .NET solution.   1. Database (SQL SERVER 2008)   2. Web Service (SOAP Service - *.asmx)   3. WPF Client I am comfortably writing Unit Tests within (3) The Client.   I am currently working on writing tests between (1)Database & (2)Service. My question is, what are some useful ways to run integration tests across all 3 tiers. I would like this to run locally in my Test Runner, as well as part of the integration test. Primarily, I am stuck on how to have a transient (setup-teardown-able) (2) Web Service & (1) Database that can be tested with (3) Client code as part of a full integration test.


title: Tips for organizing a "Hack Day" at work

text: **I was thinking about organizing a "Hack Day" at work** , think google's 20% time but just for 1 whole day (maybe just once per year or quarter). Similar to Atlassian Fedex Days I'd like for all the developers in our group to have a free day to work on any kind of project / technology they like and then show it off. Ideally, developers have fun programming without worrying about their day to day projects or technology restrictions and at the same time we can generate some cool ideas that could turn into future projects or patents etc. **Do you have any tips / suggestions for me?**   \- Has anyone organized something similar before?   \- Any pitfalls to watchout for or tips for success?   \- Any resources I should request to make the day go better? day more productive /enjoyable?   \- Should I encourage / enforce groups? Or is it better for people to work on things individually?   \- What can I use to persuade management to support this?


title: Scope vs Visiblity vs Lifetime vs Accessibility vs etc

text: I have been trying to understand what it means to say "scope of a named entity". In reading about scope, there are terms like visibility, lifetime, accessibility and more that are used. What is confusing is the fact that the terms are at times used distinctly and at times interchangeably. Quoting from this IBM article: > scope is... the largest region in which the name potentially is valid. Fair enough. But then what does this mean - > The visibility of an identifier is the region of program text from which the > object associated with the identifier can be legally accessed. Is visibility related to accessibility? Further it goes on to say > Scope exceeds visibility when a duplicate identifier is used in an inner > declarative region, thereby hiding the object declared in the outer > declarative region. The original identifier cannot be used to access the > first object until the scope of the duplicate identifier (the lifetime of > the second object) has ended. Does this mean scope and lifetime are the same things? Do these terms like scope fundamentally mean the same thing in C++ as it does in say PHP or Python or even Java. Or they could mean different things conceptually depending on the language you are working in. The article I have quoted is C/C++ related, but I want to understand the terms in the general sense.


title: What should every programmer know?

text: Regardless of programming language(s) or operating system(s) used or the environment they develop for, what should every programmer know? Some background: I'm interested in becoming the best programmer I can. As part of this process I'm trying to understand what I don't know and would benefit me a lot if I did. While there are loads of lists around along the lines of "n things every [insert programming language] developer should know", I have yet to find anything similar which isn't limited to a specific language. I also expect this information to be of interest and benefit to others.


title: Coarse-grained views on server vs fine-grained views assembled on client vs fine-grained views with batching

text: I've currently got a browser talking via an "API" to the server. API is scare quoted because the API really wouldn't support another user interface very well, because it consists of every call our UI happens to need, in the form it happens to need it, and nothing else. Which could be fine. However, we are starting to have calls along the lines of "GetUserSummaryData", "GetUserHisFriendsAndHisPurchases", "GetUserAndHisPurchases", etc. Note that on the server a more reasonable fine-grained API is written, (and the current API calls just cause the server to wire those together) it's just that what is exposed to the UI matches _exactly_ what it needs at that particular moment. The justification for the current approach is that going from "I need those 6 things at the moment" to "I need to make 6 calls and put the data together" has to happen _somewhere_ , and if you do it on the server then the browser can make 1 course-grained call, vs. the alternative of either making 6 calls and taking a (significant) performance hit, or else figuring out some system of batching the 6 calls (including dealing with the issue of dependencies, possibly by having the call batching mechanism smart enough to say "the 3rd parameter of call 2 should be this part of the JSON response object from call 1" and having the server understand that). Doing things on the server as we are does make it pretty much impossible to write another UI without making more customized views on the server to support it. But we have no reasonable current expectation that someone without access to the server would want to write another UI. Is continuing to make really customized views on the server as the only "API" the right approach, and if not what would be better?


title: Are certification test engines really what they claim?

text: I am studying for my MCPD certification from microsoft. There are plenty of resources for these certs. However I had someone reccomend CertMagic recently. With a little research I quickly discovered that there are quite a few sites like this. So i have two questions: 1) Will these sites really help ? I don't want to memorize exam answers. I want my certification to be a true representation of my skills in that subject. 2) If these sites really are helpful, which do you find to be most helpful ?


title: what is the correct/best way to populate a secondary property of an MVC Model and how do I unit test it?

text: I'm building an web application is ASP.NET MVC 3 (.NET 4) and trying to unit test as much as possible. I have a controller action `Details(int customerId)` which should display a view who's model is a `Customer`               public class Customer     {         public int? Id { get; set; }              [Required]         [Display(Name = "Customer Name")]         public string Name { get; set; }              ...              public IList<CustomerComment> Comments { get; set; }     }       The controller action looks like this:               public ActionResult Details(int customerId)     {         var model = service.Get(customerId);         if (model != null)             return View(model);              return RedirectToAction("Index");     }      As you can see, this directly calls `service.Get`               public Customer Get(int id)     {         return repository.Get(id);     }      The service has an `ICustomerRepository` injected in it and calls the `Get` method of that repository directly. My question regards populating the `Comments` collection. **How/where should the`Comments` be populated and how do I test it?** The `Details` view is the only place that displays the list of comments, so it needs this data. I can see two ways of populating this.   1. Do it all in the `ICustomerRepository.Get` implementation.   This might lead to a situation down the line where I'm using Get but not displaying the comments. This would mean I'm doing an _expensive_ (maybe) `JOIN` but not using the results.   2. Have an `ICustomerCommentsRepository/Service` injected into either my Service or Controller which is used to populate the `Comments` when required. Is there a preference? Secondly, how would you test this? In the second instance, I could assert that `ICustomerCommentsRepository.Populate(Customer customer)` is called on my mock by the Controller/Service. In the first situation all the responsibility lies in my repository so in a Unit Test sense, is untestable as the concrete implementation used in the actual app needs to speak to the DB and so is an integration test. Am I missing something? Would the `ICustomerCommentsRepository` be a bad idea?


title: Train for the job or train for the skill?

text: I'm in charge of hiring for a small java shop. We have a very limited hiring budget so we tend to pickup fresh grads cheap and spend time training them. I have found colleges and universities do quite an inadequate job these days and usually a lot of training is required. I train in 2 steps: a) Get them comfortable with Java conventions. b) Teach them programming concepts (again). Training ranges from 1 week to 1 month depending on the number of people we hire. My problem is that training them on Java I feel I rob them of the ability to _understand_ what they are doing. Colleges train them for C# so they never really understand what the code _translates_ to for the JVM or how the computer interprets this. I of course keep realizing this when I see blatantly inefficient code being laid down. My question is, if an employee will stick with the company for 3 years, is it better to train the employee for the job so they can start coding in Java or is it better to get them comfortable with Java and pick-up languages like Python, C/C++, Prolog, LISP to teach them what they are really doing? (Keep in mind there will be a learning curve again if I change languages). So over 3 years, what do you feel will pay-off more? The suits clearly say train for the job since iteration is high. **UPDATE** Bottom line is that they will be working on a product that is effectively a development environment in Java. Basically a BPMN based product that lets you specify the flow of an application graphically and use stock features to add functionality and lay-down custom java code as needed.