title: Design thoughts on a schema based request object for CXF endpoint

text: Trying to seek design suggestion on a schema based request object for a CXF endpoint. I've created a CXF SOAP endpoint which takes the following object as an input. The request object will have required fields, non-mandatory fields as well as user-defined fields.Required fields are enforced through the schema. Tag object is defined as a placeholder for user defined properties. The eventual goal of the endpoint is transform the values into Tag object and send them for processing.               public class TestServiceRequest{            @XmlElement(required = true)         protected String url;         @XmlElement(required = true)         protected String title;         protected String source;         protected List tags;              public void setUrl(String value) {             this.url = value;         }         public void setTitle(String title) {             this.title = title;         }         public void setSource(String value) {             this.text = value;         }         public List getTags() {             if (tags == null) {                 tags = new ArrayList();             }             return this.tags;         }      Tag object :               public class Tag{        public String name;        public String value;        public String weight;     }      Schema snippet:               <xsd:complexType name="tag">             <xsd:sequence>                 <xsd:element name="name" type="xsd:string" minOccurs="1" maxOccurs="1" />                 <xsd:element name="value" type="xsd:string" minOccurs="1" maxOccurs="1" />                 <xsd:element name="weight" type="xsd:string" minOccurs="0" maxOccurs="1" />                 <xsd:element name="attribute" type="tns:attribute" minOccurs="0" maxOccurs="unbounded"/>             </xsd:sequence>         </xsd:complexType>              <xsd:element name="testServiceRequest">             <xsd:complexType>                 <xsd:complexContent>                     <xsd:extension base="br:BaseRequest">                         <xsd:sequence>                             <xsd:element name="url" type="xsd:string" minOccurs="1" maxOccurs="1"/>                             <xsd:element name="title" type="xsd:string" minOccurs="1" maxOccurs="1"/>                             <xsd:element name="text" type="xsd:string" minOccurs="1" maxOccurs="1"/>                             <xsd:element name="source" type="xsd:string" minOccurs="1" maxOccurs="1"/>                             <xsd:element name="tags" type="tns:tag" minOccurs="0" maxOccurs="unbounded"/>                         </xsd:sequence>                     </xsd:extension>                 </xsd:complexContent>             </xsd:complexType>         </xsd:element>      As you can see, Tag object has an additional field called weight, which is the crux of the issue. Weight is an optional field for each property defined as required (url, title) and optional fields (source) as well. The weights are static value defined for these properties. The reason why I inclined towards this model is firstly, property field names (url, title, etc.) conform to a standard and cannot deviate. Having defined them in a schema and generating the request based on it, allows me to impose that. The end-user is free from using the exact field name and just use the setter instead, thus reducing the scope of error. Moreover, schema validation can be integrated with cxf endpoint easily, hence maintenance is easy. Any change is restricted to the schema. Issue with this model is the service end-point explicitly needs to add the weight for the fields while converting them to Tag objects. If the client ever decides to send their own weight values specific to properties, then this model will break. The other option is to use a simplified request object instead of a schema generated one.               public class Tag{        public String name;        public String value;        public String weight;     }      The pros are that this model is simple and flexible and allows user to define weights and other metadata if required. Issue with this, I need an explicit validation code to make sure the required fields are provided and the field names are correct. That means, every time a new field is added, I need to touch the code to add it as part of the validation. I'm in a dilemma to decide which is the best possible way to design this. Maybe,there's a better way to do this instead. Any pointer will be highly appreciated. Thanks


title: How complex is the documentation you write?

text: In a book I'm reading there is a chapter on documentation for your code. The book is about PHP and described some easy methods but also going for some complicated and time consuming methods (xml, xsl) like DocBook. At my current small company (5 people) we even rarely write comments, but I'm wondering if in a big company how detailed documentation do they write? Do they use such tools like DocBook? Is it complex or simple?


title: Should database-models (conceptual or physical) be reviewed by DBAs?

text: Where I work, new applications that are being developed that will use their own relational database, must have their database-models (conceptual, then physical ) reviewed and aproved by DBAs. Things looked after are normalization, antipatterns, table and column naming standards, etc. Is this really a DBA's responsability to do this ? or should it be, in a greater extend, the responsability of app designers and architects ?


title: Including Module Source files into War file using Maven

text: My goal is to include modules sources files into War file. I read this explanation on the maven official site: http://maven.apache.org/plugins/maven-assembly- plugin/examples/multimodule/module-source-inclusion-simple.html I wonder if it's the only way to include all sources files contained within all modules. Can't the simple maven-plugin-war do the same ?


title: How to do scalar multiplication and matrix inverse when variables are of size 1000 bits?

text: I am doing arithmetic operations on really huge numbers. For example, I am given six variables, a_{11}, a_{12}, a_{21}, a_{22}, x_1, and x_2. Although the above are math terms, these six variables are each 1000-bit integers. What I want to do is to calculate (1) two numbers z_1 and z_2, and (2) the matrix inverse. (1) z_1 = a_{11}*x_1 + a_{12}*x2 and z_2 = a_{21}*x_1 + a_{22}*x2 (2) if A is a matrix defined as A=[a_{11} a_{12}; a_{21} a_{22}], want to compute A^{-1} I know how to do the above when these six variables are ordinary floating points. But my question is how to compute them in C or Python when the six variables are all of size 1000-bit?


title: Aspect Oriented Programming: When to start using a framework?

text: I just watched this talk by Greg Young warning people to KISS: Keep It Simple Stupid. One of the things he suggested is that to do aspect-oriented programming, one _does **not** need a framework_. He starts by making a strong constraint: that all methods take one, and only one, parameter (though he relaxes this a little later by using partial application). The example he gives is to define an interface:               public interface IConsumes<T>     {         void Consume(T message);     }      If we want to issue a command:               public class Command     {         public string SomeInformation;         public int ID;              public override string ToString()         {            return ID + " : " + SomeInformation + Environment.NewLine;         }     }      The command is implemented as:               public class CommandService : IConsumes<Command>     {         private IConsumes<Command> _next;              public CommandService(IConsumes<Command> cmd = null)         {             _next = cmd;         }         public void Consume(Command message)         {            Console.WriteLine("Command complete!");             if (_next != null)                 _next.Consume(message);         }     }      To do logging to console, one then just implements:               public class Logger<T> : IConsumes<T>     {         private readonly IConsumes<T> _next;              public Logger(IConsumes<T> next)         {             _next = next;         }         public void Consume(T message)         {             Log(message);             if (_next != null)                 _next.Consume(message);         }              private void Log(T message)         {             Console.WriteLine(message);         }     }      Then, the pre-command logging, command service, and post-command logging are then just:               var log1 = new Logger<Command>(null);     var svr  = new CommandService(log);     var startOfChain = new Logger<Command>(svr);      and the command is executed by:               var cmd = new Command();     startOfChain.Consume(cmd);      To do this in, for example, PostSharp, one would annotate the `CommandService` this way:               public class CommandService : IConsumes<Command>     {         [Trace]         public void Consume(Command message)         {            Console.WriteLine("Command complete!");         }     }      And then have to implement the logging in an attribute class something like:               [Serializable]     public class TraceAttribute : OnMethodBoundaryAspect     {         public override void OnEntry( MethodExecutionArgs args )         {             Console.WriteLine(args.Method.Name + " : Entered!" );            }              public override void OnSuccess( MethodExecutionArgs args )         {             Console.WriteLine(args.Method.Name + " : Exited!" );         }              public override void OnException( MethodExecutionArgs args )         {             Console.WriteLine(args.Method.Name + " : EX : " + args.Exception.Message );         }     }      The argument Greg uses is that the connection from the attribute to the implementation of the attribute is "too much magic" to be able to explain what's happening to a junior developer. The initial example is all "just code" and easily explained. So, after that rather longwinded build-up, the question is: when do you make the switch from Greg's non-framework approach to using something like PostSharp for AOP?


title: Should I have a separate method for Update(), Insert(), etc., or have a generic Query() that would be able to handle all of these?

text: I'm currently trying to write a class library for a connection to a database. Looking over it, there are several different types of queries: Select From, Update, Insert, etc. My question is, what is the best practice for writing these queries in a C# application? Should I have a separate method for each of them(i.e. Update(), Insert()), or have a generic Query() that would be able to handle all of these? Thanks for any and all help!


title: Downgrading from GPL v3 to GPL v2

text: I have this issue with licensing. I downloaded a third-party class from GitHub and it's under the GPL v3 license. However, I used this class on another open-source project which is under the GPL v2 license, and submitting my script there, requires that everything is under GPL v2 from my side too. Am I allowed to change the license for that class, even though I am not the author?


title: Is there a specific name for the "Square inherits from Rectangle" paradox?

text: A certain failure of OOP is shown with a class Square inheriting from Rectangle, where logically Square is a specialization of Rectangle and should therefore inherit from it, but everything falls apart when you attempt to change a Square's length or width. Is there a specific term for describing what is going wrong with that case?


title: How can I make team Javascript development less painful?

text: We have a team working on an ExtJS web app. Right now, the interface and its functionality is all stuffed in one 1500-line JS file, which is of course _terrible_. It's bad form in general, of course, but it really makes merging changes a bear. Since Javascript doesn't have a #include or @require, or any other dependency- specifying mechanism, I'm at a loss how to gracefully split out functionality into smaller logical units, without requiring a great big laundry list of includes in the consuming HTML. I figure this is a common enough problem that somebody has worked out an elegant solution. Help?


