What is a class library?

I'm working on a lawsuit and I need a definition of a 'class library' that I can reference. Every book and all the documentation I can find seems to assume the reader already knows what a library is. Even the wikipedia entry on 'Library (computing)' is low on references. And the references it does have are from the 80s or earlier. So, in the context of C#, what is a class library? (with references) I have been getting a decent number of definitions from 'Design Patterns: Elements of Reusable Object-Oriented Software' but it also assumes the reader knows what a library is.


How to be a zero-bug programmer?

My boss has always told me that a good programmer should be able to ensure that the code he or she changes is reliable, correct, and thoroughly self- verified; that you should completely understand all the results and impacts your changes will cause. I have tried my best to be this kind of programmer—by testing again and again—but bugs are still there. How can I be a zero-bug programmer and know what every character of my code will cause and affect?


Coding to interfaces

I understand why it is a good idea to code to an interface rather than to a concrete class. I find it hard to implement though as other methods generally need to use properties of the given object. Have I got the wrong end of the stick?


Programming paradigms and the maintenance developer

I was reading, Facts and Fallacies of Software Engineering, which has a section of maintenance. Since, I'm have been a maintenance developer for years now, I was very interesting facts presented. Here's three.   * Fact 41: Maintenance typically consumes 40 to 80 percent (average, 60 percent) of software costs. Therefore, it is probably the most important life cycle phase of software.   * Fact 42: Enhancement is responsible for roughly 60 percent of software maintenance costs. Error correction is roughly 17 percent. Therefore, software maintenance is largely about adding new capability to old software, not fixing it.   * Fact 45: Better software engineering development leads to more maintenance, not less. This one was counter-intuitive, turns out that good software has more maintenance, because it's easy to change. Hence, it stays in use longer, leading to, yes, more changes. Which paradigm (such as functional, object-oriented, procedural) has the best maintainability, and is there any research to back this up?


Methodologies commonly used for embedded software development?

I am doing research on software development methodologies are commonly used for embedded software development, and how they differ from their non-embedded software development counterparts. I am having a hard time finding good resources on this topic so if you can recommend me some papers, websites or other material, I will be very grateful.


Given n distinct keys, how many different 2-3/Red-black trees can be constructed?

## Memory refresher/My understanding: A 2-3 tree is a balanced search tree that allows two types of nodes.   1. 2-node: Normal node with two children.      * LChild < Parent and RChild > Parent   2. 3-node: Node with two parents and three children.      * Parent1 < Parent2     * LChild < Parent1, Parent1 < MChild < Parent2, RChild >Parent2 A 2-3 tree is always balanced, and grows when the root raises the height of the tree by one. http://en.wikipedia.org/wiki/2%E2%80%933_tree My question is then as follows, **given n distinct keys, how many different 2-3 trees can one construct?** My math skills are poor, so if anyone knows how I should "math" in order to approach an answer, then that would be awesome! :)


parsing terminology: comments+whitespaces vs actual code

In languages like c/c++ spacing and comments are ignored and only actual code gets into compiler. I'm interested if there is accepted way of naming these two things?   * comments & spacing   * everything else (actual code) Referring to comments & spacing as "comments & spacing" is quite annoying. Any ideas?


Are there mainstream general-purpose non-Turing complete languages available today?

Non-Turing complete languages offer a great advantage over Turing-complete languages as they are much more analyzable and, thus, offer much broader optimization possibilities. Yet they are barely used and Turing-completeness is actually sold as a good feature. Are there any mainstream non-Turing-complete languages available today that are made for general-purpose programming?


Implementing the Interface Segregation Principle

Does this `IConvertible` interface satisfy the Interface Segregation Principle (ie. the "I" in SOLID)? Here is the definition:               public interface IConvertible     {         TypeCode GetTypeCode();          bool ToBoolean(IFormatProvider provider);         byte ToByte(IFormatProvider provider);         char ToChar(IFormatProvider provider);         DateTime ToDateTime(IFormatProvider provider);         decimal ToDecimal(IFormatProvider provider);         short ToInt16(IFormatProvider provider);         int ToInt32(IFormatProvider provider);         long ToInt64(IFormatProvider provider);         sbyte ToSByte(IFormatProvider provider);         float ToSingle(IFormatProvider provider);         string ToString(IFormatProvider provider);         object ToType(Type conversionType, IFormatProvider provider);         ushort ToUInt16(IFormatProvider provider);         uint ToUInt32(IFormatProvider provider);         ulong ToUInt64(IFormatProvider provider);     }      So if I would like to have a class which will implements this `IConvertible` interface the I have to implement all of those methods, right? Or if I don't implement all of them, then I have to at least make an empty method or throw an Exception, right?. In my opinion, the better way is to make more interface with fewer methods, for example:               public interface IConvertibleInt     {             short ToInt16(IFormatProvider provider);             int ToInt32(IFormatProvider provider);             long ToInt64(IFormatProvider provider);     }      Or even:               public interface IConvertibleInt16     {             short ToInt16(IFormatProvider provider);     }          public interface IConvertibleInt32     {                         int ToInt32(IFormatProvider provider);     }          public interface IConvertibleInt64     {             long ToInt64(IFormatProvider provider);     }      Is my reasoning correct?


A good way of creating XML files at run time