title: Should utility base classes be avoided

text: Knowing that C# doesn't support multiple inheritance, is it considered bad form to write a utility base class? Some initial thoughts:   * I could create an interface and a concretion, but then the implementation isn't portable   * Should the developer need to extend the class in say, a decorator pattern, they could implement this new class and inherit the base class in their new class **EDIT** : N.B. I'm not talking about vanilla inheritance here e.g. poodle<\--dog<\--mammal<\--animal More this sort of thing (lifted from here):                   using log4net;         using log4net.Config;              public class LogTest2         {             private static readonly ILog logger =                    LogManager.GetLogger(typeof(LogTest2));              static LogTest2()         {             DOMConfigurator.Configure();         }              static void Main(string[] args)         {             logger.Debug("Here is a debug log.");             logger.Info("... and an Info log.");             logger.Warn("... and a warning.");             logger.Error("... and an error.");             logger.Fatal("... and a fatal error.");         }     }      If I were to drop this into say, a WCF service, it would be expedient for the private member variable, constructor and perhaps some wrapper methods to sit in a base class to save cluttering up the service code (and make it reusable). So far, so dull. However: What if I wanted to add some other sort of logging not supported by log4net? E.g. Acme Corp provide some class to iMessage the support team if an issue occurs. **Base class** Had I implemented the log4net stuff in a base class, I'd then have to create some new master base class that supports both classes and inherit this. **Interface** I could implement an interface but the concretion would still be in the service code which we're trying to avoid. Acme Corp's class can of course now drop straight in but we're implementing two sets of code which do very similar things in different ways.


title: Resources to learn video/motion capturing

text: I'm hoping to do some programming for the Kinect for my final year University project, starting in a few months. Although I am a fairly competent C# programmer, I've no experience with motion capture, vision depth, basically all those things measured and captured by the Kinect. Could somebody recommend some reading on this subject, preferably at the novice level for now? Online resources would also be good.


title: Full Text Search Strategy For My Website

text: I have a website that allows users to search for items in various categories. Each category is a separate area (page) of my website. For example, some categories might be cars, bikes, books etc. At the moment a user has to search for an item by going to the page (for example, cars) and searching for the car they want. I would like to allow the user to search for anything on my site, from my main home page. At the moment, each page (category) has its own set of tables, and I don't really want to turn Full Text Search on for each table (20+ of them) and search each table individually when a search is done. This is going to be slow and tedious. What I'm thinking of doing is creating a single table that will hold all searchable information for each category of item (when an item is saved in its respective table, I would copy all searchable information over to my 'Search' table). I would then turn Full Text Search on for that table, and search that table. Does this sound reasonable? Is there a better way? I've never used Full Text Search before, so this is new to me.


title: Customizing configuration for PHP will Laravel 4 IoC be useful?

text: This topic has been discussed in this post: Customizing configuration with Dependency Injection However - I couldn't find one for PHP syntax and since one of the answers was to use a specific ASP.net container - I couldn't correlate. I currently have a static class App\Config - that injects itself with a long array of configuration. the array is nothing more than array('max_select' => '10'); and other breakdowns for different objects to be initialize. Would Laravel's IoC be useful to chop this up? If so - how would I do so? Laravel code would be: `$app->make('MyClassA');` However I don't know how to correlate.


title: How to improve in code after you know many languages?

text: Over the past years I learned about 14 programming languages (assembler phyton delphi qbasic c++ c# ruby perl - etc etc etc). However this was all out of my own interest, I didn't went to school for it. Now without real education I am into a team with other programmers. We are into robotics with our work. In contrast to me they know about 2 languages and many frameworks I never had heard of before. I don't really feel behind them, but they can surprise me and other times I can surprise them with solutions. The largest difference is that they have worked for years in the IT, while to me the programming part, is new and I enjoy it. But after the many languages I find it a bit hard to improve. Sometimes I see code (or tools) that are new to me. I never used tools as anksvn, or did versioning or never had seen USB driver made in code, I got used to them, learned from them on projects and my colleagues. I started making money with code (without a real degree) the last 2 years. Given that I haven't found any good YouTube channel or a book, that might improve my skills, how can I improve further? My interests these days are C++ and C#. The point I loose interests if books start with the basics of "if then while for types objects" after 14 languages you get that.


title: Is writing software easier than reading and understanding it from scratch?

text: Me and a friend of mine were discussing yesterday about differences between writing a large C++ software and understanding it as a new recruit. Is it possible that since a software gets done one line at a time and this process resembles how we (humans) learn things and build a thing on top of another one, writing a large software is actually easier than reading it and understanding what it does (stepping through the code helps but you need to remember multiple classes/source files together you don't even know what they've been written for, multithreaded code adds malus points)? This sounds weird at first but after we thought a bit it seemed reasonable


title: Source for "Programmers combine like resistors in parallel"

text: What is the origin (reference, time, author) of the following quote? For instance, is it from a book? > Programmers combine like resistors in parallel. It may be by Gerry Jay Sussman, and I can not rule out the quote comes in several variations. Optionally, **_secondary_** question: what does this quote mean?


title: How much time should be spent with use cases?

text: I'm starting to work with agile iterative approach to software development and this question seems quite natural. After gathering the requirements I should write a few use cases to describe how the user interacts with the system while the requirements are being met. Now, how much time should we spent with this? Should I spent something like a week figuring out the use cases, finish then and only then move to working with each of them to find the main objects? Or should I just write a few of them and get a small number to work with? If I understood agile well, I think I should get just some of them and assure that the functionality being purposed there is indeed constructed and is already usable. Only then I should move to other use cases and review what was done in the use case finished. Am I right with this idea? Thanks very much in advance!


title: Should model / table names be as generic as possible?

text: When naming a model, should the name be as generic as possible-- even if that won't be the name displayed to users? For example let's imagine a Django model for liking another user's posts. Does it make sense to name the model 'Like' even if I plan on displaying it as Kudos, Endorsements, Ups, etc? Does it make sense to make the name as generic as possible, even if the name won't be the one displayed to the user?


title: Why doesn't DDD consider Documents?

text: ... that is, the inputs and outputs of service functions ? Are entities, or aggregates, allowed to leave service boundaries?


title: is it valid that a state machine can have more than one possible state for some transition?

text: I have a requirement for a workflow which I am trying to model as a state machine, I see that there is more than one outcome of a given transition(or activity). Is it valid for a state machine to have more than one possible states, but only one state will be true at a given time? **Note:** This is my first attempt to model a state machine. Eg. might be: **s1->t1->s2** **s1->t1->s3** **s1->t1->s4** where s1, s2, s3, s4 are states and t1 is transition/activity. A fictitious real world example might be: For a human, there can be two states: hungry, not hungry A basket can have only one item from: apple, orange. So, to model it we will have: **hungry->pick from basket->apple found** **hungry->pick from basket->orange found** **apple found->eat->not hungry** **orange found->take juice out of it and then drink-> not hungry**


title: C language portability

text: How exactly is portability of a language like C is determined? I've learned that compilers are ISA specific. If this is true, how is C portable? Or is it that just the source code written in C is portable but not the executables? Aren't the executables ISA specific for examples applications for x86 are separate from the applications for Apple (assuming Apple uses Motorola/PowerPC microprocessor)?


title: Artificial Intelligence Code?

text: I took a Class in college (A.I.) and I found it pretty interesting, but didn't go much further than that (I graduated that semester so I wasn't able to take any more classes). So it's something that's been kind of coming back up as a "side" interest that I kinda wanted to study on my own, I have a ton of e-books and documents but the problem is they are VERY advanced and extremely math/algorithm heavy (which I can understand).....however none of them really explain how you would go about it 'code wise'......so I guess what Im asking is, is their a beginner resource to this kinda stuff (Bayesian Networks/Machine learning/Neural Networks) and such that isn't SO math heavy. I understand why the math is there, but when it doesn't really explain how you would go about 'programming' such a system.....well it gets kind of confusing to move forward with.


title: Source control and compilation tool chain

text: I am a single developer working on a large system. I was recently informed that there may be an opportunity to recruit another developer or maybe two. I have incorporated source control into my approach using Subverison and Tortoise SVN. I was talking to another developer who I used to work with recently and he reminded me about the concept of a compilation tool chain and specifically nightly builds for unit testing. I have two questions:   1. Is it good practice for all software development teams to use unit testing and nightly builds? Is there any criteria that identifies teams that are more suitable than others for nightly builds.   2. How do developers identify areas suitable for unit testing? I assume that you look at the use cases. I assume that these use cases could include different processing methods e.g. users interacting with a web application or a batch processing job that runs via a scheduled task each night.


title: Does agile development need a framework in place first?

text: We are planning a new project and we want to go with a services oriented architecture. Everyone agrees that this is the way to go but how does this fit in with starting the development using agile methodologies? I do not have any experience with SOA, although I have some experience with TDD (test driven development). The team I work with thinks that we need a framework in place before we can even start looking at developers doing work with TDD. In others we spend weeks getting a framework in place (a SOA framework) and then the developers can build on this framework to do their work. From a TDD point of view, I would have expected each developer to just flesh out the functionality using MOCKs etc whilst the framework is being developed (although I have no idea what a framework in SOA would involve). Then we could plug in the actual framework calls when we need to. Not sure if this right but it feels the correct way.


title: How should contributions to an open source project be managed by the owner(s)?