Please stare at this structure for a second :) ![enter image description here](http://i.stack.imgur.com/uZaWg.png) I should create such a thing all at run time. What are the values that we pass in at run time? the string values you see after "#" are passed in so for example AnimalBio, ClinBio, HumanGenome,etc... So I am thinking of declaring some methods like               void AddDeclaration(string str) ;     void AddSubClass(string parent, string child);      such that when I call them they will create those XML-ish tags for me with the values I pass in such as HumnaBio. These are around 15000 items that I am gonna add... What is the best approach that you would suggest for doing this? Do you think using XMLDocument class is the best way of doing it? or do you think I should go with StringBuilder class and add these as strings, or other ways of doing it? Thanks.


What is a license and how may I use code under a license?

(Let me edit this question to try to better get across what I am asking.) I don't understand what a license is and how I may "use" it. From the little that I do understand, there are two situations:   1. One writes a program/source code and _puts_ a license on it. The license says how other people may (are allowed) to use the program/source code.   2. I find a program/source code and would like to use it. The program comes with a license and the license tells me how I am allowed to use the program/source code. It is this second point that I am confused about. I have no experience with "using" licenses. I see some previous questions about licenses being closed, so just to make it clear: I am not asking for legal advice. I just want to make sure that I am doing it "right". I just want to know how one can use a license. To given a concrete real world example of what I am asking: I want to use the library CryptoJS 3.1 to make a web page (to put online for the whole world to see) using this library, but I am uncertain about how I may do this. From what I understand: according to the page about the library, the the library is offered under a license called the New BSD License. But I don't understand what this license is telling me about how I am allowed to use the source code. Specifically, I would appreciate if someone could explain (as if I was a 12 year old): _What do I need to do to use this library on my web page?_ For example: Do I need to give tribute with a link or something like that? One specific thing that is confusing me is that on the page of CryptoJS 3.1 it actually doesn't tell me what the license is verbatim. It says that the license is the New BSD license. There is a link to this page. And one that page is a _template_ for a license. So how do I make sense of this? In summary: I would like to use CryptoJS 3.1, but I don't know how I may do that. * * * (I have figured out the export regulations requirement, so that isn't an issue for me.)


For csv database extracts, how do map keys not create a dependency?

A lot of my work is done with .csv extracts (reports) from databases. As I have been programming in Clojure, I've received comments that relying on vector indexes creates dependencies. I understand why, and concur. I am rewriting one of my programs to take advantage of the fact that each report's first row contain the column headings, and I could go after each row of data I want by map key. I am rewriting some code to zipmap the headings made into map keys and one row of data (at a time) so I can access the data I want. Here is an example.               (def bene-csv-inp  (fetch-csv-data "benetrak_roster.csv"))     (def bene-csv-cols (first bene-csv-inp))     (def bene-csv-data (rest bene-csv-inp))     (def zm1 (zipmap           (map #(keyword %1) bene-csv-cols)                              (first bene-csv-data)))     (zm1 :EmploymentStartDate)     "21-Jun-82"      Does a higher level of extraction exist, and if so, what is it that would allow my code not to have to have to hard-code `:EmploymentStartDate` ? If my code has to know these keys, then how is that also not a dependency like an index? Personally, I like going after the data with map keys, because it's less confusing and more informative than indexes. However, I believe I still have a dependency. Thanks.


S.O.L.I.D., avoiding anemic domains, dependency injection?

Although this could be a programming language agnostic question, I'm interested in answers targeting the .NET ecosystem. This is the scenario: suppose we need to develop a simple console application for the public administration. The application is about vehicle tax. They (only) have the following business rules: 1.a) If the vehicle is a car and the last time its owner paid the tax was 30 days ago then the owner has to pay again. 1.b) If the vehicle is a motorbike and the last time its owner paid the tax was 60 days ago then the owner has to pay again. In other words, if you have a car you have to pay every 30 days or if you have a motorbike you have to pay every 60 days. For each vehicle in the system, the application should test those rules and print those vehicles (plate number and owner information) that don't satisfy them. What I want is: 2.a) Conform to the S.O.L.I.D. principles (especially Open/closed principle). What I don't want is (I think): 2.b) An anemic domain, therefore business logic should go inside business entities. I started with this:               public class Person     // You wanted a banana but what you got was a gorilla holding the banana and the entire jungle.     {         public string Name { get; set; }              public string Surname { get; set; }     }          public abstract class Vehicle     {         public string PlateNumber { get; set; }              public Person Owner { get; set; }              public DateTime LastPaidTime { get; set; }              public abstract bool HasToPay();     }          public class Car : Vehicle     {         public override bool HasToPay()         {             return (DateTime.Today - this.LastPaidTime).TotalDays >= 30;         }     }          public class Motorbike : Vehicle     {         public override bool HasToPay()         {             return (DateTime.Today - this.LastPaidTime).TotalDays >= 60;         }     }          public class PublicAdministration     {         public IEnumerable<Vehicle> GetVehiclesThatHaveToPay()         {             return this.GetAllVehicles().Where(vehicle => vehicle.HasToPay());         }              private IEnumerable<Vehicle> GetAllVehicles()         {             throw new NotImplementedException();         }     }          class Program     {         static void Main(string[] args)         {             PublicAdministration administration = new PublicAdministration();             foreach (var vehicle in administration.GetVehiclesThatHaveToPay())             {                 Console.WriteLine("Plate number: {0}\tOwner: {1}, {2}", vehicle.PlateNumber, vehicle.Owner.Surname, vehicle.Owner.Name);             }         }     }      2.a: The Open/closed principle is guaranteed; if they want bicycle tax you just inherit from Vehicle, then you override the HasToPay method and you're done. Open/closed principle satisfied through simple inheritance. The "problems" are: 3.a) Why a vehicle has to know if it has to pay? Isn't a PublicAdministration concern? If public administration rules for car tax change, why Car has to change? I think you should be asking: "then why you put a HasToPay method inside Vehicle?", and the answer is: because I don't want to test for the vehicle type (typeof) inside PublicAdministration. Do you see a better alternative? 3.b) Maybe tax payment is a vehicle concern after all, or maybe my initial Person-Vehicle-Car-Motorbike-PublicAdministration design is just plain wrong, or I need a philosopher and a better business analyst. A solution could be: move the HasToPay method to another class, we can call it TaxPayment. Then we create two TaxPayment derived classes; CarTaxPayment and MotorbikeTaxPayment. Then we add an abstract Payment property (of type TaxPayment) to the Vehicle class and we return the right TaxPayment instance from Car and Motorbike classes:               public abstract class TaxPayment     {         public abstract bool HasToPay();     }          public class CarTaxPayment : TaxPayment     {         public override bool HasToPay()         {             return (DateTime.Today - this.LastPaidTime).TotalDays >= 30;         }     }          public class MotorbikeTaxPayment : TaxPayment     {         public override bool HasToPay()         {             return (DateTime.Today - this.LastPaidTime).TotalDays >= 60;         }     }          public abstract class Vehicle     {         public string PlateNumber { get; set; }              public Person Owner { get; set; }              public DateTime LastPaidTime { get; set; }              public abstract TaxPayment Payment { get; }     }          public class Car : Vehicle     {         private CarTaxPayment payment = new CarTaxPayment();         public override TaxPayment Payment         {             get { return this.payment; }         }     }          public class Motorbike : Vehicle     {         private MotorbikeTaxPayment payment = new MotorbikeTaxPayment();         public override TaxPayment Payment         {             get { return this.payment; }         }     }      And we invoke the old process this way:                   public IEnumerable<Vehicle> GetVehiclesThatHaveToPay()         {             return this.GetAllVehicles().Where(vehicle => vehicle.Payment.HasToPay());         }      But now this code won't compile because there's no LastPaidTime member inside CarTaxPayment/MotorbikeTaxPayment/TaxPayment. I'm starting to see CarTaxPayment and MotorbikeTaxPayment more like "algorithm implementations" rather than business entities. Somehow now those "algorithms" need the LastPaidTime value. Sure, we can pass the value to the constructor of TaxPayment, but that would violate vehicle encapsulation, or responsibilities, or whatever those OOP evangelists call it, wouldn't it? 3.c) Suppose we already have an Entity Framework ObjectContext (which uses our domain objects; Person, Vehicle, Car, Motorbike, PublicAdministration). How would you do to get an ObjectContext reference from PublicAdministration.GetAllVehicles method and therefore implement the funcionality? 3.d) If we also need the same ObjectContext reference for CarTaxPayment.HasToPay but a different one for MotorbikeTaxPayment.HasToPay, who is in charge of "injecting" or how would you pass those references to the payment classes? In this case, avoiding an anemic domain (and thus no service objects), don't lead us to disaster? What are your design choices for this simple scenario? Clearly the examples I've shown are "too complex" for an easy task, but at the same time the idea is to adhere to the S.O.L.I.D. principles and prevent anemic domains (of which have been commissioned to destroy).


Handling array passed to object at creation

When creating my object I pass it an array of a row from my database. (everything in the array we will need, disregarding unnecessary elements at sql query level) When I need to access certain array elements from within my class, I do so like               $this->row['element']      However, As I continue development, I sometimes forget what exactly is in this passed array.(this itself doesn't seem good) I am wondering if their is a professional approach to dealing with this, Or am I the only one who has these "I wonder whats in the array" thoughts. One approach to tackling this could be that when we originally pass the array, in the constructor, we assign each element of the array to its own variable, but is this considered professional practice? Additionally by doing this, we could make those variables constants, in a attempt at immutability. Overall I am trying to adhere to good software craftsmanship. Regards.


I have a web service. Right now, I have passwords stored in plain text in a MySQL table on my server. I know this isn't the best practice, and that is why I am working on it. Why should passwords be encrypted if they are being stored in a secure database? I realize that if someone hacks in to my database they will get everyone's password. But I have other problems if someone gets in my database, for example, deleting data. The scenario I can think of is that you are hacked. You restore a database from a couple of hours ago and everything is well. However, if your passwords are plaintext... The thief has all the passwords and you have to reset them all. Hassle to your users. If the passwords were encrypted, you could just restore to previous database. Is this correct thinking?


Is a Unique ID column needed in a many-to-many (junction) table?

Getting a few projects started with EF, but I had some questions about join tables and keys etc. Lets say I have a table of applications and a table of permissions. Applications have many permissions and each permission can belong to many applications (many-to-many). Now, the Application and Permission tables are easy:               Applications     --------------     PK  ApplicationID         Name          Permissions     --------------     PK  PermissionID         Name      But what's the BEST way to do the join table? I have these two options:               ApplicationPermissions     -----------------------     PK  ApplicationPermissionID     CU  ApplicationID     CU  PermissionID      OR               ApplicationPermissions     -----------------------     CPK ApplicationID     CPK PermissionID          PK = Primary Key     CPK = Composite Primary Key     CU = Composite Unique Index      Have you ever been burned doing it one way over the other? is it strictly preference? It has occurred to me that a lot of the "differences" will be abstracted away by my repository pattern (for example, i would almost never create an entire permission object and add it to an application, but do it by ID or unique name or something), but I guess I'm looking for horror stories, one way or the other.


Getting started with object detection - Image segmentation algorithm

Just getting started on a hobby object-detection project. My aim is to understand the underlying algorithms and to this end the overall accuracy of the results is (currently) more important than actual run-time. I'm starting with trying to find a good image segmentation algorithm that provide a good jump-off point for the object detection phase. The target images would be "real-world" scenes. I found two techniques which mirrored my thoughts on how to go about this:   1. Graph-based Image Segmentation: http://www.cs.cornell.edu/~dph/papers/seg-ijcv.pdf   2. Contour and Texture Analysis for Image Segmentation: http://www.eng.utah.edu/~bresee/compvision/files/MalikBLS.pdf The first one was really intuitive to understand and seems simple enough to implement, while the second was closer to my initial thoughts on how to go about this (combine color/intensity and texture information to find regions). But it's an order of magnitude more complex (at least for me). My question is - are there any other algorithms I should be looking at, that provide the kind of results that these two, specific papers have arrived at? Are there updated versions of these techniques already floating around? Like I mentioned earlier, the goal is relative accuracy of image segmentation (with an eventual aim to achieve a degree of accuracy of object detection) over runtime, with the algorithm being able to segment an image into "naturally" or perceptually important components, as these two algorithms do (each to varying extents). I found these two papers after a couple of days of refining my search terms and learning new ones relevant to the exact kind of techniques I was looking for. I have just about reached the end of my personal Google creativity, which is why I am finally here! I do not know if this is a better fit for cstheory.stackexchange (or even cs.stackexchange). I looked, but cstheory seems more appropriate for intricate algorithmic discussions than a broad question like this. Also, I couldn't find any relevant tags there either! But please do move if appropriate.


What do you believe is a better of method of learning languages: using books or jumping straight into a project?

Do you find that it is better to learn through reading books or to just jump straight into a project and pick up what you need to know using the web, or some combination of both?


Object Oriented "normalization"

In database programming there's a technique called "normalization" that you do to data you want to store. Has anyone tried to apply this concept to object design? How did you? How did it work out? Edit: To expand/clarify, database normalization is more than a set of principles to reduce redundancy. There's actually steps and stages you go through and at least moderately objective measures that tell you which stage you are in. Object design has its own principles, and there's the concept of smell, but is there any way to do something similar that would tell you that you're in XX-form0,1,2...etc...and methods to move to the next most "normalized" level?


Use Case Diagrams - should I create a diagram just for a view business rule?

I'm modeling a UCD where I have two actors ( a content producer and a developer).. the content producer is going to create and specify details of a storyboard functionality, and the other actor (developer) will only be able to view this storyboard ( he'll log in the application and read the storyboard to start developing what it says, outside the application..) I'm working on the specification of this storyboard functionality and I'd like to know it would be like a best-practice if I describe something like " > actor- developer", "UCD - read scenes of storyboard" . This is the specification of an application I developed for my thesis and they asked me to add some specification...


Why don't databases have good full text indexes

Why don't any of the major RDBMS systems like MySQL, SQL Server, Oracle, etc. have good full text indexing support? I realize that most databases support full text indexes to some degree, but that they are usually slower, and with a smaller feature set. It seems that every time you want a really good full text index, you have to go outside the database and use something like Lucene/Solr or Sphinx. Why isn't the technology in these full text search engines completely integrated into the database engine? There's lot of problems with keeping the data in another system such as Lucence, including keeping the data up to date, and the inability to join the results with other tables. Is there a specific technological reason why these two technologies can't be integrated?


Why do some opensouce libraries lack comments?

I don't know if this happens to most Opensource libraries, but many of I know and use (for example OpenSSL, Webkit, ...) they all lack comments, or contain very few comments. Not to mention their very few documents, it is hard to read their source code. We can hardly understand what a member variable means, or what this function does. This seems to be against coding standard practice Why is that? How can people collaborate to these opensource with very few comments?


Do you think managed OSes are a good idea?

Managed OSes like Microsoft Singularity and JNode are quite an interesting concept. Essentially, the OS is bootstrapped with code written in a low-level language (C/C++/Assembly), which essentially implements a virtual machine. The rest of the OS (and all userland apps) run on the virtual machine. There are some great things about this. For example, you suddenly make arbitrary pointers obsolete. And if well written, you get rid of a ton of legacy crud that most modern OSes currently have. However, as a disadvantage, you're that much farther away from the hardware, and as a developer, you lose the ability to drop down to a lower level of abstraction and get your hands dirty. What are your opinions on this?


Is programming an art or a desk job?

Developing software needs a clear mind, full of creative ideas (art) & good knowledge in computing, software domain and logic (science). Still many companies consider programming as a desk jobs, where you have tasks you have to finish. But it's not just paper filing, developers are more creative on few days than others, more keen to solve the software issues and problems one day and the other day they don't feel like even if they try hard to do so. How should IT department management concider this issue? Should developers be considered as artists and given full time to do what they like to do (many will not deliver software on time like that) or should developer be treated as assembly workers who have to finish their specific tasks no matter how they feels about it (will not get quality results)? I think it should be somewhere in the middle, but where exactly?


Users creating instances from a template - is there a software pattern that corresponds to this use case?

I am looking into designing a system where users build a template item and then create many instances based on this template.They then need to be able customise each instance but I also need for them to be able to make changes to the template and have all instances updated. These items are fairly complex, each consisting of many components that will be stored in numerous database tables. I see two implementation paths.   1. Store complete copies of the templates to create the instances and migrate updates to the instances.   2. Store records only for the changes and build each instance from a combination of the template and instance changes. I believe the first option would create a lot of unneeded extra data however the 2nd way introduces complexities in querying the data. This seems like it has probably been implemented many times before but I am having trouble finding much reading material. Are there common names for data models or pattern options used in implementations of such systems? Any advice on benefits or pitfalls of each option, other options, or implementation guidance would be useful too. **edit:** Sorry I may not have been clear. I was looking more for a name for the general architecture not a design pattern. It is the end users who create instances not developers. For example the system might allow users to define templates to model manufacturing processes of many items. Then at different sites where facilities or requirements are different, the end user would would use one of these templates to define a process specific for that site. Things will be added, removed and modified for each site. I believe I will go with option two mentioned above - storing only delta changes, not complete copies.


script engine with no global environment (java)

I am curious about how global variables are handled by script engines. I am looking for a script engine that does not preserve the state of global variables upon invocation. Are there such engines out there? We are looking for a scripting language we can use under the script engine API for Java. When making multiple invocations of a script engine, top-level calls to eval() or evaluate() method preserves the state of global variables, meaning that consequent calls to eval() will use the global variables as they were left by the last invocation. Is there a script engine that does not preserve the state, or provides the ability to reset the state, so that global variables are at their initial state every time the script engine is invoked?


How do you visually represent programming skills?

I had a discussion with a recruiter recently that made me wish I could visually represent programming skills. In trying to explain how skills relate, **what are the important properties of those skills?** Would a tagging model work (i.e. "Design Pattern," "Programming Language," "IDE," or "VCS")? Are they really hierarchical? Clarification: The real problem I see is communicating the level of granularity among skill sets. For instance saying someone "knows Java" is a uselessly broad term in describing what someone can DO. However saying they know how to write web services with the Java Programming language is a bit better. To go even further, saying they know Spring as a tool under all that is probably specific enough. What should we call those levels of granularity? What are the relationships between the terms we use? i.e. Framework to Language, Tool to Language, Framework to Solution(like web services), etc.


Should I use title case in URLs?

We are currently deciding on a consistent naming convention across a site with multiple web applications. Historically, I've been an advocate of the 'lowercase all the letters!' when creating URLs:               http://example.com/mysystem/account/view/1551      However, within the last year or two, specifically since I began using ASP.NET MVC & had more dealings with REST based URLs, I've become a fan of capitalizing the first letter of each section/word within the URL as it makes it easier to read (imho).               http://example.com/MySystem/Account/View/1551      We're not in a situation where people _need_ to read or be able to understand the URLs, so that's not a driver per se. The main thing we are after is a consistent approach that is rational and makes sense. Are there any standards that declare it good to do one way or another, or issues that we may run into on (at least realistically modern) setups that would choose a preference over another? What is the general consensus for this debate currently?


What is a dedicated Linux box used for?

So this is probably a very basic and obvious question for most people, but my google-fu is failing me and it just seems something is going over my head. I've heard numerous people refer to having a 'dedicated linux box' as a central part of a developer's setup. I have been doing web-dev programming for about a year and understand the benefits of programming on a Unix/Linux system. But I seem to be missing what role a 'dedicated linux box' plays in the development process. I would assume that it is used as a server of some sort, but I am yet to run across any needs to have a computer dedicated to running a linux server. Am I just being nieve and mistaking the commonality of programmers preferring to work in linux for a tool used by developers? What do most developers use their 'dedicated linux box' for?


how to write a scalable/flexible php system?

I am trying to write a joomla type system in PHP to improve my coding/programming skills i need guidelines/rules of thumb to do that. what i basically want to do is create a index.php file which will act as a front controller and will redirect to the request transparently to "extensions/plugins" (no need for them to follow MVC and hence it will be more flexible) what are your recommendations on that? **EDIT** i meant i am trying to create it using CORE PHP (no frameworks), but existing libraries are acceptable


GUI, BLL, DAL Organization In A Project

I'm reading about application layers, and want to use this design in my next project (c#, .Net). Some questions:   1. Is the separation of layers done through namespaces? Project.BLL.Whatever, Project.DAL.Whatever   2. Is it more appropriate to separate by layers, then components (Project.BLL.Component1), or by components, then layers (Project.Component1.BLL)   3. For my DAL, is this layer further organized using different classes? If all database calls are put into a single class, there is no organization. Would it be better to split these up with different classes or namespaces?   4. Are DAL classes typically static? It seems cumbersome to instantiate a DAL object before calling one of its methods each time.  Any other tips for doing things the correct way with these layers would be appreciated.


Why do people say that VB gives you bad programming habits? What do they mean by this?


Are asserts or unit tests more important?

Both asserts and unit tests serve as documentation for a codebase, and a means of discovering bugs. The main differences are that asserts function as sanity checks and see real inputs, whereas unit tests run on specific simulated inputs and are tests against a single well-defined "right answer". What are the relative merits of using asserts vs. unit tests as the main means of verifying correctness? Which do you believe should be emphasized more heavily?


How to explain my 5 burnt-out years off to a new employer?

Five years ago, I lost my ability to concentrate long-term, and therefore ability to code with professional efficiency. I know why it happened, I understood how it happened, and on top of being able to re-create my calm and thus relaxed focus, I overcame the original (rooted in childhood) reason why my mind tilted on the overall situation back then; My understanding isn't rooted in words that a psychologist told me, I actually grokked them first-hand. I'm pretty much confident to be able to churn out productivity, possibly even more so than pre-burnout. I also never lost my interest in code nor did I stray from trying to get my abilities back; I kept my knowledge up to date (I could always relatively painlessly learn things coding-related, just not apply them) and thus can say that I'm a better developer than before, even if my average LOC-count over those years is abysmally low. On the other hand, now I have a biography that includes more time on the dole than in a job. What would convince you, as an employer, to give my application a chance? I don't believe I should just keep the whole topic out of it. **EDIT:** I think I should add that I didn't start searching my childhood for causes, it was the solution that pointed me to the cause. Alas, not doing my best to fix the company (which was disintegrating as I left, and completely disbanded a year later) is deeply rooted in the fact that in my childhood I, at one point, gave up on fixing my parent's relationship, misattributing it to my own failure at empathy instead of them being an utterly hopeless case, and I don't really see a way to explain that without referring to childhood. I'm perfectly able to say that without breaking out into tears, though. That said, yes, I'm aware that I'm writing to you guys as friends, not employers, right now, that's the reason why I show my distrust in you by using a one-time account .oO( ... ) Yes, I'm planning to release some OSS code before I apply anywhere. **EDIT 2:** I'm German and going to apply at a German company, so "creative truth" is definitely not an option. **As to the chosen answer:** I chose Renesis over Pierre because, while the latter did an awesome job at motivating, getting across that I shouldn't give up and giving me points to beef up my social skills section with, Renesis actually answered my question by summing up the involved key factors.