text: When managing an open source project (using a service like GitHub) how would one respond to the following: Somebody has kindly submitted a patch to add a new feature or address a problem. Any one of the following situations occur:   * The source code doesn't meet one or more naming conventions, etc.   * I feel that the source code could be improved in a certain way. Perhaps the same effect can be achieved with far simpler source, or perhaps another useful feature would be needed. Q1. Is it acceptable for me to alter the submitted source? (is this possible on GitHub?) Q2. Should all such submissions be rejected in accordance with submission guidelines? Q3. If yes to Q2, what about a really neat idea that was poorly implemented? Is it acceptable for me to just go ahead and create my own? I want to encourage contribution but at the same time it is important to maintain a certain standard.


title: Clean readable code vs fast hard to read code. When to cross the line?

text: When I write code I always try to make my code as clean and readable as possible. Every now and then there comes a time when you need to cross the line and go from nice clean code to slightly uglier code to make it faster. When is it OK to cross that line?


title: Things to be aware of Client Relationships as a Beginner?

text: I'm an entry level programmer and am involved in daily client meeting about project progress, issues, deadlines etc. I have no experience of client management, could you people please suggest any common things to consider when interacting with clients both in a project and people management perspective.


title: How to simplify unit testing with higher order functions?

text: * this is _not_ a question on how to write unit tests   * this is _not_ a question on what to test   * this is a question on reducing the typing needed overall for a personal testing framework I know you can send function pointers as arguments to functions in C. Is there a c++98 version? Or, since c++ can work backwards, should I just use the C function pointer method? I am trying to write a function that tests functions for me. I don't want to write a long list of:               try {       func1()       out << fail     } except e {       out << pass     }          if (func2(arg2) == expected_val) {       out << pass     else       out << fail          try/catch...     try/catch...     if/else...     try/catch...     ...etc      but maybe instead:               test_this(func1, passes_on_exception)     test_this(func2, ! passes_on_exception, expected_val2, arg2)     test_this(func3, passes_on_exception)     test_this(func4...     test_this(func5...     ...etc          void test_this(func_name, pass_on_exception, expected_value, arg1, ..., argn) {       if pass_on_exception {           try {               func_name(arg1)               out << fail           } catch e {               out << pass           }       } else {           if func_name == expected_value {               out << pass           } else {               out << fail           }       }     }      Virtual functions seems out of the question since, if I recall correctly, the function names have to be overridden/hardcoded; as in, I would need to create a new class to inherit and override the functions, in which case, I would redeclare the function, and also retype all of those try/catch... the chain of try/catch/if/else seems better. If there was a way to pass function names to other functions, I think I can figure it out from there. Unless the above is actually impossible in C++, then please stop me before I start, and I'll just bear with that long list of try/catch/if/else unit testing method. So, main question: is there a way to do the above? If not, alternatives?


title: Differentiating between Factory Method and Abstract Factory

text: I've been confused for a while about the differences between the patterns Factory Method and Abstract Factory. Been doing a lot of research, still confused. I have one question: Is the **only difference** between the two patterns, is that Factory Method **produces one object** , and Abstract Factory produces a **family of objects**? Or are there more differences? I read a lot on this site and the web about this, only confused me more. I know how to use the patterns, but am having trouble differentiating between the two.


title: expressing the speed of a sorting algorithm

text: How would I express the speed of the following sort algorithm? I know bubblesort is n^n (er, I mean n^2...as someone pointed out below). In the following the array decreases each time you call it recursively. thanks. * * *               $myarray = array("21","4","8","8","1","2","19","21");     mysort($myarray);          function mysort($myarray,$sorted = null){         if(!isset($sorted)){             $sorted = array();         }         $lowest = $myarray[0];         $lowindex = 0;         for($x = 1;$x < count($myarray);$x++){             if($myarray[$x] < $lowest){                 $lowest = $myarray[$x];                 $lowindex = $x;             }         }         $sorted[] = $lowest;         array_splice($myarray,$lowindex,1);         if(count($myarray) > 1){             echo "calling recursively \n";             mysort($myarray,$sorted);         }         else if(count($myarray) == 1){                   $sorted[] = $myarray[0];             $arraystr = print_r($sorted,true);             echo "sorting finished. Array is $arraystr \n";             return;         }     }


title: How to reduce close points

text: input: C matrix 2xN (2D points) output: C matrix 2xM (2D points) with equal or less points.      Lets say we have C matrix 2xN that contains several 2D points, and it looks something like that:   ![enter image description here](http://i.stack.imgur.com/1lFgN.jpg)   What we want is to group "close" points to one point, measured by the average of the other points. For example, in the second image, every group of blue circle will be one point, the point coordinate will be the average point off all points in the blue circle. also by saying "close", I mean that: their distance one to each other will be smaller then DELTA (known scalar). So wanted output is:   ![enter image description here](http://i.stack.imgur.com/Ihekp.jpg)   About running time of the algorithm, I don't have upper-limit request but I call that method several times...   I am using Matlab, and what i have tried is this:                 function C = ReduceClosePoints(C ,l_boundry)         x_size = abs(l_boundry(1,1)-l_boundry(1,2)); %220         DELTA = x_size/10;         T = [];         for i=1:size(C,2)             sum = C(:,i);             n=1;             for j=1:size(C,2)                 if i~=j     %not same point                     D = DistancePointToPoint(C(:,i),C(:,j));                     if D < DELTA                         sum = sum + C(:,j);                         n=n+1;                     end                 end             end             sum = sum./n; %new point -> save in T matrix             T = [T sum];         end         C = T;     end      And its not working :( Also I am new to Matlab.   Thank you for your help!!


title: SQL Update statement generator using C# Winforms?

text: I am trying to make an UPDATE STATEMENT generator using C# Winforms. I would like to build a statement generator which will print statements like this:               UPDATE Customers     SET ContactName='Alfred Schmidt', City='Hamburg'     WHERE CustomerName='Alfreds Futterkiste';      But my problem is, how can I let the user paste in multiple values for each `SET`? My end user is likely to build a list using a spreadsheet and will want to paste in the values into a multi-line text box. I could create 2 multi-line text boxes, but what if i have more `SET` columns i need to add?


title: Killer semi-unique programming language features

text: When learning a new programming language you sometimes come across a language feature which makes you wish you had it in your other programming languages that you know. What are some language feature which were at the time of learning very new to you and that you wish your other programming languages had. An example of this is generators in Python or C#. Other examples may include list comprehensions in Python, template in C++ or LINQ in .NET or lazy evaluation in Haskell. What other semi-unique language features have you come across which were completely new and enlightening to you? Are there other features of older programming languages which were unique and have fallen out of fashion?


title: How do you manage your knowledge base?

text: As programmers we have a lot of inputs:   1. Ebooks    2. Code snippets    3. Interesting emails    4. Documents   5. Web articles    6. Blog posts   7. StackOverflow questions   8. Podcasts ... Which tools do you use to store, organize, search and consult all of this stuff?   Is there a silver bullet solution to handle this huge amount of data?


title: With continuous integration in .NET, is it acceptable to reference DLLs of rarely-changing assemblies?

text: My company is looking to implement a CI solution pretty soon, and I am worried about one thing in particular... we are scaling up, which means our solutions are growing with more projects. One thing I wanted to look into is to split off rarely changed projects into a separate project, and then having other projects simply reference the compiled DLL, rather than including the projects in their solutions. For example...   * /BLL/DataFramework   * /BLL/OrmFramework   * /BLL/OrmDataAdapter   * /BLL/...   * /WebUI/MyWebSite The Data and ORM projects would rarely be changed, but if not referenced as DLLs would add bloat to all solutions. Instead I'd like to exclude them from the project and have them build to a Libraries folder (or something similar), so that:   * /BLL/...   * /Libraries   * /WebUI/MyWebsite Where the ORM and Data assemblies .DLLs are in the Libraries folder. So the question is... **Is there any reason this would not work with Continuous Integration?** Could I have one solution with these rarely updated classes that will build to the library folder during CI, first, and followed by the other solutions? _Edit: **To be clear...** we want to keep these projects in the CI cycle, but to not directly reference their projects in every solution._


title: several similar tables vs several one-to-one relationships?

text: I have a sort of blog application that I'm working on for constrained writing. The posts have several types, and share some columns in common (title, body for instance), but they also have columns that they don't share in common. Please correct me if I'm wrong, but I feel like my two database design options are:   1. Create a separate table for each type of post (and then use UNION if I ever need to select all of the various types).   2. Create one table to store all of the similar columns (and then have several one-to-one relationships to define what's different about them--like an inheritance-type situation). Which is better? Why? Are there other designs that would be better? **UPDATE** : these posts will be different types of constrained writing (I.e., poems), that are validated in specific ways based on the particular constraint technique, and may have a variety of other tables associated with them, so extensibility will be really important. That said it sounds like either the nosql or inheritance options would be best. I would just be worried about doing analytical stuff with nosql (never used it, so I just don't know anything about how to aggregate, etc, with it).


title: How does I/O work for large graph databases?

text: I should preface this by saying that I'm mostly a front end web developer, trained as a musician, but over the past few years I've been getting more and more into computer science. So one idea I have as a fun toy project to learn about data structures and C programming was to design and implement my own very simple database that would manage an adjacency list of posts. I don't want SQL (maybe I'll do my own query language? I'm just having fun). It should support ACID. It should be capable of storing 1TB let's say. So with that, I was trying to think of how a database even stores data, without regard to data structures necessarily. I'm working on linux, and I've read that in that world "everything is a file," including hardware (like `/dev/*`), so I think that that obviously has to apply to a database, too, and it clearly does--whether it's MySQL or PostgreSQL or Neo4j, the database itself is a collection of files you can see in the filesystem. That said, there would come a point in scale where loading the entire database into primary memory just wouldn't work, so it doesn't make sense to design it with that mindset (I assume). However, reading from secondary memory would be much slower and regardless some portion of the database has to be in primary memory in order for you to be able to do anything with it. I read this post: Why use a database instead of just saving your data to disk? And I found it difficult to understand how other databases, like SQLite or Neo4j, read and write from secondary memory and are still very fast (faster, it would seem, than simply writing files to the filesystem as the above question suggests). It seems the key is indexing. But even indexes need to be stored in secondary memory. They are inherently smaller than the database itself, but indexes in a very large database might be prohibitively large, too. So my question is how is I/O generally done with large databases like the one I described above that would be at least 1TB storing a big adjacency list? If indexing is more or less the answer, how exactly does indexing work--what data structures should be involved?


title: Why was REST web srevice named REST?

text: What does the word Representational State Transfer (REST) mean actually ? Now I don seem to find any relation between its naming and its working, I have understood that it is a architectural style for programming web service and I've read all the hush hush stuff but can't find a reason behind its naming. What is `Representational` ? Who's `State`? and What do we `Transfer`?


title: How deep is enough to represent an algorithm in UML sequence diagram?

text: I have three simple classes. `LoginController`, `UsersCatalog` and `User`. `UsersCatalog` has an array of `User`. I have to represent a simple process of login. `LoginController` has a method `login(username, password)` that simply calls a method `authenticate(username, password)` with the same parameters. Now, it's obvious that the method `authenticate` seeks for a matching `User` object and returns it. The question is: **Is it necesary to represent the seek algorithm?** Isn't representing the seek algorithm too much low level? In the other side, the access to `User` class is inside the seek algorithm, so if i don't represent it, then i don't represent the access to the `User` class. This is part of a wider question. There are any criteria for how deep is enough to represent an algorithm in UML squence diagram?


title: Local Updates in Persistent/Immutable Data Structures

text: I'm getting into ReactJS and am intrigued but also confused about persistent data structures. I love the idea, but I'm not sure how to take my MV*, Mutable, Observable Bindings experience in designing view components and apply it in a sane way. For example, suppose I have a deeply nested structure:               Foo       Bar          Baz           someValue       Qux       Quxx      In my UI, I have a component that is an editor for `someValue`. In a mutate- observe paradigm I would do something like:               Baz.setSomeValue(newValue)  // trigger observers, etc...      As near as I can tell, though, the equivalent with persistent data structures is something like:               Foo = extend(Foo, { Bar:{ Baz:{ someValue: newValue } } });     // recompute with new value of Foo      What is the normal pattern for encapsulating a component that deals with `Baz` so that it doesn't have to know the entire structure?


title: Where should I store and verify files manipulated by an app

text: I'm working on a little Ruby script to move screenshots while renaming them based on a specific convention. I'll be writing tests to confirm the behavior. Ruby has lots of conventions for where to store files (e.g. the "spec" and "features" directories for RSpec and Cucumber, respectively), but I'm not finding best practices for storing files that will be acted upon by the tests. The same goes for a destination for the final copies of the files. So, the question in two parts is:   1. Where should I store files that the test cases will use for a source input.    2. Where should tests that need to write output files send them to.


title: Decide for which class of points neurone will give output 1

text: We have to class of points `red` and `green`. We create neurone with discrete binary activation function. **How to choose weights so the neurone will return 1 for`red` points?** **How to choose weights so the neurone will return 1 for`green` points?** I am asking for general practice how to decide for which "side" the NET will be greater or equal to 0 -> if I am right about it. ![enter image description here](http://i.stack.imgur.com/UT1i3.png) NET >= 0 towards red points ![enter image description here](http://i.stack.imgur.com/12Kxe.png) NET >= 0 towards green points


title: How do I get people to stop bikeshedding?

text: I have been tasked with teaching other teams a new codebase, but I keep running into an issue. Whenever I go to actually walk through the code with people, we don't get very far before the entire exercise devolves into a bikeshedding exercise. Since they don't know the codebase, but think they need to help improve it, they focus on the things they _can_ understand: `Why is that named that?` (2 minutes to explain why it's named that, 10+ minutes debating a new name) `Why is that an abstract base class rather than an interface?` (2 minutes to explain, 10+ minutes debating the relative merits of this decision) ...and so on. Now, don't get me wrong - good names and good, consistent design are important, but we never get to discussing what the code actually _does_ or how the system is designed in any meaningful way. I've done some meeting refereeing to get people out of these tangents, but they're gone - distracted by what the code will/should be when their pet triviality is fixed, and they miss the bigger picture. So we try again later (or with a different part of the codebase) and since people didn't get enough knowledge to overcome the bikeshedding effect, it repeats. I've tried smaller groups, bigger groups, code, whiteboarding, visio diagrams, giant walls of text, letting them just argue it to death, cutting arguments short immediately... some help more than others, but nothing **works**. Hell, I even tried having other people from my team explain it because I thought it might be that I'm just bad at explaining things. So how do you educate other programmers enough that they stop fixating on trivialities and can meaningfully contribute to the design?


title: Are there any famous one-man-army programmers?

text: Lately I have been learning of more and more programmers who think that if they were working alone, they would be faster and would deliver more quality. Usually that feeling is attached to a feeling that they do the best programming in their team and at the end of the day the idea is quite plausible. If they ARE doing the best programming, and worked alone (and more maybe) the final result would be a better piece of software. I know this idea would only work if you were passionate enough to work 24/7, on a deadline, with great discipline. So after considering the idea and trying to learn a little more, I wonder if there are famous one-man-army programmers that have delivered any (useful) software in the past?


title: Teaching programming to a non-CS graduate

text: I have a couple of friends interested in computer programming, but they're non-CS graduates; some of them have very little experience in software testing field (some of them took some basic software testing courses). I am going to be working with them on teaching basic computer programming, and computer science fundamentals (data structures etc). My questions are;   * What language should I start with?   * What are essential computer science topics that I should cover before jumping them into computer programming?   * What readings can I incorporate to make the topic interesting and non-overwhelming?   * If we want to spend a year on it, what topics should take priority and must be covered in 12 months? Again, these are non computer science folks, and I want to keep the learning as much fun as possible. Thanks everyone.


title: How should one handle accessing a 'local' API?

text: I'm currently writing a project that is using a few separate virtual machines for the database, API and front-end website (currently 1 of each). I'm writing my code in PHP, and all of these virtual machines are running within the same virtual network. What are the best practices (if any) for accessing a 'local' API like this in the front-end? Would you still use something like curl? Are there alternatives to doing so?


title: How to make creating viewmodels at runtime less painful

text: **I apologize for the long question, it reads a bit as a rant, but I promise it's not! I've summarized my question(s) below** In the MVC world, things are straightforward. The Model has state, the View _shows_ the Model, and the Controller _does_ stuff to/with the Model (basically), a controller has no state. To _do_ stuff the Controller has some dependencies on web services, repository, the lot. When you instantiate a controller you care about supplying those dependencies, nothing else. When you execute an action (method on Controller), you use those dependencies to retrieve or update the Model or calling some other domain service. If there's any context, say like some user wants to see the details of a particular item, you pass the Id of that item as parameter to the Action. Nowhere in the Controller is there any reference to any state. So far so good. Enter MVVM. I love WPF, I love data binding. I love frameworks that make data binding to ViewModels even easier (using Caliburn Micro a.t.m.). I feel things are less straightforward in this world though. Let's do the exercise again: the Model has state, the View _shows_ the ViewModel, and the ViewModel _does_ stuff to/with the Model (basically), a ViewModel _does_ have state! (to clarify; maybe it delegates all the properties to one or more Models, but that means it must have a reference to the model one way or another, which is state in itself) To _do_ stuff the ViewModel has some dependencies on web services, repository, the lot. When you instantiate a ViewModel you care about supplying those dependencies, but also the state. And this, ladies and gentlemen, annoys me to no end. Whenever you need to instantiate a `ProductDetailsViewModel` from the `ProductSearchViewModel` (from which you called the `ProductSearchWebService` which in turn returned `IEnumerable<ProductDTO>`, everybody still with me?), you can do one of these things:   * call `new ProductDetailsViewModel(productDTO, _shoppingCartWebService /* dependcy */);`, this is bad, imagine 3 more dependencies, this means the `ProductSearchViewModel` needs to take on those dependencies as well. Also changing the constructor is painful.   * call `_myInjectedProductDetailsViewModelFactory.Create().Initialize(productDTO);`, the factory is just a Func, they are easily generated by most IoC frameworks. I think this is bad because Init methods are a leaky abstraction. You also can't use the readonly keyword for fields that are set in the Init method. I'm sure there are a few more reasons.   * call `_myInjectedProductDetailsViewModelAbstractFactory.Create(productDTO);` So... this is the pattern (abstract factory) that is usually recommended for this type of problem. I though it was genius since it satisfies my craving for static typing, until I actually started using it. The amount of boilerplate code is I think too much (you know, apart from the ridiculous variable names I get use). For each ViewModel that needs runtime parameters you'll get two extra files (factory interface and implementation), and you need to type the non-runtime dependencies like 4 extra times. And each time the dependencies change, you get to change it in the factory as well. It feels like I don't even use a DI container anymore. (I _think_ Castle Windsor has some kind of solution for this [with it's own drawbacks, correct me if I'm wrong]).   * do something with anonymous types or dictionary. I like my static typing. So, yeah. Mixing state and behavior in this way creates a problem which don't exist at all in MVC. And I feel like there currently isn't a really adequate solution for this problem. Now I'd like to observe some things:   * People actually use MVVM. So they either don't care about all of the above, or they have some brilliant other solution.   * I haven't found an in-depth example of MVVM with WPF. For example, the NDDD-sample project immensely helped me understand some DDD concepts. I'd really like it if someone could point me in the direction of something similar for MVVM/WPF.   * Maybe I'm doing MVVM all wrong and I should turn my design upside down. Maybe I shouldn't have this problem at all. Well I know other people have asked the same question so I think I'm not the only one. **To summarize**   * Am I correct to conclude that having the ViewModel being an integration point for both state and behavior is the reason for some difficulties with the MVVM pattern as a whole?   * Is using the abstract factory pattern the only/best way to instantiate a ViewModel in a statically typed way?   * Is there something like an in depth reference implementation available?   * Is having a lot of ViewModels with both state/behavior a design smell?


title: How feasible would it be to not work for anyone, my entire programming career?

text: Assume I have enough money to live off of for 3 months. Would it be impossible to _just_ freelance my entire programming career, after sufficiently learning the language and helping open source projects? Or would clients want to see work experience. I am mostly talking about Objective-C development, so I would be publishing apps to make income. Is this possible?


title: What are the security implications of running untrusted code on my server?

text: I would like to set up an app that allows users to send their code and execute it on my server. The thought of running untrusted code makes me cringe, so I am trying to set up an exhaustive list of security threats that should be addressed. I am assuming I should strip down certain features of the language executed, like file access or (maybe) networking. I also come across terms like `sandboxing` or `chroot`. I know what they mean, but how should I actually use them? In short: What security threats should I address before allowing users to run their code on my machine, and how do I do it?


title: What factors can make mid-project join successful?

text: It's not entirely uncommon in IT that programmers are added to an existing project somewhere in the middle, or closer to finish. Unfortunately, I've seen that people quickly get disillusioned and leave the job. So, is there an actual problem? If there is a problem, is there some research in or are there best practices for avoiding this mid-project-join syndrome? Is this common in industry?


title: At what point does programming become a useful skill?

text: This is probably a very difficult question to answer, because of its subjectivity, but even a vague guess would help me out: Now that Khan Academy is beginning to offer Computer Science lectures I'm getting an itch to learn programming again. I maybe am a bit more technical than your average computer user, using Ubuntu as my OS, LaTeX for writing and I know some small tricks like regular expressions or boolean search for google. However from my previous attempts to learn programming, I realized I do not have a natural aptitude for it and I also don't seem to enjoy the process. But I am fairly certain that a basic proficiency in programming could prove to be very beneficial for me career wise; I also often get ideas for little scripts that I cannot implement. My question is: Let's say you study programming 1 hour / day on average. At what point will you become good enough so that programming can be used for automating tasks and actually saving time? Do you think programming is worth picking up if you never have the ambition to make it your career or even your hobby, but use it strictly for utility purposes?


title: Is it possible to take a binary compiled for ARMv7 architecture and convert it to ARMv6?

text: Is it possible to take a binary compiled for ARMv7 architecture and convert it to ARMv6 ? Are there any tools that can do this?


title: Advice for Setting up an On-Call Team

text: I'm leading a largish development team (~35 developers). We are doing primarily Web Development work on a number of sites. Historically the knowledge on the teams has been pretty siloed. If you worked on Site A you will know how to troubleshoot it, but you would not be a lot of help on Site B. We also have a few cross-cutting concerns, i.e. common components used between sites which require specialized knowledge to troubleshoot. With all this in mind, I'm trying to understand the best way to setup an on- call team. This would be a team of programmers who would be available to deal with out- of-hours emergency issues occasionally (say one call every 2 weeks). They may be required to deploy emergency fixes. Part of me is saying we can't have a big on-call team with shallow knowledge, instead we need a smaller team with deep knowledge who can expect to be on- call more often and remunerated as such. Does anyone have any suggestions based on experience on how to setup this team? Thanks in advance.


title: Which Common Lisp implementation to use?

text: There seems to be an immediate problem with starting to develop in Common Lisp: choosing an implementation. What should one take into account, and how much weight should it bear when considering a CL implementation? Should it conform to the ANSI standard? Should it be supported by SLIME? Do certain implementations lack good libraries, documentation, etc?


title: Why does this static field always get initialized over-eagerly?

text: I am looking at this excellent article from Jon Skeet. While executing the demo code, Jon Skeet says that we can expect three different kinds of behaviours. To quote that article: > The runtime could decide to run the type initializer on loading the assembly > to start with... Or perhaps it will run it when the static method is first > run... Or even wait until the field is first accessed... When I try this out (on framework 4), I always get the first result. That is, the static method is initialized before the assembly is loaded. I have tried running this multiple times and get the same result. (I tried both the debug and release versions) Why is this so? Am I missing something?


title: In what ways can I test an image slideshow javascript code?

text: I have a slideshow of images (and links) on a page. These images are part of a JSON response to a request sent after the page loads. The slideshow is set to play at an interval of 2 seconds. The slideshow can be paused, played over, and all other controls a normal slideshow would have. As a Rails dev, I proposed cucumber but the javascript guys in the team are not comfortable with ruby. I saw some cucumber for javascript libraries coming up, still in experimental stage. I checked out jasmine and related tutorials but all I could get from them is how I can carry out any internal functional testing such as credit-cart validation, etc. - which I think could actually be handled in unit testing? (Screw the research I did and) How should I go about testing this and similar components?


title: How can I look at a GitHub repository and know what version of the code to download?

text: I am new to GitHub and new to the open source world (coming from .NET). I have a media wiki site and want to install a Google analytics extension: http://www.mediawiki.org/wiki/Extension:Google_Analytics_Integration The extension's documentation says to download the code from GitHub. In the GitHub repo, there are some "reviews" that say master and some that that say branches. I assume that I want a master and not a branch. But how do I pick which master to download? Also, the documentation says that some of the commits will be tagged but this does not seem to be the case. Without tags/documentation is there any easy way to know what commits are stable and what commits are not? I'd love some general wisdom about how to approach a repo for a project like this.


title: Is Windows Workflow Foundation appropriate for a CPU-heavy async application?

text: At one of the DevDays conferences a presenter said that Workflow Foundation isn't just for applications that require persistence, but they can make it easier to write and maintain Async WCF code and the corresponding error handling. (try.. catch)   * Assuming that is true, is Workflow Foundation able to use all the CPUs in a system? (Async IO)   * What WF-specific guidance is needed before writing a CPU-heavy Async WCF application within the WF framework? (only tips that are specific to Workflow Foundation)


title: Azure website that talks to third party services

text: I have website that crawls data from many third party services when user browse to webpage. This can be really slow because I hit third party server and process returned data before showing it to user. I am hosting website on Azure (shared mode). I am thinking to improve my implementation. Here is what I am thinking... Run a service that crawls data from third party services, process it and then store it in database. when user browse to my site, my site pulls data from database and display them to user. But above solution is not clear to me. Should I have normal service or wcf service? If wcf service then should website talk to database or wcf service (that can access data from database)? If normal service then how can I deploy on Azure?


title: Does anyone else feel Scrum isn't agile?

text: I am a big fan of agile development and used XP on a very successful project a few years ago. I loved everything about it, the iterative development approach, writing code around a test, pair programming, having a customer on site to run things by. It was a highly productive work environment and I never felt like I was under pressure. However the last few places I have worked use/used Scrum. I know it's the poster child for agile development these days but I'm not 100% convinced it is agile. Below are the two main reasons why it just doesn't feel agile to me. **Project Managers Love It** Project managers, who by their very nature are obsessed with timelines, all seem to love Scrum. In my experience they seem to use the Sprint Backlog as a means to track time requirements and keep a record of how much time was spent on a given task. Instead of using a whiteboard they all use an excel sheet, which each developer is required to fill out, religiously. In my opinion this is way too much documentation/time tracking for an agile process. Why would I waste time estimating how long a task is going to take me when I can just get on with the task itself. Or similarly why would I waste time documenting how long a task took when I can move onto the next task at hand. **Standup Meetings** The standup meetings in the previous place I worked were a nightmare. Everyday we had to explain what we had done yesterday and what what we were going to do that day. If we went over on our time "estimate" for a task the project manager would kick up a stink, and reference the Sprint Backlog as a means of showing of incompetent you are for not adhering to the timeline. Now I understand the need for communication but surely the tone of daily meetings should be lighthearted and focus on knowledge sharing. I don't think it should turn into a where's your homework style charade. Also surely the hole point of agile is that timelines change, they shouldn't be set in stone. **Conclusion** The idea of agile is to make the software better by making the developers life easier. Therefore in my opinion any agile process used by a team should be developer led. I don't think having a project manager use a process they have labeled "agile" to track a project has anything to do with agile development. Thoughts anyone?


title: Is there a licence that let people see my code but not use it?

text: I'm building free games in javascript, with my code is easily accessible by looking into the html of the webpage. I really don't mind people looking at my code (for curiosity, or to learn something). But I don't want anyone to use my code to make their own games, or steal the art I've done. With this goal in mind, what software licence should I use? Thanks!


title: How to handle monetary values in PHP and MySql?

text: I've inherited a huge pile of legacy code written in PHP on top of a MySQL database. The thing I noticed is that the application uses `doubles` for storage and manipulation of data. Now I came across of numerous posts mentioning how `double` are not suited for monetary operations because of the rounding errors. However, I have yet to come across a complete solution to how monetary values should be handled in PHP code and stored in a MySQL database. Is there a best practice when it comes to handling money specifically in PHP? Things I'm looking for are:   1. How should the data be stored in the database? column type? size?   2. How should the data be handling in normal addition, subtraction. multiplication or division?   3. When should I round the values? How much rounding is acceptable if any?   4. Is there a difference between handling large monetary values and low ones? **Note:** A **VERY** simplified sample code of how I might encounter money values in everyday life (various security concerns were ignored for simplification. Of course in real life I would never use my code like this):               $a= $_POST['price_in_dollars']; //-->(ex: 25.06) will be read as a string should it be cast to double?     $b= $_POST['discount_rate'];//-->(ex: 0.35) value will always be less than 1     $valueToBeStored= $a * $b; //--> any hint here is welcomed           $valueFromDatabase= $row['price']; //--> price column in database could be double, decimal,...etc.          $priceToPrint=$valueFromDatabase * 0.25; //again cast needed or not?      I hope you use this sample code as a means to bring out more use cases and not to take it literally of course. **Bonus Question** If I'm to use an ORM such as Doctrine or PROPEL, how different will it be to use money in my code.


title: Microsoft Visual C++ Redistributables, Software Requirement?

text: When compiling with Visual Studio C++, I noticed that you need a specific MSV C++ Redist, depending on the version of Visual Studio you compile with. The required redistributable is necessary on machines without it. Otherwise without the redists missing MSVCPxxx.dll errors are prompt. Is there a way to by-pass needing the necessity of the redistributable? Or is there a way to package that inside of the program you're creating, be it DLL, executable, etc.?


title: Is it bad code smell if private method calls public one?

text: Is it bad code smell to call public method in private method of same object instance?


title: Whats the best way to parallel my problem using Java API

text: I´m with trouble, because I want to make faster my code using `threads`, `fork in join` or any kind of `parallel`. I did a code using `fork in join` but I saw my `arraylist` isn´t getting the correct values. I don´t know if is my implementation. But I want to take off all messages without attachments, later separate by sender. One example of my class using `fork in join`, but I´m looking for any suggestions.               package service.forkinjoin;          import java.io.IOException;     import java.util.ArrayList;     import java.util.List;     import java.util.concurrent.RecursiveAction;          import javax.mail.Message;     import javax.mail.MessagingException;          import service.EmailUtil;          public class ForkSortMessagesBySender extends RecursiveAction {              private static final long serialVersionUID = -1092415796824205832L;         private List<Message> listMessagesWithAttachment;         private List<Message> listMessages;         private String sender;              public ForkSortMessagesBySender(List<Message> listMessagesWithAttachment, List<Message> listMessages, String sender) {             this.listMessagesWithAttachment = listMessagesWithAttachment;             this.listMessages = listMessages;             this.sender = sender;         }              @Override         protected void compute() {                  List<RecursiveAction> actions = new ArrayList<>();                  if (this.listMessagesWithAttachment.size() <= Runtime.getRuntime().availableProcessors()) {                 try {                     this.separateMessages();                 } catch (MessagingException | IOException e) {                     e.printStackTrace();                 }             } else {                      int end = this.listMessagesWithAttachment.size() / 2;                 actions.add(new ForkSortMessagesBySender(this.listMessagesWithAttachment.subList(0, end), this.listMessages, this.sender));                 end += this.listMessages.size() % 2 == 0 ? 0 : 1;                 actions.add(new ForkSortMessagesBySender(this.listMessagesWithAttachment.subList(end, this.listMessagesWithAttachment.size()), this.listMessages, this.sender));                 invokeAll(actions);             }         }              private void separateMessages() throws MessagingException, IOException {                  for (Message message : this.listMessagesWithAttachment) {                 if (EmailUtil.getSender(message).equals(this.sender)) {                     this.listMessages.add(message);                 }             }         }     }


title: Are nested classes under-rated?

text: I'm not trying to say I know something everyone else doesn't but I've been solving more and more designs with the use of nested classes, so I'm curious to get a feeling for the acceptablilty of using this seemingly rarely used design mechanism. This leads me to the question: am I going down an inherintly bad path for reasons I'll discover when they come back to bite me, or are nested classes maybe something that are underrated? Here are two examples I just used them for: https://gist.github.com/3975581 \- the first helped me keep tightly releated heirarchical things together, the second let me give access to protected members to workers...


title: DataSet Validation vs. ASP.NET MVC Validation

text: I have a general question on where to put validation. I have an asp.net mvc that gets/sets data from/to a DataSet. Currently, the fields in the form are validated by the form itself (e.g. for invalid length, range, etc.). Is it a good or better idea to transfer these validation checks into the DataSet? The downside is I need to trigger update calls to the DataSet in order to get the column with errors. In using forms, I can catch the error earlier. Or should I use validation for both of them? For additional consideration - it's possible I will be re-using this Dataset assembly with another project (a WCF service?). And I'd like to re-use the same validation code when possible.


title: Resources on Writing Efficient C Code for Micro-controllers?

text: Serious help needed here. I love programming. I've been reading bunch of books(such as K&R) and articles/forums online for C language lately. Even tried looking into Linux code(although, i was lost where to start but peeking into small libraries helped?). I started as a Java programmer and in Java it's pretty cut and dry; If programs gets too big, slice it in classes then further into functions. Guidelines like, keep the code readable and add comments. Use information hiding and OOP techniques. Some of which still applies for C. I've been coding in C now and so far i get programs to work one way or the other. A lot of people talk about performance/efficiency, algorithm/design, optimization, and maintainability. Some people stress one more then the other but for non-professional software engineers you often hear something like e.g: Linux kernel dev won't just take any code. My question is this: I plan on writing a code for 8-bit microcontroller **without wasting any resources**. Know that i'm coming from java background so things are not the same anymore... resources/books/links/tips will be much appreciated. Performance and size now matters. Resources/Tricks on efficient(within best practices) C code for 8-bit micro-controllers? Also, `inline assembly` plays a vital role as well sticking close to micro- controllers standard. But are there general rule of thumb to efficiency that applies to all? For example: `register unsigned int variable_name;` is preferred over `char` anytime. Or using ` uint8_t ` if you don't need big numbers. EDIT: Thank you so much for all the answers and suggestions. I appreciate everyone's effort for sharing knowledge.


title: Why use other number bases when programming

text: My coworkers and I have been bending our minds to figuring out why anyone would go out of their way to program numbers in a base other than base 10. I suggested that perhaps you could optimize longer equations by putting the variables in the correct base you are working with (for instance, if you have only sets of 5 of something with no remainders you could use base 5), but I'm not sure if that's true. Any thoughts?


title: Client-Server connection response timeout issues

text: User creates a folder in client and in the client-side code I hit an API to the server to make this persistent for that user. But in some cases, my server is so busy that the request timesout. The server has executed my request but timedout before sending a response back to client. The timeout set is 10 seconds in client. At this point the client thinks that server has not executed its request (of creating a folder) and ends up sending it again. Now I have 2 folders on the server but the user has created only 1 folder in the client. How to prevent this? One of the ways to solve this is to use a unique ID with each new request. So the ID acts as a distinguisher between old and new requests from client. But this leads to storing these IDs on my server and do a lookup for each API call which I want to avoid. Other way is to increase the timeout duration. But I dont want to change this from 10 seconds. Something tells me that there are better solutions. I have posted this question in stackoverflow but I think its better suited here. **UPDATE:** I will make my problem even more explicit. The client is a webbrowser and the server is running nginx+django+mysql (standard stack). The user creates a folder in webbrowser. As a result I need to hit a server API. The API call responds back, thereby client knows API call was success. This is normal scenario. Sometimes though, server successfully completes the API request but the client-side (webbrowser) connection timesout before server can respond back. The client has no clue at this point. The user thinks the request was a fail & clicks again. This time it was a success but when the UI refreshes he sees 2 folders. I want to remedy this situation.


title: Learning PHP for an ASP.NET Developer

text: I am mostly developing on ASP.NET MVC and sometimes on ASP.NET WebForms. But when I hit a PHP web site, I always think that; > Should I learn PHP? Assuming answer here is yes, where would be the first place to start and where should I go from there?


title: USB software protection dongle for Java with an SDK which is cross-platform “for real”. Does it exist?

text: What I'd like to ask is if anybody knows about an hardware USB-dongle for software protection which offers a very complete out-of-the-box API support for cross-platform Java deployments. Its SDK should provide a jar (only one, not one different library per OS & bitness) ready to be added to one's project as a library.   * The jar should contain all the native stuff for the various OSes and bitnesses   * From the application's point of view, one should continue to write (api calls) once and run everywhere, without having to care where the end-user will run the software   * The provided jar should itself deal with loading the appropriate native library **Does such a thing exist?** With what I've tried so far, you have different APIs and compiled libraries for win32, linux32, win64, linux64, etc (or you even have to compile stuff yourself on the target machine), but hey, we're doing Java here, we don't know (and don't care) where the program will run! And we can't expect the end-user to be a software engineer, tweak (and break!) its linux server, link libraries, mess with gcc, litter the filesystem, etc... In general, Java support (in a transparent cross-platform fashion) is quite bad with the dongle SDKs I've evaluated so far (e.g. KeyLok and SecuTech's UniKey). I even purchased (no free evaluation kit available) SecureMetric SDKs&dongles (they should've been "soooo" straighforward to integrate -- according to marketing material :\ ) and they were the worst ever: SecureDongle X has no 64bit support and SecureDongle SD is not cross-platform at all. So, **has anyone out there been through this and found the ultimate Java security usb dongle for cross-platform deployments?** Note: software is low-volume, high-value; application is off-line (intranet with no internet access), so no online-activation alternatives and the like. \-- EDIT Tried out HASP dongles (used to be called "Aladdin"), and added them to the no-no list: here, too, there is no out-of-the-box (out-of-the-jar) support: e.g. end-linux-user has to manually put the .so library (the specific file for the appropriate bitness) in the right place on his filesystem, and export an env. variable accordingly. \-- EDIT 2 I really don't understand all the negativity and all the downvoting: is this a **taboo** topic? Is it so hard to understand that a freelance developer has to put food on the table everyday to feed its family and pay the bills at the end of the month? Please don't talk about "adding value" as a supplier, because that'd be off- topic. Furthermore I'm not in direct contact with end-customers, but there's an intermediate reselling entity: it's this entity I want to prevent selling copies of the software without sharing the revenue. \-- EDIT 3 I'd like to emphasize the fact that the question is looking for a **technical** answer, not one about opinions concerning business models, philosophical lucubrations on the concept of value, resellers' reliability, etc. I cannot change resellers, because this isn't a "general purpose" kind of sw, but a very vertical one and (for some reasons it's not worth explaining here) I _must_ go through them. I just need to prevent the _"we sold 2 copies, here's your share [bwahaha we sold 10]"_ scenario.


title: Loose Coupling Presenter to View in MVP

text: We work in a Java shop here and our web application uses an implementation of the MVP architectural pattern. Our manager comes from a .NET world, where he has been exposed to the MVVM design pattern. Our manager is advocating changes in our MVP implementation, including that the Presenters should be decoupled from (or loosely coupled to, depending on your interpretation) its Views via the Observer design pattern, in tradition with MVVM. I am more of the opinion that the Presenter and the View work together to achieve a common goal, and as such should be coupled. Among the arguments brought up in support of the change is the ability to unit test Presenters. If the Presenters only see the views as Observers, the argument goes, then they can be more easily unit tested. But presenters strongly coupled to their views are not necessarily difficult to test. If the View uses the Humble View paradigm, then it can be mocked. And finally, testability should be a symptom of good design, not a driver for the design. Another argument used by my manager in support of layering the Views and the Presenters is the supposed maturity of MVVM. As such, we should follow MVVM's teachings and adapt to its implementation of MVP. Correct me if I'm wrong, but MVVM imposes the (artificial) layering of views and presenters in order to facilitate its data bindings in controls. Can you please help us see the light here? Why should we use a decoupled model and pay the price for it? I'm not seeing the benefit. Occam's razor says I need arguments to use decoupling, and testing doesn't seem to be one of them. * * * **Clarification** : What I'm really looking for with this question are the arguments that can tip the balance in favor of a presenter that doesn't know about its view and shoots events in the aether or in favor of a presenter that knows about its view(s) through more direct coupling, like a humble view interface or directly to the class. Note that presenters can easily serve multiple views with both loose and tight coupling. The difference is in the interface that the presenter talks to: with loose coupling, the presenter talks to listener classes (or an event bus representative), whereas with tight coupling, the presenter talks to the view interface.


title: What's the best way to estimate story points in scrum?

text: I like the way planning poker works at the beginning of any project, letting you compare and discuss details of each story with one another. One of the issues I've noticed with this is that through time and as you gain more experience with the problem domain, you tend to vote less points for each story, i. e., a story that was worth a 5 or an 8 at the beginning of the project might now be worth a 3. How do you avoid or tackle this problem in the best possible way? Is there a better way to estimate? Should the stories always remain the same, or is this story points decrease ok?


title: How do programming language translators work?

text: I'm a programmer and I'm looking to play around with translating one language to another. Say C# to Lua. I'm curious as to how translating languages like that works? I would think there is some kind of standard methodology that I could perhaps look into for this or is it pretty raw?


title: Will it be a wrong idea to have <style> in <body>?

text:
In below code i placed internal style sheet with in body tag, instead of having in head. For Single-Page-Application I am considering to do this for styles that is only applicable to that page alone, rather than having separate pagespecific.css file. Is there a scenario where this has downside as i am not putting the same in head section?
                   Hello


title: In what meaningful ways does Erlang prevent race conditions in concurrent programming?

text: Reading about concurrency in Erlang, reminds me of the Akka concurrency toolkit. Both give you tools to prevent or limit race conditions. But you can send links to mutable data to other processes using the Akka toolkit, which is still unsafe. I see Akka as a useful tool, but it does not provide _protection_ against out-of-order access to objects and data leading to race- conditions, deadlock, and/or starvation. It doesn't prevent you from writing unsafe code the way Java or C# protects you from writing most of the kinds of memory leaks you can write in C++ (you can still create memory leaks in Java by tricking the garbage collector, but it is less of a problem than having to remember to free every byte you allocate). Does Erlang guarantee a degree of correctness, performance, and robustness in concurrent programming? I think operating systems provide protection when accessing system resources (assuming the driver writers did their jobs well). ACID databases provide protection for reads and updates. So it seems this is a solvable problem. Or would a generic safe solution would erase the performance gains that concurrency provides? Do other languages or toolkits provide the kind of concurrent safety that Erlang does (or doesn't)? This is a follow-up question to @Malfist's comment on @user1249's answer to What programming language generates fewest hard-to-find bugs?.


title: Separating entities in the business logic layer

text: I am going to start a project, which in the `BLL` would have something like:   * Jumper    * Map   * Record I need to keep track of all those, so I will make probably classes which hold them, e.g.:   * JumperList   * MapList   * RecordList First of all, is that a good practice to hold all the objects and is it good if I separate them like: `BLL.Entity` for the `Jumper`, `Map`, `Record` and `BLL.List` for `JumperList`, `MapList`, `RecordList` * * * Okay, I may have written it in a confusing way. What I meant was, is it good to make it like that:               BLL.Entity      - Jumper      - Map      - Record     BLL.List      - JumperList      - MapList      - RecordList


title: How to write a good mock for testing

text: I code in Python and I'm starting to use the Mock library. Although I've read through all of the documentation, something that I'm finding hard to understand is 'What makes a good mock'. For example, say I've got a function that makes a HTTP request:               def fetch_url(url, method=urlfetch.GET, data=''):         """Send a HTTP request"""              result = urlfetch.fetch(url=url, method=method, payload=data,                                 headers={'Access-Control-Allow-Origin': '*'})              return result.content      What would a good mock for this function look like? Furthermore, what would then be tested? From my understanding, the characteristics of a good test are that the test checks:   1. That the code isn't broken   2. That the code acts as expected   3. That the code returns the expected output if it returns something That said, what would be the characteristics of a good mock?


title: Does decoupling trump DRY in REST?

text: I am building a REST API to expose most of functionality of an existing Java API. Both APIs are for internal use within my organization; I do not have to design for external use. I have influence over both APIs but am implementing the REST one. The Java API will continue to be used for local applications (it's not being "retired"), but the REST API will be used for significant new development. Some of the Java API classes are simply data (beans with properties, getters, setters). And at least some of these make sense to transmit (in some form) over the REST API as data (which will be marshalled to XML or JSON). For example, a class that stores info about a server machine. I am faced with the following choice for these data classes: Do I...   1. expose the original Java class (or a subclass) directly in the REST API, or   2. make a new data transfer class (DTO pattern) specifically for the REST API? Either way I'll have REST data transfer classes; the question is whether to annotate the originals or create new ones (which may be near copies of the originals). There may be other choices, but I'll focus mainly on those two. Arguments for #1:   * DRY (don't repeat yourself)   * Faster to implement   * Easier to upgrade REST API Arguments for #2:   * What if REST API needs to be versioned separately from Java API? (This is somewhat likely.)   * What if there are significant changes to the Java data classes such as removal of properties, adding of behavior, or changes to class hierarchy? (This is also somewhat likely.) Bottom line is that it seems like a tradeoff between DRY (#1) and decoupling (#2). I'm leaning toward starting with #1 and then if problems arise moving to #2 later, following the agile guideline of not building what you can't prove you need. Is this a bad idea; should I start with #2 if I think I may end up there anyway? Are there major arguments/consequences missing from my lists?


title: Why don't modern libraries use OOP

text: I'm a beginner-level C++ programmer, but I understand the concepts of the language fairly well. When I began to learn external C++ libraries, like SDL, OpenGL (maybe something else too), to my great surprise I found out that they don't use C++ concepts at all. For example, neither SDL, nor OpenGL use classes or exceptions, preferring functions and error codes. In OpenGL I've seen functions like glVertex2f, which takes 2 float variables as an input and probably would be better as a template. Moreover, these libraries sometimes use marcos, while it seems to be a common agreement that using macroses is bad. All in all, they seem to be written more in C style, than in C++ style. But they are completely different incompaitable languages, aren't they? The question is: why modern libraries do not use the advantages of the language they are written in?


title: Should I Make my ASP.NET MVC N-tier?

text: I'm currently building a very small website, around 20 to 30 views, 10 controllers. I know MVC is only a design pattern and should only be the top presentation layer. I'm currently at a stage in development when you start question yourself and what you're doing. It feels like this small website don't 'need' the N-tier architecture because it's too small for that. But in the long run maybe it's worth it. Is it worth the time to migrate to N-Tier? IS there some level of abstraction when you **should** migrate to n-tier? Is there some magic point when the project grows too large? Or should it be done directly in the beginning of the development?


title: How did Strassen come up with his matrix multiplication method?

text: The famous Strassen's matrix multiplication algorithm is a real treat for us, as it reduces the time complexity from the traditional O(n^3) to O(n^2.8). But of all the resources I have gone through, even Cormen and Steven Skienna's book, they clearly do not state of how Strassen thought about it. What is the rationale of Strassen's matrix multiplication algorithm? Is this a lucky accident or is there something deeper in it?


title: Is is OK to use a non-primary key as the id in a rails resource?

text: I am getting ready to set up a resource for some new api calls to my rails application. I am planning on calling the resource devices ie               resources :devices      This is going to represent android mobile devices I know this will get me routes such as GET devices/:id In most cases :id would be an integer representing the primary key, and in the controller we would use :id as such:               GET devices/1     @device = Device.find(params[:id])      In this case I would like to use :id as the google_cloud_messaging_reg_id So I would like to have requests like this:               GET devices/some_long_gcm_id      and then in the controller , just us `params[:id]` to look up the device by the gcm registration id. This seem more natural, since the device will know it's gcm id rather than it's rails integer id. Are there any reasons I should avoid doing this? **\---------------------------------------------------------------------** **UPDATE:** **_My initial concern was that seeing a route (via rake routes) of /devices/:id or looking at the controller and seeing params[:id] would be confusing since most would assume :id was the integer primary key._** **After thinking about it some more, and reading Idan Arye's answer below, my current thinking is to create routes like shown below. This will get me routes (via rake routes) that look like this:**               GET    /api/v1/android_devices/:gcm_reg_key(.:format)       **which I think makes it somewhat clear that :gcm_reg_key may not be a primary key integer**. **And in the controller the parameter would be**               params[:gcm_reg_key]      **Again, I think this makes it somewhat clear that the param may not be an integer primary key (convention would be params[:id])** **Any other thoughts or suggestions are welcome.**               match '/android_devices/:gcm_reg_key', to: 'android_devices#show' , via: :get, as: 'android_device'     match '/android_devices/:gcm_reg_key', to: 'android_devices#update', via: :post, as: 'android_device_create'     match '/android_devices/:gcm_reg_key', to: 'android_devices#update', via: :patch, as: 'android_device_modify'     match '/android_devices/:gcm_reg_key', to: 'android_devices#destroy', via: :delete, as: 'android_device_destroy'     resources :android_devices , only: [:create, :index]


title: "Default approach" when creating a class from scratch: getters for everything, or limited access?

text: Until recently I always had getters (and sometimes setters but not always) for all the fields in my class. It was my 'default': very automatic and I never doubted it. However recently some discussions on this site made me realize maybe it's not the best approach. When you create a class, you often don't know exactly how it's going to be used in the future by other classes. So in that sense, it's good to have getters and setter for all of the fields in the class. So other classes could use it in the future any way they want. Allowing this flexibility doesn't require you to over engineer anything, only to provide getters. However some would say it's better to limit the access to a class, and only allow access to certain fields, while other fields stay completely private. **What is your 'default' approach when building a class from scratch?** Do you make getters for all the fields? Or do you always choose selectively which fields to expose through a getter and which to keep completely private?


title: Differentiating Standalone and Client-Server architectures

text: I was wondering what is the exact difference between a client-server and a standalone application, particularly in following scenario. For example lets say there is a win forms application running on a PC. So that the DBMS, SQL Server also installed on the same PC as it hosts the database too. Now this is clearly a standalone setup. Now if we introduce another PC and connect it to the first PC through a local area network and we want to run the application on this new PC too but it will use the same database which is in the first PC. Now is this application considered to be a standalone app or a thick client - server? EDIT: The application communicates with SQL server to access data and processing will happen locally. SQL server hosts the data and there are few stored procedures and views too.


title: Is it recommendable to program .net apps with C++

text: From what I can understand, C# is the defacto language when coding .NET apps. Is it recommendable to program .NET apps [let that be ASP.NET, WinPhone 7, GUI, etc] in C++? What are the pitfalls and the drawbacks if we choose to go down this path? Thanks for sharing.


title: How can I group commits in a version control system such as git

text: Instead of a one long flat commit history, why isn't there a hierarchy, so at the top level you might have pull requests, then you could go down a level and look at the commits in that PR. I realise that PR's are specific to github, but you get the idea. I just mean grouping a number of commits as a feature or bug-fix, for example. Surely it would make the commit history a lot easier to navigate. I'm sure there is an obvious answer this question, but I can't seem to find it.


title: What is better to return from the DataService: Status or Exceptions?

text: I have a MVVM app with DataServices (using mvvmlight). Right now, i'm using it like               var answer = await myDataService.PullList(categoryId);     if (answer.Status == Ok)         ObservableListOfItems.ReplaceWith(answer.Collection); // Show results     if (answer.Status == ConnectionLost)         // Handle connection lost state, show msg window or something     if (answer.Status == ParsingError)         // Handle parsing problem      where               async Task<MyAnswer> PullList(int id)     {         // Just a wrapper around HttpWebRequest, returns String.Empty if something happened         var resultString = await NetworkManager.GetAsync(UrlGenerator.GenerateCategoryRequest(id));                if (String.IsNullOrEmpty(resultString))             return new MyAnswer {Status = ConnectionLost);              try         {             var parsedResult = JsonConvert.DeserializeObject<PocoProducts>();                  return new MyAnswer {Status = Ok, Collection = parsedResult.List);         }         catch (Exception)         {              return new MyAnswer {Status = ParsingError; }         }       and               public class MyAnswer()     {         public List<Items> {get; set;}         public EnumStatuses Statuc {get; set;}     }          public enum EnumStatuses     {         Ok = 0,         ConnectionLost,         ParsingError     }      So I'm curious, did i just re-invented an exceptions, didn't i? PS: wrote a code just here, typos are possible, but general idea should be clear


title: Design for migrating to Multitenant architecture

text: We are in a process of redesigning our product code in such a way so as to support multitenancy. Currently the implementation is such that one product deployment caters to only one customer. Thus the application data corresponds to only one customer. This data (which is global wrt the application) is in the form of hashtables, lists and DB. Multiple threads make use of this data. The complete code is written in C. Now, since we want to migrate to multitenant architecture, the application code would need to store data for multiple customers. Since data stored in the application should be segregated wrt customers, I want to figure out what kind of architecture would best suit this requirement. I am thinking of adopting some OOP concepts here since I can use C++ also. But not sure how good this idea would be. Modularity is a prime advantage that OOP offers over C and hence thinking on those lines. But at the same time it is going to have a humongous on the current implementation requiring lots of changes. Hence, minimizing this is also important. What would be the best approach to attain all the objectives mentioned above? Is there any other way to do this?


title: Sync SQLite using only HTTP

text: I currently have a SQLite DB on my server that is needed by an android app I am currently developing. I download the DB to the android device using HTTP each time the contents are changed. Does anyone have any suggestions as to how to do this more efficient. ie. when the database gets large I don't want the android user to have to download the whole database again just because one record was added.


title: C++ is easy once you know PHP

text: I was at work last week and one of our "lead developers" (who said he has programmed C++ before, but I don't believe him) was talking about C++ and how our team of developers who only know PHP would not have a hard time at all learning C++. My first reaction was pure shock and then I laughed at his comment. He gave me a bad look and i asked if he was serious. Me personally I program a lot of C and C++ for mostly school projects and coding competitions. I don't think it's at all like PHP. I asked him why they were the same and he could not give me an answer (he doesn't know C++ at all I was thinking). Then I said "OK, yeah they both use curly braces and have conditional statements. But C++ you have to worry about memory management and all the easy to use built in functions in PHP, for example the array functions, are non-existent in C++. You actually have to know the algorithms behind them.". There are some great C++ libraries (STL, Boost) that will make your life easier but C++ is like PHP, come on! If you already know one language it will make it a little easier to learn another because you will already be good at boolean login (if this then that) or looping but there is just so much more to C++ than PHP. Like you have to compile the language and actually have to define what type of variable you are using and returning from functions. What do you think? EDIT: Actually what he said was "C++ is not much different than PHP"


title: Should sanity be a property of a programmer or a program?

text: I design and implement languages, that can range from object notations to markup languages. In many cases I have considered restrictions in favor of sanity (common knowledge), like in the case of control characters in identifiers. There are two consequences to consider before doing this:   * It takes extra computation   * It narrows liberty I'm interested to learn how developers think of decisions like this. As you may know Microsoft C# is very open on the contrary. If you really want to prefix your integer as Long with 'l' instead of 'L' and so risk other developers of confusing '1' and 'l', no problem. If you want to name your variables in non-latin script so they will contrast with C#'s latin keywords, no problem. Or if you want to distribute a string over multiple lines and so break a series of indentation, no problem. It is cheap to ensure consistency with restrictions and this makes it tempting to implement. But in the case of disallowing non-latin characters (concerning the second example), it means a discredit to Unicode, because one would not take full advantage of its capacity.