Is an atomic action supposed to be deterministic?

I was reading about the _at most once_ property that defines what an atomic action is and I've been curios about this example:               x = 0, y = 0     x = y + 1 || y = y + 1      If we use the 'at most once' definition, we can say that, indeed, `x = y + 1` is atomic because   * `y` is only referenced in an another thread and   * `x` is not being read by any thread But the result of this action is not deterministic, it could be 1 or 2 depending on which operation is being computed first. I might be wrong from the start, isn't atomicity suppose to grant some kind of determinism?


Making server logic independent of client interaction

I'm trying to make a realtime multiplayer web-game in node.js with express framework and socket.io library. But I can't seem to make my server-side logic independent of client interactions. I want client to interact only when I (server side logic) want but I can't seem to be able to do that. For example: I want 2 users to start playing a game. I have to first initialize the game, like set up environment, variables and stuff.. all in a separate, call it: The Game Logic. Only then can I "allow" the clients to interact. But how am I supposed to carry on with my Game logic when my `socket.on` event is "calling the shots"? With socket.io you have to define triggers like               io.sockets.on('connection', function(socket) {         socket.on('event', function(data) {             //supposed this is fired when client hits an "interact with X" button         });      }      All my logic seem to be dependent on these triggers. I only wanted client to be able to fire that event when _I want_ (after I've set up the game env etc), but defining it like so, separated from my game logic, it creates problems like **how am I supposed to transfer the execution control from socket into my game logic**? And even if I managed to, there's that whole client "calling the shots" problem. I then have no control when client could want to interact. Any advice what should I do?


Writing High Quality Software Proposals

I've been reading over some proposals for software projects recently and I'm a little concerned by what I've seen. Often I feel that proposals have been rushed and/or poorly thought out. It's very possible that proposals don't need to look like a basket of fruit, but if your pitching for work or seeking approval for funding, there has to be some guidelines available for what constitutes a "decent" proposal. I was wondering if anyone was aware of good guidelines for writing software proposals or could possibly point me at books/websites etc?


Bluetooth push application

I am considering the technical viability of software that I want to write. Is there a way that I can push data to a phone (iPhone or Andriod) via Bluetooth without pairing with it? I want to be able to walk into a room and have a computer push data to my phone when I get a certain distance from it, or push data to any phone automatically when it comes within a certain distance to a Bluetooth-ready device?


Developing a DVR software using a hardware KIT

I'm currently thinking about a project for my masters degree graduation. I start researching for options to make my own video streaming software based on a premade hardware kit having not much knowledge about what I'll exactly need that will match my needs. My search led me to the `DVR` `(Digital Video Recorder)` cards which seems to be the closest to what I need, but still I can't find out a few basic things so I decide to ask for them here. Currently I haven't find a lot of manufacturers that offers such kits so where I can look and have some options to choose from? There are a lot of `DVR` products on the market but they already have a software written for them and even if I buy one they just don't give any documentation or sdk's so buying such is not an option I need a DVR card made exactly for software programers and not end users. Are there a preferred manufacturers that provide such kind of devices with good and developer-friendly documentation? Also - I prefer to do all this with Java, is this an option (I think I will make it with .NET too but really prefer Java as a language of choice)


How can I design an anti-spam algorithm based on a web usage profile?

I've looked at other anti-spam algorithms, notably Reddit's, but they seem to be inadequate and naive: for example, only banning specific words (like "spam") that appear in the title of a post. How can one approach this problem? Are there any tools that would help in this case, and for high-activity online community websites in general?


Web-app DAO and server architecture design for service outside LAN

i just need a suggestion what path should i take to educate myself further. Situation:   We've got in our company internal (LAN only) application that, among other things, serves something like ordering app. Main functionality is - people can schedule some service(eg. technical consultation, fixing electronics etc.) for a particular date. Today outside customers have to personally come to the employee who will create their ticket. Boss said that we can no longer live in caves so we have to develop web app for scheduling orders.      Background:   \- our internal system is based on Java(swing) + DB(postgres)   \- DB server is on dedicated machine   \- data in DB is fragile (in sense of security)   \- because this is a little legacy code, most of logic is in stored procedures on DB   \- we would like to use Vaadin to develop web-app   \- host web-app on other machine         Main tasks:   \- separate internal server (DB) from outside world   \- serve only portions of data from DB required to create a ticket from web- app   \- find and secure or eliminate weakest link between internet web-app and internal DB system in chosen solution   \- web-app has to be synchronized with internal ordering app (no condition race for scheduling for particular date)         So how to make it right?:   \- host web-app on local machine (other than DB, and in DMZ) or use external commercial hosting   \- create Web-Service which will proxy web-app requests with customers orders to DB and then process them?   \- use maybe JMS for user requests and then poll from JMS to DB (using maybe Apache Camel to process and store to DB)?   \- create second database instance just for web-app, and then synchronize master-DB and web-app-DB in some sophisticated way?   \- in web-app data access layer we would like to develop high abstraction just in case we will have to switch from one of above to another         What are your suggestion, which of these, or maybe something completely different should we consider in this project?


Why does storm not supply a mechanism for supplying topology necessary dependent jars other than the fat jar?

Following is a question that I had posted at the incubator-storm-user mailing list (verbatim). I had decided to open up the question here as well, because it also contains a conceptual side to it, which might be answered by non-storm users. > I am no python expert and am also a newbie to storm. > > I have gone over the storm source code in order to see how to add jars to > the classpath. Obviously, the preferred mechanism is the fat jar (as > specified in Micheal Noll's tutorial and another post on the storm-user > mailing list). The second seemingly available mechanism is via the > `USER_CONF_DIR` which amounts to `os.path.expanduser("~/.storm")` but this > does not allow for topology independent versioning of the same jars (e.g. > `apache-commons-aaa` version x and version y). There does not seem to be a > third way. Many other Java based technologies do give a way to amend the > classpath. Why doesn't storm? To generify the question a bit, why would a (clustered) java software framework/container not supply a mechanism for adding app specific dependent jars, but force you to use fat jars?


How do you manage feature requests and software changes?

I am a Software Engineer and over the past few years I have become the de- facto software project manager simply because there isn't one. So to keep our sanity in the R&D/Engineering department, customers have become accustomed to coming to me with their requests. I have no experience in this realm so it is my first time acting as a project manager for software projects. I have managed other things but not software. So, how do you manage software projects and mark priorities? Requests come in at infrequent intervals so we very well could be working on something for someone else and then another person comes in with a "rush" job that needs working on. Is it easier to just say First Come, First Serve or is it the person with the most money?


How does one handle an incorrect resource file?

I'm starting the parser that will handle one of the key features of my app and realizing exactly who easy it would be for me to screw up a resource file that is provided to the application. For example, a simple resource that I provide to my app is a JSON file that contains an entity layout (name, fascia, location etc...). It would be easy for me to leave out the name of the entity or misspell the JSON key. Obviously catastrophic failures during parsing are to be handled in a try/catch, but how would subtle failures (such as a dyslexic spelling of name) be handled?


TDD for batch processing: How to do it?

I like "red/green/refactor" for RoR, etc. just fine. My day job involves batch processing very large files from third-parties in python and other custom tools. Churn on the attributes of these files is high, so there are a lot of fixes/enhancements applied pretty frequently. Regression testing via a known body of test data with expected results does not exist. Closest thing is running against the last batch with new test cases hand coded in, make sure it does not blow up, then apply spot-checking and statistical tests to see if data still looks OK. Q>> How to bring TDD principles into this kind of environment?


Is ASP.NET MVC too much overhead for smaller projects?

I will be honest I don't really know much about MVC other than the stuff you can read online in 5 minutes. Unfortunately this doesn't really tell me whether its suited to smaller projects or not. I also read this related question and its chosen answer, but the business perspective is not a concern in this case for me as I am the only one making it. The next answer proceeds to say why it is more flexible. Sure, that's great. But my question is again, if its an ideal choice for a small project. For example I would rather use winforms to make a simple mockup of a small desktop program than do it on WPF because of the overhead of custom styling. So I have a project that will essentially have about 6-8 pages that read excel files and user input use that to pull a bit of data from databases and output resulting excel files. I will be the only one working on this project. If I used webforms I would expect it to take no more than 2-3 weeks. Now I am 100% comfortable with webforms. And I know its easy to do a small project in webforms. But I have only heard good things about MVC so I am seriously considering it.


Web development advice for a distributed development team

I am a web developer. Worked in many projects. Now I have changed my work place. It is big organisation. I and my group are thinking about new project. There is no difficulty to write project but our organisation is big and it's has little offices in many places (within the country). There is no any problem about internet in center. But there is problem with internet in remote areas sometimes. My question is: is there any solution to solve problem as it? If anybody has create project such this please tell little about what technologies you have used. Thanks


Divisional/Sectional comments, good or bad?

I know the general trend against comments explaining how something works, and how it's a good idea to use them only to explain why you're doing what you're doing, but what about using comments as a means of dividing up the code? Assume you have a script that does a preamble, searches through a bunch of records, prints the records, then closes everything:               // Preamble     ... preamble code, say about 10-15 lines ...          // Find records     ... sql query ...     ... put records into array ...     ... some other stuff ...          // Print records     ... printing records, 20-30 lines a record ...          // Close everything     ...      More of a way to visually divide the code, make it easier to find a certain section. Like if in a month you need to fix the printing code, rather than reading through a couple hundred lines to try and find the right spot, just look at the comments to see where it is. What actually happens in each section being fairly straightforward and easy to tell what's going on, **would this approach to comments be considered good or bad**? **Edit:** I'm working mostly with PHP scripts, where you either can't put code into functions, or it's impractical to do so. However, the same sort of thing would apply to large class files, with several methods that do related things, like getters/setters, database updates, etc.


Testing BI (Business Intelligence) systems on the MS stack

I'm placing my first steps in the Business Intelligence sector and **I'm looking for good ways to test BI systems.** I'm going to try to explain what my system consists of so that people unfamiliar with BI systems could also pitch in some advice. **For those of you who are rather unfamiliar with BI systems, here's how a BI system typically looks like on the MS stack:**   1. Data is in MS SQL DBs, text files, XML files, etc    2. The data is put into a single MS SQL DB ( **the data warehouse** ) using (an) **Sql Server Integration Services (SSIS)** package(s). (ETL, Extract - Transform - Load)    3. A 'Cube' containing Measurements, KPIs etc is processed on the data warehouse, using **Sql Server Analysis Services (SSAS)**   4. Reporting can be built on the cube using excel, Reporting services, etc. **There are multiple things you can/should test:**   * Is the data put into the data warehouse correctly   * Are the measurements and calculations done correctly I think a test environment could be made in .NET using empty databases with the same structure as the production databases and data warehouse. **Tests could be written like this:**   1. Insert dummy data in the production databases of which you know that they should produce certain measurements, KPI values. For example: Insert a car with cost 100 and profit 110 sold in 2008. another car with cost 100 and profit 120 sold in 2009. markup in 2008 should be 10% and in 2009 20%.   2. Run the SSIS package(s). I looked this up and its possible in .net   3. Run the SSAS calculations. Still have to look up how to do it, but should be possible.   4. Retrieve the KPI data from the Analysis Services database and test if it matches the expected results. **Some downsides I expect to this approach:**   1. Setting up test databases, security for the test script, ... will take quite some time.   2. Changes to production databases and the data warehouse will have to be copied to the test environment.   3. Creating the insert statements for the test data could be difficult. In my car example it is simple but for more complex calculations this could be quite time consuming   4. Tests will most likely run quite slow   5. The tests are error prone, either in the INSERT statements or in the part where you retrieve the KPI data. Figuring out what went wrong could be difficult. So summarized, writing **and** maintaining these tests could be quite consuming. On the other hand, you would have a nice **test-driven approach** where you write the test first, plus your business logic is explained and documented in the tests. Since I have not much practical experience with BI development I'm unsure if this is the way to go and what alternatives there are. Perhaps someone more experienced could explain how BI systems are usually tested and documented?


Check-list to avoid vendor lock-in?

Is there a set of industry approved rules to avoid vendor lock-in? I mean something one can show to a manager or other decision maker that is easy to understand and easily verifiable.   * Are there any universally accepted set of rules, checklist or conditions that help detect and prevent vendor lock-in in an objective, measurable way?   * Have any of you warned a manager about the risk of vendor lock-in during the initial stages of a project?


Why does Cem Kaner consider a test not revealing a bug a waste of time?

What about confirming the functionality in positive tests, proving it is working - should I say it is a waste of time? What kind of concept is behind this quote? > Unsuccessful tests, i.e. tests that do not find errors are a waste of time. Web Engineering: The Discipline of Systematic Development of Web Applications quoting Cem Kaner.


How do people make money by writing programming languages?

Why will anyone even attempt to write a programming language? It seems to be a tedious task and the alternative (simply using an existing language) seems to make much more economical sense. Microsoft may hire people to write .NET because they have too much spare money to burn. But why will anyone else write a language if they aren't paid for it?


How to delete .tmp file in fileupload struts2

I have used `file-upload` (common fileuplod) in `strtus-2.3.15.3` . There is one Form in my `.jsp` with multiple field with many diff type(textfield,textarea,hidden,file) including `FILE` and obvious `SUBMIT`. When i submit form by selecting one file and enter some text in all other field its generated `.tmp` file in mention temp folder . Only `.tmp` file related to file field is going to delete after uploading my file to myfolder but rest of `.tmp`(with 1kb size) file is remaing as its .               List items = upload.parseRequest(servletRequest);       This line in below code generate `.tmp` file for all field which have some value (if you do not enter any text in text field it not generated) . `MonitoredMultiPartRequest.java` **:**               public void parse(HttpServletRequest servletRequest, String saveDir)                 throws IOException         {                  System.setProperty("java.io.tmpdir", "D:\\ankit");                  UploadListener listener = new UploadListener(servletRequest);             // Create a factory for disk-based file items             FileItemFactory factory = new MonitoredDiskFileItemFactory(listener);             // Create a new file upload handler             ServletFileUpload upload = new ServletFileUpload(factory);              }      `MonitoredDiskFileItemFactory` :               public class MonitoredDiskFileItemFactory extends DiskFileItemFactory     {         HttpServletRequest request;              public MonitoredDiskFileItemFactory(OutputStreamListener listener, HttpServletRequest request)         {             this.listener = null;             this.listener = listener;             this.request = request;             setTrackers();         }              public void setTrackers()         {             FileCleaningTracker fileCleaningTracker = FileCleanerCleanup.getFileCleaningTracker(request.getServletContext());             File repository = new File(System.getProperty("java.io.tmpdir"));             DiskFileItemFactory factory = new DiskFileItemFactory(DiskFileItemFactory.DEFAULT_SIZE_THRESHOLD, repository);             factory.setFileCleaningTracker(fileCleaningTracker);             super.setFileCleaningTracker(fileCleaningTracker);             super.setRepository(repository);         }              public MonitoredDiskFileItemFactory(int sizeThreshold, File repository, OutputStreamListener listener)         {             super(sizeThreshold, repository);             this.listener = null;             this.listener = listener;         }              public FileItem createItem(String fieldName, String contentType, boolean isFormField, String fileName)         {             MonitoredDiskFileItem result = new MonitoredDiskFileItem(fieldName, contentType, isFormField, fileName, getSizeThreshold(), getRepository(), listener);             FileCleaningTracker tracker = getFileCleaningTracker();             if (tracker != null)             {                 tracker.track(result.getTempFileOfDistFileItem(), result);             }                  return result;         }              private OutputStreamListener listener;     }      `MonitoredDiskFileItem` :               public class MonitoredDiskFileItem extends DiskFileItem     {              public MonitoredDiskFileItem(String fieldName, String contentType, boolean isFormField, String fileName, int sizeThreshold, File repository, OutputStreamListener listener)         {             super(fieldName, contentType, isFormField, fileName, sizeThreshold, repository);             mos = null;             this.listener = listener;         }              public OutputStream getOutputStream()                 throws IOException         {             if (mos == null)                 mos = new MonitoredOutputStream(super.getOutputStream(), listener);             return mos;         }              public File getTempFileOfDistFileItem()         {             return super.getTempFile();         }              private MonitoredOutputStream mos;         private OutputStreamListener listener;     }      `UploadListener` :               public class UploadListener implements OutputStreamListener, Serializable     {         private static final long serialVersionUID = 1L;         private int totalToRead = 0;         private int totalBytesRead = 0;         private int percentDone = 0;         private int previou_percentDone = 0;         private long uploadspeed = 0;         private long starttime;         private long stTime, EndTime;         HttpSession session;         private int count = 0;              public UploadListener(HttpServletRequest request)         {             totalToRead = request.getContentLength();             session = request.getSession();         }              public void start()         {             session.setAttribute("percentageDone", 0);             session.setAttribute("speed", 0);             starttime = System.currentTimeMillis();             stTime = starttime;              }              public String getMessage()         {             return "" + totalBytesRead + " bytes have been read (" + percentDone + "% done)  ";         }              public void bytesRead(int bytesRead)         {             totalBytesRead = totalBytesRead + bytesRead;                  if (100.00 * totalBytesRead > totalToRead)             {                 previou_percentDone = percentDone;                 percentDone = (int) Math.round(100.00 * totalBytesRead / totalToRead);                 if (previou_percentDone < percentDone)                 {                     long speed = 0;                     try                     {                         double TimediffInSecond = (System.currentTimeMillis() - starttime) / 1000;                         if (TimediffInSecond > 0)                             speed = Math.round(((totalBytesRead) / TimediffInSecond) / 1048576);                         else                             speed = totalBytesRead / 1048576;                          }                     catch (Exception e)                     {                         System.err.println(e.getMessage());                     }                 }             }                   }              public void done()         {             EndTime = System.currentTimeMillis();             session.setAttribute("percentageDone", 100);             session.setAttribute("speed", 100);         }              @Override         public void error(String message)         {             // System.out.println(message);         }              public long getUploadspeed()         {             return uploadspeed;         }              public void setUploadspeed(long uploadspeed)         {             this.uploadspeed = uploadspeed;         }          }      `EDIT` **:** 1> Why this `.tmp` file is generated for fields (textarea ,hidden,textfield) . How can we prevent this ? 2> i want to stop generating `.tmp` file for all field except where `type='file'`(file field) . 3> Otherwise, how can i delete this all `.tmp` file ?


Proper response for a REST insert - full new record, or just the record id value?

I'm building a REST API which allows inserts (POST, not idempotent) and updates (PUT, idempotent) requests to add/update database to our application. I'm wondering if there are any standards or best practices regarding what data we send back to the client in the response for a POST (insert) operation. We need to send back at least a record ID value (e.g. your new record is record #1234). Should we respond with the full object? (e.g. essentially the same response they'd get back from a "GET /object_type/1234" request) Should we respond with only the new ID value? (e.g. "{ id: 1234 }", which means that if they want to fetch the whole record they need to do an additional HTTP GET request to grab the full record) A redirect header pointing them to the URL for the full object? Something else entirely?


What's the meaning of "the Sun defect" and how does it differ from the more generic "NIH syndrome"?

I hear people talking about the "Sun defect", often giving the whole mess around logging as an example. How is it different from the not-invented-here syndrome, which means uselessly duplicating existing work?


Is Python suitable for a statistical modeling application looking over thousands of past events?

I'm currently working on a project with a partner where we analyze large datasets of past sporting events. There are approximately 30,000 events per year and we have historical data for five years. Thus, we're looking at analyzing 150,000 events. I wrote our first version in Python with a heavy reliance on Pandas (great tool, by the way). However, each time I add a "factor" or calculation to the process it slows down by quite a bit. Simply put, it can read all the various data files and data queries we need at a rate of 25-events-per-second. The problem is once I start working with the data, it drops fast. If I add a simple calculation, it drops to 24... and each calculation after that it drops again. With just 10-12 "factors" calculated from the data (we're not talking complex loops or anything crazy), it's now down to 6-events-per-second. ... and we're barely scratching the surface. At this rate, it'll take this thing days to work through all 150k events! I've optimized our data queries, flat file reads etc. Those really aren't the issue. I can live with doing 15-20 events per second. However, I can't live with such drastic slowdowns each time a new factor calculation is added. I've read a lot where Python as an interpreted language is slow etc., but my question to the experts out there - what language should this project be done in? **EXAMPLE...** One of the key "DataFrames" I am using through Pandas is fairly large. 350 rows x 70 columns, as an example. Even when trying to simply multiply one column's value by another...                data['value'] = data['col1'] * data['col2']      ...I see what I could consider significant drop in performance. It's very puzzling, and very frustrating. I understand this is a large set of data, but I can't believe this is anything so crazy that Python would be slowing to a crawl. If I just read the data files and do no calculations on them at all, it reads 67 events in 2.807 seconds. If I add one simple calculation where I execute code like the example above, it slows to 2.877 seconds. Based on our research, we're needed to add upwards of 100 calculations on the data.... so 7 seconds worth of slowdown? Seems too hard to believe.


I am developing an app for iPhone - does it matter which iPhone I buy?

It's a basic application - nothing majorly fancy (i.e. not a game) I have the option to buy iPhone 5 iPhone 5c iPhone 5s Just wondering if it matters which iPhone I buy to test out my App or should I just go for the most common? I guess the real question is do people see any bugs based on the phone type (less so the OS type).


Is IoC feasible in winforms?

I'm coming back into the winform world after being in the web world for a while. Is it common or otherwise feasible for developers to use IoC in winform? My concern is mainly with performance. I envision that I will need to "bootstrap" or initialize all my inverted items that are required by a given form instance on form initialization. If this initialization becomes expensive, I can push the task off to a thread, but that requires that I get the created objects back to the main thread where they will be used at some point.


How to fit requirements into MVC

Let's say we have a website requirement to allow User functionality. Simple! We create the UserModel, UserController and UserView. Works perfectly. However, let's assume that User has a `many-to-one` relational table connected to it titled `Child` which also has its own MVC components: ChildModel, ChildController, ChildView. Now if we had a requirement to create a CSV file for download containing a few details from the `User` and a few details from its `Child`, how would we go about designing this requirement? "DownloadCSV" could essentially have its own CRUD methods, it's own Controller, it's own View but its Model is based on the details from other tables, so should it have its own Controller, View, Model(/DB View) or should it just be another method besides CRUD in `User` or `Child` controller?


What are the benefits of using database abstraction by ORM?

I'm starting to use the ORM recommended by the framework I choose, and though I like the idea of the added layer of abstraction the ORM provides, I'm starting to realize what this really means. It means I'm no longer working with my database (mysql) and any mysql-specific features are gone, out the window, like they don't exist. The idea the ORM has is that it's trying to help me by making everything database agnostic. This sounds great, but often there is a reason why I choose a specific database system. But by going the database agnostic route, the ORM takes the lowest common denominator, which means I end up with the smallest set of features (the ones supported by all databases). What if I know that for the long term I won't be switching the underlying database? Why not access the database-specific features, too?


The design of a generic data synchronizer, or, an [object] that does [actions] with the aid of [helpers]

I'd like to create a generic data-source "synchronizer," where data-source "types" may include MySQL databases, Google Spreadsheets documents, CSV files, among others. I've been trying to figure out how to structure this in terms of classes and interfaces, keeping in mind (what I've read about) composition vs. inheritance and is-a vs. has-a, but each route I go down seems to violate some principle. _For simplicity, assume that all data-sources have a header-row-plus-data-rows format. For example, assume that the first rows of Google Spreadsheets documents and CSV files will have column headers, a.k.a. "fields" (to parallel database fields)._ _Also, eventually, I would like to implement this in PHP, but avoiding language-specific discussion would probably be more productive._ Here's an overview of what I've tried. * * * # Part 1/4: ISyncable               class CMySQL implements ISyncable         GetFields()     // sql query, pdo statement, whatever         AddFields()         RemFields()         ...         _dbh                    class CGoogleSpreadsheets implements ISyncable         GetFields()     // zend gdata api         AddFields()         RemFields()         ...         _spreadsheetKey         _worksheetId                    class CCsvFile implements ISyncable         GetFields()     // read from buffer         AddFields()         RemFields()         ...         _buffer                    interface ISyncable         GetFields()         AddFields($field1, $field2, ...)         RemFields($field1, $field2, ...)         ...         CanAddFields()  // maybe the spreadsheet is locked for write, or         CanRemFields()  // maybe no permission to alter a database table         ...         AddRow()         ModRow()         RemRow()         ...         Open()         Close()         ...      **First Question:** Does it make sense to use an interface, as above? * * * # Part 2/4: CSyncer Next, the _thing that does the syncing_.               class CSyncer         __construct(ISyncable $A, ISyncable $B)         Push()          // sync A to B         Pull()          // sync B to A         Sync()          // Push() and Pull() only differ in direction; factor.                         // Sync()'s job is to make sure that the fields on each side                         // match, to add fields where appropriate and possible, to                         // account for different column-orderings, etc., and of                         // course, to add and remove rows as necessary to sync.         ...         _A         _B      **Second Question:** Does it make sense to define such a class, or am I treading dangerously close to the "Kingdom of Nouns"? * * * # Part 3/4: CTranslator? ITranslator? Now, here's where I actually get lost, assuming the above is passable. Sometimes, two `ISyncable`s speak different "dialects." For example, believe it or not, Google Spreadsheets (accessed through the Google Data API "list feed") returns column headers _lower-cased and stripped of all spaces and symbols_! That is, `sys_TIMESTAMP` is `systimestamp`, as far as my code can tell. (Yes, I am aware that the "cell feed" does not strip the name so; however cell-by-cell manipulation is too slow for what I'm doing.) One can imagine other hypothetical examples. Perhaps even the data itself can be in different "dialects." But let's take it as given for now, and not argue this if possible. **Third Question:** How would _you_ implement "translation"? Note: Taking all this as an exercise, I'm more interested in the "idealized" design, rather than the practical one. (God knows _that_ shipped sailed when I began this project.) * * * # Part 4/4: Further Thought Here's my train of thought to demonstrate I've thunk, albeit unfruitfully:   1. First, I thought, primitively, "I'll just modify `CMySQL::GetFields()` to lower-case and strip field names so they're compatible with Google Spreadsheets." But of course, then my class should really be called, `CMySQLForGoogleSpreadsheets`, and that can't be right.   2. So, the _thing which translates_ must exist outside of an `ISyncable` implementor.   3. And surely it can't be right to make each translation a method in `CSyncer`.   4. If it exists outside of both `ISyncable` and `CSyncer`, then what is it? (Is it even an _"it"_?)   5. Is it an abstract class, i.e. `abstract CTranslator`?   6. Is it an interface, since a translator only _does_ , not _has_ , i.e. `interface ITranslator`?   7. Does it even require instantiation? e.g. If it's an `ITranslator`, then should its translation methods be `static`? (I learned what "late static binding" meant, today.) And, dear God, whatever it is, how should a `CSyncer` _use_ it? Does it "have" it? Is _it_ , _"it"_? Who am I? ...am I, "I"? * * * I've attempted to break up the question into sub-questions, but essentially my question is singular: **How does one implement an object`A` that conceptually "links" ( _has_ ) two objects `b1` and `b2` that share a common interface `B`, but where certain pairs of `b1` and `b2` require a helper, e.g. a translator, to be handled by `A`?** Something tells me that I've overcomplicated this design, or violated a principle much higher up. Thank you all very much for your time and any advice you can provide.


Should you write down a list of issues, or fix issues as they arise?

I have observed a strange trend in the company I work at. There are people who insist that there should be a list of tasks. They estimate those tasks, implement them, and try to meet their commitments. However, while they are coding, the requirements are likely to change. The priorities shift, the tasks increase or decrease, and the scope may just down right change, causing the whole work to get discarded. And then, there is another team, who meet issues and fix them as they arise. There are no estimates, there are no priorities, there are no set deadlines, and mission statements for sprints go something like, “Fix the bugs in the [insert subsystem name here]”. Now, which is the right way to go about being agile when you have technical sprints that focus only on stabilizing the system? Should you try and gather a list of issues, only to have them change, or should you try and fix-as-you-go, without saying when you’ll be done?


A* search for Sudoku

I have a homework problem for an Artificial Intelligence course that I am having trouble answering. > Consider solving the Sudoku problem using A* search. The start state has > some number of cells filled in, and the successors of each state are all > legal ways an additional cell can be filled in. At any time we know exactly > the number of cells that remain to filled. > > Therefore, if K cells remain to be filled at node n, we know that h(n) = K. > Thus if we set our heuristic function h(n) to be h(n)=K, we will have > perfect heuristic knowledge in A. > > Explain the mistake in the above statement. I understand that this heuristic is entirely pointless since if there was some function that could find legal successors you might as well run a depth first search but what exactly is wrong with the above statement.


Pre-screening coding test - How long is reasonable?

**EDIT** After a good amount of thinking and self-reflection on the topic, I realised that most of the issues I raised in this question was coming only from a personal, rather than a professional perspective. Hence the moderators put this question on hold because of the highly personal, subjective nature of the problem I tried to talk about. I was thinking about rephrasing the question but I could not really find a possible way to manifest the question in more objective way so it can be the subject of a discussion where answers can be back up with some sort of evidence or references. For the sake of those who are still interested, I am trying to give a summary of the discussion emerged from this question:   * a 4 hours pre-interview, offsite programming test is not usual but   * many people pointed it out that for some companies you would interview for much-much longer than that all together   * it is our personal decision if we take a test or not, and we can evaluate this based on our circumstances and the perceived benefits of getting hired for the company   * all companies are different, as people are, and it can be perfectly reasonable for a company to employ a longer pre-interview offsite test, if that is what fits their needs or circumstances I wanted my original question to be about how _reasonable_ to expect 4 hours from me, and how _ethical_ to give out a problem so the solution (not the code, but the design) can be possibly used for the company. As I can now see both of these questions can only (at best) be explored in a forum discussion, rather than using a question-answer type community tool like stackexchange. However, I found all your answers valuable and thanks for sharing. **ORIGINAL POST** I am interviewing for several positions, and most of them include a pre- screening phase where I have to submit a coding test before the telephone interview or the onsite interview would take place. I have pretty much got used to this idea, and find it quite reasonable that companies expect me to do this so they can check what type of work I can produce on my own. Generally, my experience is that these type of coding exercises are mostly small programming tasks. Do some logic, maybe implement a small algorithm, open a file and read/write data, stuff like that. Even the most simple task can be implemented with nice separation of logic, testable components, etc, to see how the candidate is coding, generally how well he is prepared for the type of job a company want to fill in. Recently I came across a company who sent me a coding test with a whole page long description of their exercise, asking me to solve a real life problem of their business (I don't want to say specifics to protect the company, but the test was pretty much about what they do). They described a pretty complex system to implement, included real data, and in the end they concluded that the coding test should not take more than **4 hours**. Is it reasonable from a company to expect me to spend 4 hours working on their dummy assignment in my free time, even before they would say hi to me? (the recruiter sent me the coding test) Don't get me wrong, I am motivated to find a new job and new challenges, but most companies expect me to spend maximum 1-2 hours on a task like that, and such tasks has always been far less complicated. What I came up as a conclusion with this company is that either: 1) My motivation is not good and probably they are looking for someone else 2) They do not respect their future employees to expect such a long coding tests to do even without saying hi to them 3) They just want to give out one of the problems they work on and see if there is an enthusiastic young fella who would solve it for them for free (again, don't get me wrong I am not a conspiracy theorist but I have heard such stories ...) How much do you think is reasonable for a company to expect candidates spend time on their dummy coding tests without talking to them? What is your experience generally?


What is the relationship between data structures and algorithms?

I have been searching for a good online course in data structures but have found that Google also returns results for algorithms courses, which say stuff like: > In this course you will learn several fundamental principles of algorithm > design: divide-and-conquer methods, graph algorithms, **practical data > structures (heaps, hash tables, search trees)** , randomized algorithms, and > more. [source] and > By the end of this class you will understand key concepts needed to devise > new algorithms for graphs **and other important data structures** and to > evaluate the efficiency of these algorithms. [source] and > This course provides an introduction to mathematical modeling of > computational problems. It covers the common algorithms, algorithmic > paradigms, **and data structures used to solve these problems**. [source] My question is: are algorithms and data structures intimately linked, meaning that they must be understood together or is one topic more foundational than the other? _EDIT: For those voting to close this question, can you please tell me why and maybe how to improve this one? Learning to ask the right questions is part of the educational process._


Release management with Azure and Visual Studio Online (Cloud TFS)

What strategy would you use to manage the releasing of versioned software to Azure cloud services (web and worker roles)? We are not looking for continuous integration. We are using Visual Studio 2013 and Visual Studio Online (Cloud TFS). At one point, we were releasing straight from Visual Studio using the Azure Cloud Project Publish tool. This is really bad practice in my opinion as you can never be sure what you are really releasing. Additionally, there is no automated control on the labeling or branching of code, or the running of unit tests and code analysis checks. Next, we employed Release builds on Visual Studio Online. Before deployment, one would edit the appropriate Build Definition (whether it be for Test or Production by and filling in the code label (under the "Get Version" build property) that is to be released. This would then get the appropriate code (by the label specified), build it, and release it to whatever cloud service is specified in the targeted Cloud Project profile (this is using the AzureContinuousDeployment.11.xaml template). There is still a degree of manual intervention involved. Also, the fact that a version of code is built every time before it is released is not ideal (as far as I understand it would be better if it was packaged once). Microsoft Release Management tools look ideal for the job, but are not supported with Visual Studio Online. Is there a better way of handling our releases?


The Written Roles of Chief Technology Officer

A follow up to this question: The Written Roles of Software Development Manager What is the role and what are the responsibilities of a CTO when it's done well, with particular reference to how it might pertain to a programmer with aspirations towards this sort of position? (Reason for asking - it's one potential career destination for programmers looking to move away from a purely hands-on role and for those with this sort of ambition it's worth knowing what it actually entails).


Converting event-based asynchrony to C#5 async

We currently have an interface for an asynchronous video decoder that runs on its own thread. Basically you feed it some data and it'll eventually call you back on its thread through some events, like so (not real code):               interface IDecoder {         void Decode(parameters);         event FrameReady;         event FrameDropped;         // lots of other possibilities     }      It's a bit messy and I'd like to convert it to a C#5, async-based version, something like:               interface IDecoder {         async Task<DecodeResult> DecodeAsync(parameters);     }      Where DecodeResult will have all the information that would have otherwise been transmitted via events, and the client code can be written cleanly with async/await rather than a mess of event handlers and thread dispatching. It is my understanding that Tasks are scheduled on the ThreadPool by default. We want all Decode operations to happen sequentially on a single, decoder- specific thread. Can this be achieved using Tasks, if so, how? Are Tasks even appropriate for this use or is there a more obvious pattern I'm missing?


Using dot to Access Object Attribute and Proper abstraction

I have been programming in python and Java for quite a number of years and one thing I find myself doing is using the setters and getters from Java in Python but a number of blogs seem to think using the dot notation for access is the pythonic way. What I would like to know is if using dot to access methods does not violate abstraction principle? If for example I implement an attribute as a single object and use dot notation to access, if I wanted to change the code later so that the attribute is represented by a list of objects, that would require quite some heavy lifting which violates abstraction principle.


Designing exceptions for conversion failures

Suppose there are some methods to convert from "X" to "Y" and vice versa; the conversion may fail in some cases, and exceptions are used to signal conversion errors in those cases. Which would be the best option for defining exception classes in this context?   1. A single `XYConversionException` class, with an _attribute_ (e.g. an `enum`) specifying the _direction of the conversion_ (e.g. `ConversionFromXToY`, `ConversionFromYToX`).   2. A `XYConversionException` class, with two _derived classes_ `ConversionFromXToYException` and `ConversionFromYToXException`.   3. `ConversionFromXToYException` and `ConversionFromYToXException` classes _without_ a _common_ base class.


Are C static libraries frowned upon?

There are 2 arguments for having shared libraries:   1. It helps reduce disk space.   2. When a shared library is updated, all the binaries depending on it get the update. There is mainly one drawback for shared libraries:   * They (can) introduce dependency hell. * * * On desktop computers, the 1st advantage doesn't really hold anymore. Wasting disk space isn't much of an issue these days. Having static binaries would allow us to get way better package managers -- I mean, the dependency hell would be a thing of the past. Adding a program would be just adding a binary; eventually a folder to let it handle its files. Deleting a program would be simply deleting this file. Dependencies? Gone. The 2nd advantage still stands, but I think the advantage of static binaries on desktop computers outweighs it. I mean, even new languages like Go compile all their binaries in spite of the shared libraries advantages, because of the convenience. * * * Since one of the main advantages of shared libraries is not a big deal anymore, are C static libraries are still frowned upon? If so, why?


Ruby on Rails Development Process

We are a small team that is about to start developing a localized version of a successful US web app in Korea, using RoR. Our question is: What process would you recommend we use to go about developing the app? Should we start with the data models? The views in HTML and then code them? Take a single feature, develop it and then add additional features as necessary? A few more details about the project:   1. it is a web app for small business owners   2. it includes the usual crm-reporting-dashboard-user admin-document mgmtfeatures that most small biz apps tend to have   3. team size is initially 2 people: a programmer and a designer/CSS guru (just one coder)   4. experience level is medium. good knowledge of Git, Ruby, Rails and XHTML/CSS, less experienced with deployment issues. this is the first project of its kind that we are doing together as a team


"Don't do programming after a few years of starting career". Is this a fair advice?

I am a little experienced developer having approximately 5 years experience in PHP and somewhat less in Java, C# and trying to learn some Python nowadays. Since the start of my career as a programmer I have been told every now and then by fellow programmers that programming is suitable for a few early years of a career (most of them take it as 5 years) and that one must change the direction after it. The reason they present include headaches and pressures associated with programming. They also say that programmers are less social and don't usually like to give time to their families, etc. and especially "Oh come on, you can not do programming your entire life!" I am somewhat confused here and need to ask others about it. If I leave programming then what do I do?! I guess teaching may be a good option in this case, but it will require to first earn a PhD degree perhaps. It may also be noteworthy that in my country (Pakistan) the life of a programmer is not very good in that normally they must give 2-3 extra hours in the office to accomplish urgent programming tasks. I have a sense that situation is somewhat similar in other countries and regions as well. Do you think it is fair advice to change career from programming to something else after spending 5 years in this field? UPDATE * * * Oh wow... I never knew people can have 40+ years of experience in this field. I am both excited and amazed seeing that people are doing it since 1971... That means 15 years before my birth! It is nice to be able to talk to such experienced people, we don't get such a chance here in Pakistan. * * * Thanks again for all the help and sharing. It has been a nice experience getting your thoughts on this.


Javascript simple code to understand prototype-based OOP basics

I know Javascript for some time, although I am not a heavy user, I know it the first from the time when Netscape was my browser. I pretty much understand the main things, but since JavaScript approach to OOP is prototypical I have some problem grasping it. One problem to add to this it seems that things can be done in more than one way, and here is where books don't help much because they put all the examples on the table making it hard to keep the pace. What I need for start is only one way of doing it, if someone can help me with the simplest code possible an example where I can see how the prototypal OOP model works? To be helpful the code should have an inherited object, to access a parent's property and its inherited properties and a parent's function, to overwrite a parent's function and and have an instance of a multiple inheritance where an object inherits two other objects.


Best practices for cloning bugs

I'm trying to think of a nice and easy way to do this, but I thought I'd run it past some people for a second opinion: Say you've got 8 clients (one project for each customer) and each project derives from a core project. If a bug is raised that has to be fixed in core, our current approach is to create a bug and clone it for each customer (using Bugzilla). A lot of developers are finding it time consuming to manually clone the bugs across all clients and ensure that they are placed on each release tracker per customer. I suppose this is a workflow problem, so does anyone have suggestions on the best way to handle cloning bugs for multiple customers? Perhaps Bugzilla isn't the best tool for this. Most of us believe that it can not be fully automated and will require some manual intervention regardless of what tool we use. One idea I did have was to create a single bug issue. If it is a core bug and when assigning it for one release, we don't mark it as completely resolved as it has not been tested for all client projects that stem from the core project. The problem with this is that I would need a way to link the single bug to all customers and have it know when to automatically set it to resolved once the last customer has had a release. I don't believe Bugzilla has such a feature. Any thoughts or ideas would be welcome.


Is JavaScript "write once run everywhere"?

I have a business requirement for a javascript "write once run everywhere" App. I did research and discovered that there are a few options between: FireFox OS, ChromeOS, NodeOS, Tizen, and Dart. What I do not know - is if 1) this software is truly capable of allowing a single website to be written once and exported to Hosted or Packaged Native Apps. 2) Can a single JavaScript Website really traverse device-platform as a Native App via this breed of JavaScript Operating System or not? 3) Is it simple, or is it painful? Has anyone seen a full implementation first hand in at least a test environment or production? Also - are the upsides expected or unexpected - and what are the downsides? Overall: is JavaScript write once run everywhere - or not? To the point it isn't 'Native' - I found these. Apple iOS7 JS first-class citizenship. Last month. http://fluentconf.com/fluent2014/public/schedule/detail/32624 It is called JavaScriptCore framework. I installed a FireFox OS Open WebApp with emulator. https://developer.mozilla.org/en-US/Apps/Quickstart/Build/Your_first_app I don't know what these are, but it was easy and it looks cool. Like a website packaged into a Native App. Has any one reviewed this class of JavaScript Architecture?


N-Tier MVC4 Web Application with console application

I've built an MVC web application and I need to run several tasks at different time intervals. So I've also made a console application to schedule these tasks through task manager in windows. For example, the application needs to send out an email every week summarizing the program's data. I've chosen to use the Nuget RazorEngine package to format the emails because I already have to show the same data on a webpage too, so by using the RazorEngine package, I can re-use my viewmodel for both the email and the UI of the web project (just use it in a template formatted for email instead of web). But therein lies the problem, the ViewModel is in the UI project. I don't think the right thing to do here is for my console application to take a dependency on my UI layer. The logical decision to me at first was "just make another layer, App.ViewModelBuilders (maybe also help me with a better name?), and take a dependency in both App.UI and App.ConTasks" But I've never seen that done before, so I'm not sure if that is a wise choice or not... Here's my current layers (projects) for the solution:   * App.DAL (No Dependencies - Unit of Work and Repository pattern)   * App.Service (Depends on DAL - uses DAL for business operations, such as getDataWithCondition() which returns the relevant objects (it's actually an IQueryable)   * App.UI (Depends on Service - gets the data back from service and runs it thru a ViewModelBuilder to map the business objects to the appropriate view model, and then renders a view using that view model)   * App.ConTasks (SHOULD depend only on service, but still needs ViewModels - uses data returned from service to render view formatted for email and send the email) What Layer should my View Models and View Model Builders go in?


How do I architect zip code & distance calculation functionality?

I am building an app using MVC 4/Razor and EF 4/ .NET 4 in which it is possible to search items by zip code and thus retrieving items only a certain distance from your current zip code. I have a class that calculates distance using census gazetteer files (zip, lat, and lon) and the Haversine formula. My specific problem deals with the SQL portion of my code. I have a view that uses a pager (20 results per page) and has hyper links that order the columns in asc and desc order. I also have 3 drop down lists that can further filter the results down: Manufacturer, Category, Distance. When I am filtering by say 50 miles my class retrieves an IEnumerable of zipcodes that are within the requested distance. At times this can be in the 10,000 - 30,000 area. Each `Item` object contains an `int ZipCode` ![Relationships](http://i.stack.imgur.com/OQRfd.jpg) The problem EF generates when I try to grab item objects from the database using a list of acceptable zip codes is _One of your queries is too deeply nested. Try breaking them up_. I am assuming that it is because you can not have a where clause with thousands of conditions. This makes sense. I had found a link a few days ago that basically dealt with creating a temporary table to use as the list in the where condition but can not find the link anymore. It also applied to raw ADO.NET as opposed to EF. **My question is basically, how can I implement the functionality that I want without having make huge changes?**                using (var context = new JDMExchangeEntities())             {                      var results = context.Items.Include(P => P.Manufacturer).Include(P => P.Category)                     .Include(P => P.VehicleMake).Include(P => P.VehicleModel).Include(P => P.VehicleYear);                               //Category logic                 if (!string.IsNullOrEmpty(Categories))                 {                     results = results.Where(P => P.Category.Name == Categories);                 }                      //Manufacturers logic                 if (!string.IsNullOrEmpty(Manufacturers))                 {                     results = results.Where(P => P.Manufacturer.Name == Manufacturers);                 }                      //Vehicle logic                 if (Vehicle > 0)                 {                     results = results.Where(P => P.YearId == Vehicle);                 }                      if (acceptableCodes.Count > 0)                 {                     List<int> codes = acceptableCodes.Keys.ToList();                     results = results.Where(P => codes.Contains((int)P.ZipCode));                              //return _UoW.tblcoursebookingRepo.All        //.Where(cb => AttendanceIDs.Contains(cb.Attended))        //.ToList();                 }                 ////Take out items that are not in the ManualQueryResults Dictionary                 //if (!String.IsNullOrEmpty(ManualQuery))                 //{                 //    var all = listB.Where(b => listA.Any(a => a.code == b.code));                 //    results = results.Where(r => ManualQueryResults.Any(a => a == r.id));                 //}                      ////Take out zips not in the closeCodes variable                 //if (!string.IsNullOrEmpty(DistanceLimit))                 //{                 //    results = results.Where(P => closeCodes.Any(z => z.ZipCode.Code == P.ZipCode));                 //}                      switch (sortOrder)                 {                     case "Price_desc":                         results = results.OrderByDescending(P => P.Price);                         break;                     case "Price":                         results = results.OrderBy(P => P.Price);                         break;                     case "Date_asc":                         results = results.OrderBy(P => P.PostDate);                         break;                     default:                         results = results.OrderByDescending(P => P.PostDate);                         break;                      }                 int pageSize = 20;                 int pageNumber = (page ?? 1);                           IPagedList<Item> cc = results.ToPagedList(pageNumber, pageSize);      I could call `.ToList()` somewhere before I hit the `.ToPagedList()` but then I will be returning back thousands of entries and thus lagging the response time by a few seconds. After that I could easily make a paged list from the IEnumerable list. I want to try and minimize response time and so I think the area I need to fix is in the SQL code so as to not pull unnecessary data and then filter it out.