System testing - making sure the system conforms to specification. Validation?

After weeks of research I have nearly completed my thesis, yet I am unable to clear up my confusion contained in all previous threads here (and in many books): During system testing, we check the system function against system analysis (functional system design) - but that would fit to a definition of verification according to many books. But I follow ISO12207, which considers all testing as validation (making sure work product meets requirement for intended use). **How can I justify that unit testing or system testing is validation, even though when I check it against specification? Which fullfils the definiton of verification?** When testing that e.g. "Save button" works, is it validation? This picture shows my understanding of V&V, so different from many other sources, including ISTQB etc. ![This is my understanding of V&V - picture taken from the net](http://i.stack.imgur.com/7I040.gif) Essential problem I have is that a book using the same picture also states on another place that: > test activities in the area of validation are usability, alpha and beta > testing. For verification, testable system requirements are defined whose > correct implementation can be tested through system tests. Isn't that the opposite of what the picture says? Most books present the following picture, where validation is just making sure that customer needs are satisfied. Mind you that according to ISO, validation activity is testing. ![enter image description here](http://i.stack.imgur.com/0Enyb.gif)


how to properly credit authors of MIT license program

Although I have found similar questions on this site they were not what I was looking for. I have modified the source code of an MIT licensed project, and I have added new classes to it as well. Please correct me if I am wrong, but I think that it is legal to add my copyright notice above the license and remove the other one. But how should I attribute the contribution of the previous authors? Should I use a separate file? There are also some html files with no license or copyright notice in them which I also modified. Do I have to handle them differently? My question is different than this question in that I have also modified some of the files of the project I am extending.


NoSQL as file meta database

I am trying to implement a virtual file system structure in front of an object storage (Openstack). For availability reasons we initially chose Cassandra, however while designing file system data model, it looked like a tree structure similar to a relational model. Here is the dilemma for availability and partition tolerance we need NoSQL, but our data model is relational. The intended file system must be able to handle filtered search based on date, name etc. as fast as possible. So what path should i take? Stick to relational with some indexing mechanism backed by 3 rd tools like Apache Solr or dig deeper into NoSQL and find a suitable model and database satisfying the model? P.S: Currently from NoSQL Cassandra or MongoDB are choices proposed by my colleagues.


For user defined data, is it better to use a table of tables or dynamically created tables?

In an application that allows users to define their own tables and columns (details of that are not the focus of this question, but imagine a tool that lets users create their own forms and automatically handles storage, just to get the idea) is it better to store each table and column they create in a "table" table and a "column" table, or to dynamically create tables and columns? This "one table to rule them all" question is somewhat related, but in that case the "table" table is more clearly a bad idea. In this case, if you don't go that route then all your queries will have to be dynamically generated. Even though the argument "don't write yet another application designer tool for non-programmers, so you can keep adding features until you are basically having users develop in a crummy version of, say, Visual Studio, using your custom crummy language" is pretty reasonable, I've had a lot of projects with some version of the user defined tables requirement and this question is about _how_ to implement it. _Whether_ to implement it is another question, but probably too specific to particular applications to be a good question here.


Hiring Developers - Securing Source Code

I have a popular web-based app, and now suddenly my main developer has disappeared. Although I've found other great developers but I don't want to distribute the source code to everyone. Is there any way I can have them work on it while keeping the source code safe? Thanks


Design pattern for configuring objects

### Context In a Cocoa application I am developing, I need to load a data model that is defined in plist files. So, I have something like:               root (Array)     ---- item (Dictionary)     -------- name : "objects" (string)     -------- prefab : "object" (string)     -------- children : (Array)     ...     ---- item (Dictionary)     -------- name : "actions" (string)     -------- prefab : "action" (string)     -------- children : (Array)      So, the previous data model is loaded in the code to become an object representation using the language's primitives (arrays, dictionaries, strings, ... etc). No custom classes here. When I load that model, I know that an item in the table view can have children if the "prefab" key is set. When "add child" is pressed, I go to the prefabs (some other plist) and fetch that prefab's structure. e.g:               root (Array)     ---- item (Dictionary)     -------- name : "object" (string)     -------- parameters : (dictionary)     ------------ key "object_id" : value ""     ------------ key "x_position" : value 0     ...      As you can see, from the prefab in the first model, I can go to the second plist and fetch a structure that is defined in a plist. All loaded using a plist library, without any subclass creation whatsoever. There is a single prefab factory class that contains the prefab structures, and instantiates and initializes the object from the prefab with the configuration data. ### Problem I hope you see the grave danger in this design. The model contains both user generated data as well as configuration data!! _EEEEK!!!_ ... Sheesh, that's so bad... The problem haunted me when I started exporting the model after the user of the app interacted with the model though the UI. The exported model would contain the configuration data (such as the prefab key), which makes the exported data rigid and un-upgradable. If I were to change the prefab key in later version of the app, to something else, and you load an old model, that model will load the old configurations with it, in our case, referencing the old prefab. ## Question I need help find a proper design pattern that clicks with this data driven design that I have, by providing the configuration data from a separate file, and somehow, linking it with the data model.


What are typical responsibilities and achievements recorded on a CV, for a programming job?

I'm brushing up my CV/resume and trying to think of responsibilities and achievements from my past jobs and projects. It seems there aren't many, but probably there're some that I just don't identify as worth mentioning to a employer. What kind of responsibilities and achievements does your job include and which of them do you list on your CV/resume?


Javascript Use of Window Object through alternate means

Disregard your usual paradigms for a mere moment here.... I've seen a few sites who have used the following logic:               a=[];     b=a["sort"];     c=(b)();     c["alert"](1); // intended output: Alert displaying "1"...      supposedly to access (I'm guessing here) the primitive of the sort function to gain access to the window object, and then using that to access "alert"... I've tried executing this ages ago, and it worked a charm... But some twelve months or so later, I tried to run it again... and it's failed to execute, and given the following error:               TypeError: can't convert undefined to object      My question is, why wouldn't this logic work? It seems quite sound... Or is it? And yes, I know that I could just do `alert(1)` and be done with it, but I'm trying to get an understanding of alternate ways of coding... I work in IT security and I know certain people have ways of using XSS to find alternative ways to perform generic functions to compromise systems...


Where to start fixing a complex bug?

I'm trying to solve a complex bug in our codebase , but the problem seems to be coming from a lot of places to the point that i dont know what to change first . do you have any procedure or guidelines todo in such a situation ?


Capitalization convention in assembly?

Is there any convention on what to capitalize in (x86) assembly? For example, which one of these 'looks best'? (Or maybe none of them do?)               [BITS 32]     %define MACRO 1     MyLabel:         MOV EAX, 2      versus               [bits 32]     %define macro 1     MY_LABEL:         mov eax, 2      versus               [Bits 32]     %define MACRO 1     MyLabel:         mov EAX, 1      versus all the other possibilities?


How do I go about releasing my application as open source?

I have created my own forum on ASP.NET MVC 3 and Razor. It's a decent forum with, say, version 1 functionality. I plan to work on other features as well after my release of this version. 1) What site apart from Codeplex can I post my application on as open source? 2) What are the guidelines I need to follow before posting my application regarding my code etc? 3) I want my application to be used by others, so do I have to worry about anything like making a documentation about my code, etc?


Where's the unix philosophy community?

I am trying to implement my computer system following the unix philosophy i.e. I want to edit files, read/send email, store data and browse the web, all using tools that comply with the unix philosophy. Others have defined the unix philosophy better than I, but suffice it to say that I mean tools that "do one thing well", work with unix pipes and can be easily scripted. I'm looking at tools like ed, edbrowser, nmh and uzbl. However, I wonder where like-minded people on the internet 'hang out' (e.g. a wiki or forum)? Is there any internet community, or linux distribution community, that has a large group of people who also wish to implement all their work through unix philosophy tools? Any suggestions would be much appreciated.


How to adopt agile methodology for developing firmware/embedded-systems-software?

I've always wondered how to apply agile methods really are in large complex embedded system software (100+ engineers). Firmware development has some unique characteristics that make it difficult to do agile (ie. Hardware is not available until late in the dev cycle; Once product is released, can't easily update firmware; etc...) The norm in this kind of development is thick documentation and grueling peer reviews. You can't get a simple code fix like renaming a variable without 2-3 signatures. (I exaggerate a little but this is typical. Additionally, a lot of people do take shortcuts and the Project Managers even approve them especially in the face of hard market deadlines.) I would like to hear any tips or guidelines on how to adopt agile methodology for firmware development projects.


Is NoSQL a good fit for a graphing app, and how can I compare different NoSql Servers?

I am traditionally a MsSQL or MySQL developer - I have been prototyping a new application that involves storing data from many targets. I have seen that the app appears to get slow after scaling to 10k targets after inputting around 300k results for each (64 bit ints) - especially once I start trying to average and/or graph a few targets at once. Once the app is deployed I will need to add around 1k targets a month and store one data point from each for each and every minute for approx 2 years. I have never used NoSql, but from reading, it sounds like a good fit - create a document for each target and keep adding fields for each target. So, I was just wondering, is NoSQL the way to go for this project or should I be sticking with traditional SQL - and/or can anyone offer any advice? And the second part - If NoSQL is a solution can anyone recommend a fair comparison as I am getting lost in biased reviews that seem to say each solution is superior!?


Offensive programming / coding

Last time I heard about "offensive programming/coding". I am not sure what it exactly mean. Why it is better, from defensive programming? Can someone give me some examples or answers?


What industry/programming is right for a careful coder?

My approach to programming is very deliberative. I spend a lot of time planning and designing before I code, even for the most basic tasks. I always try to make my code very simple, design everything very elegantly, and always to leave space for flexible changes later on. Some might say I think too much about what else could happen. I wonder, what industry and what tasks would be best suited to someone who works the way I do? Are there jobs out there that require high precision without a lot of schedule pressure, and if so, where should one look for them?


Is .NET WCF worth the effort?

Maybe it's me, but I've never encountered nearly as many problems, annoying challenges, indirect error messages and general frustrations with any other technology as I have with WCF. What are the ACTUAL benefits? Not the MS Press Release benefits of 'a unified architecture for something something that's not going to work anyway.' And are those benefits worth the annoying frustrations? I'm normally a big MS fanboy over here, but I just can't get behind WCF.


Why do we write mock objects when writing unit test cases?

We are currently writing unit test cases in our project . The implementations for database methods exist and is working fine . In this case why do we need to write mock objects ? Is there any specific reason ? Why can't I test the DAO implemntation directly?


Does unit testing lead to premature generalization (specifically in the context of C++)?

### Preliminary notes I'll not go into the distinction of the different kinds of test there are, there are already a few questions on these sites regarding that. I'll take what's there and that says: _unit testing in the sense of "testing the smallest isolatable unit of an application"_ from which this question actually derives ### The isolation problem What is _the smallest isolatable unit_ of a program. Well, as I see it, it (highly?) depends on what language you are coding in. Micheal Feathers talks about the concept of a _seam_ : [WEwLC, p31] > A seam is a place where you can alter behavior in your program without > editing in that place. And without going into the details, I understand a seam -- in the context of unit testing -- to be a place in a program where your "test" can interface with your "unit". ### Examples Unit test -- especially in C++ -- require from the code under test to add _more seams_ that would be strictly called for for a given problem. Example:   * Adding a virtual interface where non-virtual implementation would have been sufficient   * Splitting -- generalizing(?) -- a (smallish) class further "just" to facilitate adding a test.   * Splitting a single-executable project into seemingly "independent" libs, "just" to facilitate compiling them independently for the tests. ### The question I'll try a few versions that hopefully ask about the same point:   * Is the way that Unit Tests require one to structure an application's code "only" beneficial for the unit tests or is it actually beneficial to the applications structure.   * Is the code generalization that is needed to make it unit-testable useful for anything _but_ the unit tests?   * Does adding unit tests force one to generalize unnecessarily?    * Is the shape unit tests force on code "always" also a good shape for the code in general as seen from the problem domain? I remember a rule of thumb that said don't generalize until you need to / until there's a second place that uses the code. With Unit Tests, there's _always_ a second place that uses the code -- namely the unit test. So is this reason enough to generalize?


options for data analytics for time series store

I'm building an Internet of Things solution that has a number of real time feeds. I need to make a couple of design decisions with regards to the data store and reporting and looking for input. I have two deployment models, local where a small Linux server captures multiple streams usually a new data point each second and record length is small, basically a fixed format message of about 20 bytes. The other model is cloud based where the transaction rate will be much higher, up to 1000 data points a second. Concentrating on the local model first, my prototype uses SQLite under MONO and works fine in a traditional RDMS manner. However I'm aware that RDBMS isn't optimal for time series systems and possibly a NOSQL solution might be better. I'm having a re-think on the SQL approach due to my real time analytics requirement. I want to be able to easily report on SUM, COUNT, AVERAGE, MEAN, SD, MIN, MAX on potentially each of the time series datasets, basically have the system recalculate these for each new data point. Although I haven't done any performance testing, I can see if I have a year or more data the dataset size is going to be pretty large (20 bytes / second over a year is 600MB and I could have up to 30 different time series datasets) and won't be great for real time calculation of averages etc. in normal SQL. I also want to keep the size / cost of the server low so won't be able to add gobs of CPU or memory but disk space should be OK. The other option I have is that my system can store the delta (changes) to the real time feeds instead of the regular data point, which will save about 80% of the disk space. However I don't know of an easy way to do set calculations like running averages if I am storing deltas (as far as I know not possible with standard SQL statements but I could be wrong). Given my use case above I have 3 questions: 1) Should I seriously consider a NOSQL data store? Do you have any suggestions on the advantages of a NOSQL store for this model? 2) How I can best do real time set calculations like average without a lot of complexity or hardware? I have platform options of either MONO or NODE on Linux or Windows. 3) How to do efficient real time set calculations (especially averages which will be the majority of calculations) on either SQLite or a NOSQL DB when I'm storing deltas?


Abstract exception super type

If throwing `System.Exception` is considered so bad, why wasn't `Exception` made `abstract` in the first place? That way, it would not be possible to call:               throw new Exception("Error occurred.");      This would enforce using derived exceptions to provide more details about the error that occurred. For example, when I want to provide a custom exception hierarchy for a library, I usually declare an abstract base class for my exceptions:               public abstract class CustomExceptionBase : Exception     {         /* some stuff here */     }      And then some derived exception with a more specific purpose:               public class DerivedCustomException : CustomExceptionBase     {         /* some more specific stuff here */     }      Then when calling any library method, one could have this generic try/catch block to directly catch any error coming from the library:               try     {         /* library calls here */     }     catch (CustomExceptionBase ex)     {         /* exception handling */     }      Is this a good practice? Would it be good if `Exception` was made abstract? EDIT : My point here is that even if an exception class is marked `abstract`, you can still catch it in a catch-all block. Making it abstract is only a way to forbid programmers to throw a "super-wide" exception. Usually, when you voluntarily throw an exception, you should know what type it is and why it happened. Thus enforcing to throw a more specific exception type.


Software license restricting commercial usage like CC BY-NC-SA

I want to distribute my software under license like Creative Commons Attribution - Non commercial - Share Alike license, i.e.   * Redistribution of source code and binaries is freely.   * Modified version of program have to be distributed under the same license. Attribution to original project should be supplied to.   * Restrict any kind of commercial usage. However CC does not recommend to use their licenses for software. Is there this kind of software license I could apply? Better if public license, but as far as I know US laws says that only EULA could restrict usage of received copy?


Benefits of using config files over making many small classes?

My friend and I are building a mobile game and ran into the following design problem: We will have many different types of units all with different stats and abilities. However, all unit types should have a few commonalities (for example, they would all have a totalhealth attribute). We were trying to decide what the best way of representing these units would be. My friend suggested simply making a new class for each unit type. I feel that having hundreds of different classes feels wrong, but can't quite figure out what's so bad about it. My alternative is to put the unit type information into either configuration files or a database (which will also solve the issue of enforcing every unit type to have a few common attributes with a schema). And then have a master unit class to instantiate types of units from the db. What is the proper way of architecturing this?


Pitfalls of combining dependant traits and exceptions in same file as interface in php

What are the potential pitfalls of combining related class like objects (interfaces, traits, custom exceptions) in the same source file? For code reuse and only loading what I need I always separate out full class's into separate files. But interfaces, traits, and extended exceptions don't seem to need that same level of granularity. I have been trained that all classes and class like objects (interfaces, extended exceptions, etc.) should be given their own source files. But now I am starting to work with traits and after getting advice about combining traits and interfaces, to have the ability to have something along the lines of multiple inheritance, I am combining the interface and the trait in the same source file. That way the only way to access traits is to implement the corresponding interface. Once the class calls the autoloader to get the source for the interface it also loads the trait. Not all classes that implement the interface will use the trait for functionality, but most will, and those that don't will just not _use_ the trait. I also will use extended Exceptions for an interface along the lines of PDOException. These are exceptions only thrown by classes that extend or implement a class. So now my **Stackable.php** interface file looks like:               interface Stackable{       public function add($content);       public function _registerParent($parent);       public function _checkLoop($child);     }          trait StackableTrait{       private $containter_contents = array();       private $container_parent = NULL;            public function add($content){         if(is_a($content, "Stackable")){            $content->_registerParent($this); //prevents adding twice and creating loops.         }elseif(!is_string($content)){            $this->_checkLoop($content);         }         return $this->container_contents[] = $content;       }       public function _registerParent($parent){         if(empty($this->container_parent)){           $this->container_parent = $parent;           return;         }         throw new StackableException("Object has already been added to a parent");       }       public function _checkLoop($child){         if(in_array($child,$this->container_contents,TRUE){           throw new StackableException("Object has already been added to a parent");         }elseif(!empty($this->container_parent)){           $this->container_parent->_checkLoop($child);         }       }     }          class StackableException extends Exception{}      As you can see all of the contents of the file are interrelated, any class that wants to use the StackableTrait will need to also implement the interface so the class checking in the trait functions will work. And only things using _StackableTrait_ or implementing _Stackable_ will have access to throw _StackableException_.


What kind of transform is this?

I have a function that linearly "remaps" a value from a given interval to an other interval? The function remaps a value from a given interval [oldMin, oldMax] to another interval [newMin, newMax] using this formula:               newVal = newMin + (newMax - newMin) * (oldVal - oldMin) / (oldMax - oldMin)      If it helps identify what type of transform it is, the above formula is just a reformulation of the following equation. All I did was re-arrange the terms to express `newVal` on the left hand side of the equation so it is a function of all the other parameters: ![enter image description here](http://i.stack.imgur.com/wukZX.png) Is there a standard name for the remapping transformation?


What is the advantage of a programmers VM apart from portability

I can understand the benefits of Java running on a JVM. Portability. Nice simple reason. But I have always been puzzled as to why Microsoft brought out their own version of a JVM - .NET. C# is supposed to be a fine language (haven't used myself) but could Microsoft have launched product to use native. ie to generate an exe? My colleague is learning F#. The reason it has to be a language which runs on .NET is because the Microsoft Lync API which will be used is only available on .NET. ie there is no C API for Lync. A cynical view may be that the reason is vendor lockin. F# will only run on a Microsoft platform (or C# for that matter) and so program is locked in. But maybe I am missing some other benefit of a VM platform?


Mechanics of reasoning during programming interviews

This is not the usual "I don't want to write code during an interview", in this question the assumption is that   * I need to write code during an interview (think about the level of rewriting the quicksort or mergesort from scratch)   * I know how the algorithm work or I have a basic idea of how I should start working from there, i.e. I don't remember the algorithm by heart I noticed that even on a whiteboard, I **always** end up writing bugged code or code that doesn't compile. If there's a typo, whatever I usually live with that.. but when there's a crash due to some uncaught particular case I end up losing confidence in my skills. I realize that perhaps interviewers might want to look at how I write code and/or how I solve problems rather than proof-compiling my whiteboard code, but I'd like to ask **how should I approach the above problem in mental terms, i.e. what mental steps should I follow when writing code for an interview with the two bullet points above**. There must be a unique and agreed series of steps I should follow to avoid getting stuck/caught into particular exception cases (limit cases) that might end up wasting my time and my energies rather than focusing on the overall algorithm for the general case. I hope I made my point clear


Can I, as author and copyright holder, relicense my code under a more liberal license after it has been published under a more restrictive license?

Say, for example I published my code under GPL. A month after release, I decide evil corporations (`*`cough`*`) are allowed to use my code after all, because it's so brilliant and bug-free. Can I just relicense my own code, or have I locked myself out of the right to do so?


Synthetic database records

Assume we are getting some statistics from a customer which we analyse and we send our comments to the customer. Now, the customer tells us that the statistic they computed between January and March are based on a wrong methodology and sends us corrected series. We want perform analysis with the wrong and with the correct set of data, which are huge and only differ from January to March, so that we want to avoid data duplication. Therefore, we need something like _synthetic database records_ implementing the following logic:               synthetic[1] = wrong_data     synthetic[2] = correct_data between Januar and March, wrong_data otherwise      With this, we can easily perform our analyses on synthetic records. Should such synthetic records be implemented in the application logic or on the side of the database? What are common pitfalls of such an implementation?


Serialized values or separate table, which is more efficient?

I have a Rails model `email_condition_string` with a `word` column in it. Now I have another model called `request_creation_email_config` with the following columns   1. admin_filter_group:references    2. vendor_service:references    3. email_condition_string:references `email_condition_string` has many `request_creation_email_config` and `request_creation_email_config` belongs to `email_condition_string`. Instead of this model a colleague of mine is suggesting that storing the word inside the same model as comma separated values is more efficient than storing it as a separate model. Is that all right?


How do I test a file reader?

I am working on a project with a few file formats. Some formats are specified by .xsds, others by documentation on their respective websites, and some are custom in-house formats that have no documentation. Mwahahahaha. **What's the problem?** I would like to test my file readers, but I'm not entirely sure how to go about doing this. The flow of the application is as such:               file.___  ===> read by FileReader.java ===> which creates a Model object      where the `FileReader` interface is               public interface FileReader {         public Model read(String filename);     }      The `Model` has a number of attributes that are populated when the file is read. It looks something like               public class Model {         List<String> as;         List<String> bs;         boolean isAPain = true;         // ...     }      **What have I tried?** My only idea was to create file "generators" for each file format. These generators are basically builders which take in a few variables (eg. number of comments to generate in a file), and output a sample file which I then read in and compare the resulting `Model` with the variables I used to initially generate the file. This has a few problems, though:   * The files that it generates don't _look_ like real files. The generator is in no way aware of context.   * It's hard to recognize if the generator has generated for edge cases since I'm the one manually setting the variables. This method is barely better than me creating a dozen sample files. Are there any better ways to do this? EDIT: Changed unit to integration since that's what I actually mean. EDIT2: Here is an example of the edge cases I mentioned. Each file represents a graph made up of vertices and edges. These vertices and edges can be attached in different ways, so:               v1 -- e1 --> v2 <-- e2 -- v3      is different from               v1 -- e1 --> v2 -- e2 --> v3      in that the direction of the edges matter. I'm not sure if this is in the scope of the question, but it's hard to think up all of the pertinent edge cases when I manually set the number of vertices, number of edges, and just generate the connections randomly.


Is heap fragmentation a problem in bare-metal arm with g++?

I am converting a project from C to mixed C/C++. It is going quite nice, and the new features are really lightening the work. The platform is an ARM SAM4, compiler is arm-none-eabi-g++. This is not a safety-related equipment, but still could be left running for months and is not supposed to restart sporadically. The original C project has managed quite nicely to solve problems without a single `malloc` call, allocating statically all needed data. For example, arrays with unknown size are allocated to the maximum expected size. Now I am considering can I get away with using `new`. For example, all STL containers hold their content in the heap. Just adding a new element to a `vector` can cause de-allocation of a whole region of the heap and allocation of another one. Will there be fragmentation issues? Related: What is memory fragmentation?


File system layout for multiple build targets

I am seeking some ideas for how to build and install software with some parameters. These including target OS, target platform CPU details, debugging variant, etc. Some parts of the install are shared, such as documentation and many platform independent files, others are not, such as 64 and 32 bit libraries when these are separated and not together in a multi-arch library. On big networked platforms one often has multiple computers sharing some large server space, so there is actually cause to have even Windows and Unix binaries on the same disk. My product has already fixed an install philosophy of $INSTALL_ROOT/genericname/version/ so that multiple versions can coexist. The question is: how to manage the layout of all the other stuff?


Container/Item pattern without `friend`

I have a class `Container` containing objects of type `Item`. They are different classes, and especially they have no common base class (e.g. a `Container` does not itself have a `Container`).:               class Container     {         public ICollection<Item> Items { get { /* ... */ } }     }          class Item     {         public Container Container { get { /* ... */ } }     }      I’d like to enforce that each `Item` needs to have exactly one `Container`, and I’d like to make sure there never can be an inconsistent situation such that e.g. `i.Container.Items.Contains(i)` returns false. This could be done by e.g. adding a method `Container.AddItem` that sets the `Item`’s `Container` property accordingly or by having a `Item.SetContainer` method that takes care of `Container.Items`. Example:               class Item     {         private Container container;         public Container Container         {            get            {               return container;            }            set            {                if (container != null)                    container.Items.Remove(this);                container = value;                if (value != null)                    value.Items.Add(this);            }         }     }      This could be easily done with the concept of a “friend”, but I’m using C# that does not have friends, and thus this example code won’t compile. However, it of course would compile if `Container.Items` had a public setter, but this again would allow inconsistencies: A “user” of the classes would need to know not to use the setter of `Container.Items`, but `Item.Container` instead. After searching for quite some time, I feel there is no way to enforce this restriction that seems to be so trivial. (Using `internal` might be a work- around, but no solution.) Is there an elegant way to enforce this one-container-per-item rule without the concept of “friend”?


How will the new development of Java influence its interoperability with languages like Scala and Clojure?

As far as I understand, both Scala and Clojure have been designed as new languages that   1. depend on the JVM, and   2. easily integrate with Java code, in the sense that they allow to use Java classes inside Scala and Clojure code. Starting with Java 8 (and maybe even more strongly with subsequent versions of Java), there will be changes in the semantics of the Java language. I wanted to ask how these changes will impact the interoperability between Java and Scala / Clojure and what the consequences will be. For example, since lambdas in Java 8 are not objects (see e.g. here), Scala and Clojure might have to deal with Java values that are not objects. Would this be a problem? I can think of the following scenarios:   1. The Scala or Clojure language will be extended to adapt to the new Java semantics (to handle the new non-object values) and support interoperability with Java.   2. The Scala or Clojure language will **not** be extended. This would only be possible if the new Java features like function values can be mapped to existing concepts. E.g., in Scala even a function is an object, so I guess Java functions would again be wrapped into some kind of objects when they become visible to Scala.   3. The Scala or Clojure language will continue to support interoperability up to Java 6 or 7, without following latest Java's development. This would require that older versions of Java be still supported (at least by OpenJDK or another project), so that these languages can be based on a more conservative / stable branch of Java. Summarizing: can we expect that the future development of Java will have an impact on languages like Scala and Clojure to maintain interoperability with Java? Is there some (link to) ongoing discussion on this topic already? **Note** I can imagine that Scala, Clojure, and other JVM-based languages won't have any major problems updating their implementation to newer versions of the JVM (and that new JVM features will make this implementation even easier). My question focuses on features of Java as a language and whether / how other JVM-language will be able to "see" / use these new features, not on whether JVM-based languages will run on the latest JVM's.


Javascript function should call python logic in django web development without additional triiger

I have been trying to solve this problem for sometime now. This is regarding django web development. I have an **HTML page** which has a **Javascript** function to upload an image file from the users local computer. After that file has been uploaded on to the HTML template, I want to use the uploaded image file for further processing. I am calling my python logic from `views.py` for processing the image before rendering the processed information on to another HTML page. My problem is that I want my `upload function()` to call my python logic.(There should be no additional trigger to call the python logic. i.e `somefunction`() within the `upload function()` which can directly call my python logic without having to use any button click or anything else.) Can I somehow call the Python logic from javascript function (the one which uploads the image)? or should I save the uploaded file to my local computer and use its path to process the image information? I googled and found that both of these are challenging tasks. There is no direct method to do it since one is client side scripting while the other is server side. Also, javascript does not have input output facilities (for writing/saving the uploaded image to local disk that too without a trigger). What should be done in such a case? Should I write my upload function also in python then?(I don't want that to happen). Please help. Thanks in advance :)


Is there a better way to handle data abstraction in this example?

I'm building an application that retrieves Sharepoint list data via a web service `SPlists.Lists`. To create an instance of the web service, I have the following class:                  class SharepointServiceCreator        {                  public SPlists.Lists createService()             {                 listsService.Url = "http://wss/sites/SPLists/_vti_bin/lists.asmx";                 listsService.Credentials = System.Net.CredentialCache.DefaultCredentials;                 SPlists.Lists listsService=new SPlists.Lists();             }             }      I'm concerned that this isn't good OOP abstraction, though, because in order to create this service elsewhere in my application, I would need the following code:               class someClass     {      public void someMethod()      {       SharepointServiceCreator s=new SharepointServiceCreator()       SPlists.Lists listService=s.createService()      }     }      Having to use declare the instance of `listService` in `someMethod` as type `SPlists.Lists` seems wrong, because it means that `someClass` needs to know about how `SharepointServiceCreator` is implemented. Or is this ok?


What branch of computing involves object recognition in images?

Several applications of this is text recognition (OCR), face recognition (biometrics), camera guided missiles (targetting systems). Each involves analyzing images and making out some object of interest. **Is there a term that describes this branch of programming?**


Working with vectors and transformations

I am going to write an graphical 2D application that allows user to create polygons and transform them through transformation such as rotation an so on. I was hoping someone can give pro and cons arguments for the different choices I got in my mind. (Its all in Java btw!) a). Represent vectors by filling matrices with 'real' numbers. This means making a matrix datas tructure that supports multiplication, transposing etc b). Make a own vector class, such that I can make a matrix class that support those vectors.


Arithmetic coding issue

Since a few days I am fighting my way through implementing arithmetic coding. I found a really great source of information which made me understand how it should work. Long story short, it implements arithmetic coding on integers using two registers: HIGH and LOW. Those register store a fraction, ex.               HIGH = 98765 //means 0.98765(9)     LOW = 91234 // means 0.91234(0)      Then comes magic, when the most significant numbers match (in this case it would be 9s) they are printed out. It's all clear to me. However, when we take the following example                                        HIGH    LOW    RANGE   CUMULATIVE OUTPUT          Initial state           99999  00000   100000     Encode B (0.2-0.3)      29999  20000     Shift out 2             99999  00000   100000    .2     Encode I (0.5-0.6)      59999  50000             .2     Shift out 5             99999  00000   100000    .25     Encode L (0.6-0.8)      79999  60000   20000     .25 //here starts problems     Encode L (0.6-0.8)      75999  72000             .25 //how possible?     Shift out 7             59999  20000   40000     .257     Encode SPACE (0.0-0.1)  23999  20000             .257     Shift out 2             39999  00000   40000     .2572     Encode G (0.4-0.5)      19999  16000             .2572     Shift out 1             99999  60000   40000     .25721     Encode A (0.1-0.2)      67999  64000             .25721     Shift out 6             79999  40000   40000     .257216     Encode T (0.9-1.0)      79999  76000             .257216     Shift out 7             99999  60000   40000     .2572167     Encode E (0.3-0.4)      75999  72000             .2572167     Shift out 7             59999  20000   40000     .25721677     Encode S (0.8-0.9)      55999  52000             .25721677     Shift out 5             59999  20000             .257216775     Shift out 2                                      .2572167752     Shift out 0                                      .25721677520      I really don't know how the marked lines are achieved on computers, on paper it's easy, since:               /*          range, HIGH, LOw - integer         symbol->high, symbol->low - real     */     HIGH = HIGH - (range - symbol->high*range)     LOW = LOW + range*symbol->low      But on computers? The real-number inaccuracy comes in and my intervals are much different.               [0; 99999)  100000  b   [0.2; 0.3)     [20000; 29999)  100000  ===> 2     [0; 99999)  100000  i   [0.5; 0.6)     [50000; 59998)  100000  ===> 5 //inaccuracy     [0; 99989)  99990   l   [0.6; 0.8)     [59993; 79990)  19998   l   [0.6; 0.8)     [71991; 75990)  19998   ===> 7     [19910; 59909)  40000       [0; 0.1)     [19910; 23908)  3999    g   [0.4; 0.5)     [21509; 21908)  3999    ===> 2     [15090; 19089)  3999    ===> 1     [50900; 90899)  40000   a   [0.1; 0.2)     [54900; 58898)  40000   ===> 5     [49000; 88989)  39990   t   [0.9; 1)     [84991; 88988)  39990   ===> 8     [49910; 89889)  39980   e   [0.3; 0.4)     [61904; 65900)  39980   ===> 6     [19040; 59009)  39970   s   [0.8; 0.9)     [51016; 55011)  39970   ===> 5     zakodowano: 257215865      I would appreciate any help.


Preventing possible burnout in a junior dev, or perhaps I'm not doing enough?

I'm a software developer with 5 years experience over 3 companies. Within the last year a junior (brand new to the industry) has started at my current employer. I believe he is an excellent developer, who always delivers and is skilled as solving complex problems. However I'm slightly concerned that he is possibly applying himself _too much_ for the following reasons:   * He begins work approximately 2 hours before most (and is expected)   * In his free time he has developed an application that was clearly **months** worth of work that is specific to our employer I and the team are completely greatful for all he is doing, and is clearly an asset to our team. However I'm worried that this is **_not sustainable_**. I can almost see that he has the same enthusiasm that I had when I began coding for work, however over the years I've realised that extra curricular work not only doesn't progress your career, but eats into your all important free time. The question I'm asking is: **Should I advise him to take things a bit more slowly? Or perhaps I need to learn from him and do more for my employer out of hours?**


How should I specify locations where clients can resolve authorization problems in a REST API?

I'm working through an API design where a user's authentication will be verified by the presence of a valid forms authentication ticket in a session cookie. However, there are additional levels of access that can exist for particular resource URLs. When attempting to access those, it seems like returning a 401 would be the most appropriate response. However, generally we handle 401s by redirecting to a sign-in page. That would not be a valid course of action for clients on certain resources, where there's an additional step required (e.g., email validation, signing up for a particular role). **Is there a standard way to communicate where to go next when responding with a 401?** I'm tempted to include something in the Location header, but that seems only appropriate for 302s after a POST. I'm also reluctant to use URLs to specify where to go, since clients may not be restricted to browsers. **Any good examples or standards docs I can refer to on this?**


How do I perform some actions in my Java program whenever a particular network interface comes up?

I wanted to perform some actions in my Java program whenever a particular interface comes up (network interface ppp0 e.g.). However I figured out it was way too clumsy to keep polling the interface to verify its status. After finding out `if-up.local` file in Linux, now I can run a bash script whenever the interface comes up. Works fine, however considering my running Java program, how can I make this script interact with my Java code? I am considering the following options:   1. Write a listening socket and from this script send message to this Java socket.   2. Invoke a C program, and through JNI run my java code. I am looking for intuitive and less resource intensive approach.


Unit testing vs Integration Testing

What is the difference between unit testing and integration testing when it come to web development (where 90-95% of the code relies on a database)? One thing I here all the time is that unit testing should not deal with databases and integration testing should. The issue I have with this is that to me that means the only difference between unit testing and integration testing is the data source and if that is the case, you are testing the same functionality. If the functionality that is tested is the same, why even bother with unit testing and always test against a database?


Approach to submitting forms from a multi-platform native/hybrid app with unstable internet connection

Sorry for the long question, but I want to be sure to define my problem clearly. For my thesis (in aerospace engineering, so not much programming experience) I want to develop a (prototype) mobile application which will facilitate the reporting of safety related events in African aviation. Although the content of my thesis focuses on the more technical and sociological aspects of safety (management) I decided to include some practical design for demonstrative purposes. Considering the criteria I will present below, my first guess is to develop a mobile app using PhoneGap or something similar. But life can't be that simple, so I'll need more than just this single framework. My question to you is, what a convenient and effective approach would be to satisfy the following description? Quite simply this is what I envision (in layman's terms):   * A user (pilot, ground crew, etc.) experiences or notices a safety related event   * The user fills out a form (Air Safety Report) about the event on his/her phone   * Additional information (pictures/videos) are attached   * Once a stable internet connection comes available (we're in Africa) the report/form is submitted to a server. Important considerations here are:   * The limited availability of internet -> I need a native/self-contained solution/app so the reporter does not have wait with reporting, and which stores data and submits once possible.   * I don't want - nor should - exclude potential users (for multiple reasons) -> The app should be available on as many platforms as possible (especially BlackBerry and Symbian are still very popular in Africa!).   * I am doing this as a form of development aid and want it to be cheaply available -> open source preferably. Altogether, the following criteria can be defined: It should   * be open-source   * support multiple-platforms   * allow file attachments (pictures mainly)   * be self contained/native   * support/allow web services   * provide geolocation and date/time support (automate report whereabouts)   * allow camera use for direct attachment (optional, but preferable)   * identify an internet connection and submit the data once possible   * store data until submission Besides PhoneGap (which doesn't support image library browsing? -> apparently is possible, see supporting documentation), I have considered the following frameworks:   * Mobl (not tested for all major platforms, no date/time support?)   * QuickConnect (does not support BlackBerry and Symbian)   * Rhodes (meets my requirements as for as I can see)   * Appspresso (doesn't support BB and Symbian, no date picker) I've read the following thread on stackoverflow:   * how can I send the form data from a native jquery mobile app to a remote server?   * Phonegap - Choose Image From Gallery


How do you update live web sites with code changes?

I know this is a very basic question. If someone could humor me and tell me how they would handle this, I'd be greatful. I decided to post this because I am about to install SynchToy to remedy the issue below, and I feel a bit unprofessional using a "Toy" but I can't think of a better way. Many times I find when I am in this situation, I am missing some painfully obvious way to do things - this comes from being the only developer in the company.   * ASP.NET web application developed on my computer at work   * Solution has 2 projects:      * Website (files)     * WebsiteLib (C#/dll)   * Using a Git repository   * Deployed on a GoGrid 2008R2 web server Deployment:   1. Make code changes.   2. Push to Git.   3. Remote desktop to server.   4. Pull from Git.   5. Overwrite the live files by dragging/dropping with windows explorer. In Step 5 I delete all the files from the website root.. this can't be a good thing to do. That's why I am about to install SynchToy... **UPDATE:** THANKS for all the useful responses. I can't pick which one to mark answer - between using a web deployment - it looks like I have several useful suggesitons:   1. Web Project = whole site packaged into a single DLL - downside for me I can't push simple updates - being a lone developer in a company of 50, this remains something that is simpler at times.   2. Pulling straight from SCM into web root of site - i originally didn't do this out of fear that my SCM hidden directory might end up being exposed, but the answers here helped me get over that (although i still don't like having one more thing to worry about forgetting to make sure is still true over time)   3. Using a web farm, and systematically deploying to nodes - this is the ideal solution for zero downtime, which is actually something I care about since the site is essentially a real time revenue source for my company - i might have a hard time convincing them to double the cost of the servers though. \--> finally, the re-enforcement of the basic principal that there needs to be a single click deployment for the site OR ELSE THERE SOMETHING WRONG is probably the most useful thing I got out of the answers. **UPDATE 2:** I thought I come back to this and update with the actual solution that's been in place for many months now and is working perfectly (for my single web server solution). The process I use is:   1. Make code changes   2. Push to Git   3. Remote desktop to server   4. Pull from Git   5. Run the following batch script: cd C:\Users\Administrator %systemroot%\system32\inetsrv\appcmd.exe stop site "/site.name:Default Web Site" robocopy Documents\code\da\1\work\Tree\LendingTreeWebSite1 c:\inetpub\wwwroot /E /XF connectionsconfig Web.config %systemroot%\system32\inetsrv\appcmd.exe start site "/site.name:Default Web Site" As you can see this brings the site down, uses robocopy to intelligently copy the files that have changed then brings the site back up. It typically runs in less than 2 seconds. Since peak traffic on this site is about 2 requests per second, missing 4 requests per site update is acceptable. Sine I've gotten more proficient with Git I've found that the first four steps above being a "manual process" is also acceptable, although I'm sure I could roll the whole thing into a single click if I wanted to. The documentation for AppCmd.exe is here. The documentation for Robocopy is here.


Concurrency with listeners and upload: is this solution sound?

I'm working on an Android app. We have listeners for position data and camera capture which is timed on a background thread (not a service). The timer thread dictates when the image is captured and also when the data is cached in a local sqlite db. So, my question is how to properly store the location data as it comes in based on the listeners and pull that data so that the database can be updated as the camera capture is executed. I can't put the location data into the database as it arrives because it is processed more frequently than the camera images and the camera images are what dominates the architecture at the moment. (Location data is supplement). However I need the location data to get a rough location of the where the image is captured. My first thought was to have singleton store the location data. And have a semaphore on the getInstance method so if the database update is happening (after an image is captured) we don't have an error. The location data can wait for the database update or it can be lost for that particular event it doesn't really matter. What are you thoughts? Am I on the right track? (And is this the right sub- site or would this be better on stackoverflow?)


Recent programming language for AI?

For a few decades the programming language of choice for AI was either Prolog or LISP, and a few more others that are not so well known. Most of them were designed before the 70's. Changes happens a lot on many other domains specific languages, but in the AI domain it hadn't surfaced so much as in the web specific languages or scripting etc. Are there recent programming languages that were intended to change the game in the AI and learn from the insufficiencies of former languages?


Does reading fiction improve one's ability to read technical material?

Does any know of a study or personally witnessed any change, or lack of change, in technical reading skills after spending a good deal of time reading fiction?


Handling bugs, quirks, or annoyances in vendor-supplied headers

If the header file supplied by a vendor of something with whom one's code must interact is deficient in some way, in what cases is it better to:   1. Work around the header's deficiencies in the main code    2. Copy the header file to the local project and fix it    3. Fix the header file in the spot where it's stored as a vendor-supplied tool    4. Fix the header file in the central spot, but also make a local copy and try to always have the two match    5. Do something else  As an example, the header file supplied by ST Micro for the STM320LF series contains the lines:               typedef struct     {       __IO uint32_t MODER;       __IO uint16_t OTYPER;       uint16_t RESERVED0;       ....       __IO uint16_t BSRRL; /* BSRR register is split to 2 * 16-bit fields BSRRL */       __IO uint16_t BSRRH; /* BSRR register is split to 2 * 16-bit fields BSRRH */       ....         } GPIO_TypeDef;      In the hardware, and in the hardware documentation, BSRR is described as a single 32-bit register. About 98% of the time one wants to write to BSRR, one will only be interested in writing the upper half or the lower half; it is thus convenient to be able to use BSSRH and BSSRL as a means of writing half the register. On the other hand, there are occasions when it is necessary that the entire 32-bit register be written as a single atomic operation. The "optimal" way to write it (setting aside white-spacing issues) would be:               typedef struct     {       __IO uint32_t MODER;       __IO uint16_t OTYPER;       uint16_t RESERVED0;       ....       union // Allow BSRR access as 32-bit register or two 16-bit registers       {         __IO uint32_t BSRR; // 32-bit BSSR register as a whole         struct { __IO uint16_t BSRRL, BSRRH; };// Two 16-bit parts       };       ....         } GPIO_TypeDef;      If the struct were defined that way, code could use BSRR when necessary to write all 32 bits, or BSRRH/BSRRL when writing 16 bits. Given that the header isn't that way, would better practice be to use the header as-is, but apply an icky typecast in the main code writing what would be idiomatically written as `thePort->BSRR = 0x12345678;` as `*((uint32_t)&(thePort->BSSRH)) = 0x12345678;`, or would be be better to use a patched header file? If the latter, where should the patched file me stored and how should it be managed? **Edit** In this vendor's data file, I/O device registers are defined by using structure definitions like the above with macro definitions like `#define GPIOB (*((struct GPIO_TypeDef*)GPIO_BASE + 0x100))`. Because `GPIOA`, `GPIOB` etc. are defined as macros rather than identifiers, any macro substitution of `GPIO_TypeDef` which goes into effect after the structure is defined would affect future uses of that type but also apply to `GPIOA`, `GPIOB`, etc. Thus, my present inclination would be to define my own project-wide header file which `#include`s the vendor's file, and then defines my own structure and macro-substitutes my structure's name for the vendor's. That would allow code to be written to use the registers in the normal idiomatic fashion while using the vendor-supplied definitions for just about everything else, and while providing a clear patch-point.


Does the order of learning matter in web development?

I have many things to learn: CSS, HTML, C#, **JavaScript** , ASP.NET, SQL Now does the order matter here? For example, is it better to learn C# before HTML or the reverse could be better?


what is the object oriented counterpart to haskell / coq

I have detailed information on the latest developments in functional programming. I think haskell is quite an advanced and high level programming language. With coq and agda this gets even more complex and advanced. With "advanced" and "high level" I mean many distinct features, that can only be found in the respective languages. Like for haskell   * everything is pure and lazy per default    * support for advanced concepts like GADTs, Monads, Functors, etc. For coq / agda   * a dependent type system  And both haskell and coq are used in academics, a good sign that they are 'state-of-the art'. However I have no clue what comparable developments in object oriented programming are. What are some of the latest developments in object oriented programming? What would be a state-of-the-art OOP language counterpart to haskell / coq? (I even search for advanced programming language on google, but I found mostly haskell related information. The only language I could think of is D 2.0. Scala is for me mainly a java compatible version of haskell.)


Is it possible to write a generalized string reverse function that works for all localisations and string types?

I was just watching the Jon Skeet (with Tony the Pony) presentation from Dev- Days Although "write a string reverse function" is coding interview 101 - I'm not sure that it's actually possible to write a general string reverse function, certainly not one that works in all localisations and all string types. Apart from detecting if the input string is ascii, UTF8, UTF16 (fixed and variable length) etc.   There is the 'apply accent to next character' (U+0301) code that Jon highlighted. Then there are ligatures that may or may not be displayed, or encoded as double characters. Seems that "reverse a string" is actually one of the harder computer science tasks!


Should I accept to write unsecure code if my employer requests me to do so?

My employer asked me to implement a feature that would require storing passwords in clear text in a database (or using an obscure encrypt/decrypt function stored in a binary, which is a bit better, but also insecure). I replied that I was willing to implement such a feature, provided that customers were acknowledged of security implications when using it. When discussing this problem with colleagues, someone told me that, as a software engineer, we are personally responsible (in the legal sense) for security problems that we introduce in our products. I looked into my contract, but did not found anything related to a similar case. From a legal point of view, should I refuse to implement such a feature? Is it true that my employer could take me to court if a customer experiences damage due to this feature, even if he was aware of security concerns as well? * * * _EDIT:_ I understand this question can only be answered reliably from a lawyer. The same is true for licensing questions: people here give their understanding and their experience, sometimes after having consulted a lawyer, with no guarantee it applies in another jurisdiction. But licensing is explicitly accepted as a topic here, see What kind of questions can I ask here?. I believe other programmers may have the same issue, and other may have been confronted to this situation before, and may have consulted a lawyer for that.


What determines when a computer is considered a "client"?

In web development the terms _"server"_ and _"client"_ are often refered to when discussing how pages are requested on the web. It is also used exstensively when talking about PC, phone, tablets, etc. The question that came to my mind was what qualified a computer to be considered a client? I took a look at this article from wikipedia and noticed that clients are considered _service requesters_ whereas Servers are considered _service providers_. If this is true couldn't all computers that request a service in a sense be considered a client? The stereotype I noticed is that a client computer is usually synonymous with a "consumer" computer, but according to wikipedia this is not entirely accurate. Any idea on how to draw the line in this common scenario?


How to refactor a Python “god class”?

# Problem I’m working on a Python project whose main class is a bit “God Object”. There are _so_ friggin’ many attributes and methods! I want to refactor the class. ## So Far… For the first step, I want to do something relatively simple; but when I tried the most straightforward approach, it broke some tests and existing examples. Basically, the class has a loooong list of attributes—but I can clearly look over them and think, _“These 5 attributes are related…These 8 are also related…and then there’s the rest.”_ ### **getattr** I basically just wanted to group the related attributes into a dict-like helper class. I had a feeling `__getattr__` would be ideal for the job. So I moved the attributes to a separate class, and, sure enough, `__getattr__` worked its magic perfectly well… At _first_. But then I tried running one of the examples. The example subclass tries to set one of these attributes directly (at the _class level_ ). But since the attribute was no longer “physically located” in the parent class, I got an error saying that the attribute did not exist. ### @property I then read up about the `@property` decorator. But then I also read that it creates problems for subclasses that want to do `self.x = blah` when `x` is a property of the parent class. # Desired   * Have all client code continue to work using `self.whatever`, even if the parent’s `whatever` property is not “physically located” in the class (or instance) itself.   * Group related attributes into dict-like containers.    * Reduce the extreme noisiness of the code in the main class.  For example, I **don’t** simply want to change this:               larry = 2     curly = 'abcd'     moe   = self.doh()      Into this:               larry = something_else('larry')     curly = something_else('curly')     moe   = yet_another_thing.moe()      …because that’s still noisy. Although that successfully makes a simply attribute into something that can manage the data, the original had 3 variables and the tweaked version still has 3 variables. However, I would be fine with something like this:               stooges = Stooges()      And if a lookup for `self.larry` fails, something would check `stooges` and see if `larry` is there. (But it must also work if a subclass tries to do `larry = 'blah'` at the class level.) # Summary   * Want to replace related groups of attributes in a parent class with a single attribute that stores all the data elsewhere   * Want to work with existing client code that uses (e.g.) `larry = 'blah'` at the class level   * Want to continue to allow subclasses to extend, override, and modify these refactored attributes without knowing anything has changed    Is this possible? Or am I barking up the wrong tree?


Why does C dominate in the embedded software market?

Almost everyone will now say the blessing: **performance**! Okay, **C** does allow to write athletic code. But there are other languages that can do so, after all! And the optimising power of modern compilers is awesome. Does **C** have some advantages that no other language has? Or there's simply no need for more flexible instruments in the domain?


Will this "wireless" syntax for my framework make for good code structure / design?

I'm at the point where I'm getting into the freelance development of some complex web apps, and I would like to develop a light weight framework for my personal use, but I'd like to get some advice from more experienced programmers first about one aspect of my big-picture design for the framework. It's heavily prototype / OOP based. The framework is set up to know how to handle each prototype, and to know that certain objects for example, a `socketIO` construct, can utilize other specific objects, the `IP` of a `server` for example, and also the `socketPort` of that `server`. It facilitates this practice with the programmer's own functionality as well, helping to keep all code decoupled, object oriented, and "wireless". The outcome of this is code that looks "wireless" -- What I mean by that, is instead of passing data as function parameters, the framework's objects know which objects to look for and read from. The developer can pass an object in as the parameter, but if he doesn't the framework will search for it and find it if it exists within the appropriate scope. **Is what I have described a good programming practice/design?** I like the code structure that it helps me to achieve more quickly, but it's important to me that I don't spend time on something that is broken (a bad model). _I want to know if this practice where the data isn't visually passed around / transferred is an acceptable approach to development._ My concern is that the communication between related objects "behind the scenes" may confuse programmers who aren't privy to the design of the framework. * * * Here's some "mock" client side engine code that would work after the completion of the this framework that I'm currently calling Air JS. It's commented to explain itself, because it's my blueprint, of sorts, so feel free to skim through it without bothering with every detail.               App.Engine = new engine({              /*               Air JS's Engine Model          ---------------------              When developing web apps, the engine          gets complex quickly, both on the          client and server side. Without a          framework promoting the use of good          JS OOP coding patterns, the code can          very quickly become a tangled mess!              By utilizing object prototypes, Air         JS accesses relevant objects and will          find things like IPs, Ports,          extensions, and other information         relevant to a specific task, without         the developer needing to manually          connect things. For example, when          creating a socket.IO connection, if         a server object exists that owns a         socketPort object, Air will find the         port! No strings attached.               */              Server : new server({              /*              The server constructor allows all          relevant server information to be          gathered into one place. Sky JS          objects such as:                  socketIO object             AJAX object              that utilize server information          will dynamically locate and utilize         the information "wireless", without         the need to be passed in.              */                  location : new location({                      url     : new URL("www.website.com"),                 IP      : new IP("1.2.3.4.5"),                 ports   : new portList({                          default     : new defaultPort("8080"),                     socket      : new socketPort("4545")                      }),                 paths   : new pathList({                          app         : "App",                     login       : "Login",                     register    : "Register",                     getData     : "Get"                      });                  }),                  auth : new authentication({                      username    : new username(App.Client.Username),                 password    : new password(App.Client.Password)                  }),              }),              "Socket" : new socketIO({                  open : new socketListener("open", function(){                      // handle event                  }),              }),              /*               The socketIO object expects an object          containing socketListeners as its first          parameter.              The SocketIO object accepts a server object,         portList, socketPort, or port string / int          as its second parameter:                  App             Server             App.Engine             App.Engine.Server             App.Engine.Server.ports             App.Engine.Server.ports.socket                  "4545"              4545              This is an example of how Air.JS works          "wireless" -- If the relevant object exists         within the same engine, it will be found,          without the developer passing the object or         information in as a parameter. This is called         wireless association in Air JS.              Wireless association will be discussed later         on in this program, and is the primary proponent         of the clean, de-coupled code that Air JS         promotes.              In this situation, the relevant object is a         socketPort. If a server object exists that          owns a portList containing a socketPort,          it will grab the port.              If there are multiple server objects, the          framework will choose the first one that owns          a portList and / or a socketPort.              If no socketList object is found in a server          object, the framework will search the main          scope of the server object. If no socketPort          object is found in a server object, or no          server object is found in the engine object,          the framework will check for a socket object          in the engine object's main scope.               Ultimately,          if no socketObject exists, and the developer          does not provide the port via parameters, an         error will be thrown, pointing to the missing          data.               */          });          App.init();      The functionality demonstrated here are object prototypes assigned within the framework, as shortcuts. For programmer models of new engine pieces/components, the framework would facilitate the use of objects that "know" certain prototypes. For example, the user creates the prototype `Car` and lists `carDoor` as one of its related objects, so a `Car` instance will look for any `carDoor`s, without the developer feeding it a `carDoor` through parameters.


"Invalid operation" status code in a HATEOAS REST API

In a HATEOAS API links are returned which represent possible state transitions. A conforming client should just be retrieving and following those links, but if a non-conforming client is constructing URIs rather than following the supplied links what would be the most appropriate status code/response to return?   * 400 would work, together with some information in the response body - this is what we're currently doing   * 403 I guess would be wrong, as it implies that the request could never work - but potentially the link may be available in the future   * 404 sounds plausible - at this point in time the resource doesn't exist What do people think? I know that conditional requests can handle requests based on stale responses (resulting in e.g. 412s), but this is a slightly different situation. Update: OK, I see now that the correct response for these types of invalid operations would be a 404. How about where the syntax of a request is correct, it's going to a valid resource but it's somehow violating a business rule. Here's a couple of contrived examples:   1. Let's say the client can provide two numbers which must be within 20% of each other, but otherwise could be any number.   2. Let's say the client can provide a number which goes through some calculation the result of which indicates that the original number provided was incorrect. Is 400 is the correct response for these?


Should I separate a web api from the webserver?

Lets say I'm building a site similar to this or Quora (or some arbitrary blog- like site). I need a real-time component that will be using web-sockets/long- polling to notify the user of new posts, questions, etc. depending on what page the user is viewing. That real time component will essentially be the site's API implemented in something like Twisted or Java NIO, and the site's web server will be sitting in front of say Flask or Pyramid. Should the API and webpages be served by the same component or is it best to keep them separate? (I'm asking _both_ logically and physically)


What is the downside of returning a string instead of a void function or throwing an exception?

Say I have a method that inserts a record into the database. I don't need to know the newly-inserted ID or anything else. I have two options:   1. `public void Insert()`   2. `public string Insert()` In the first: if an insert is successful, the calling code will continue. If it fails, an exception with the details will be returned and the calling code will handle it in the catch. In the second: the calling code will interrogate the return string for specific words to see whether or not it was successful. Which option is better and why?


Is there a reason to define type aliases in any program

I have started to learn c++ for some time ago. It is a big subject and I am not very use to it yet. Thus is this question asked more of curiosity, than something else. In the book that I read to now learn there is a discussion about portability. I agree that the discussion comes quite earky for someone in the beginning of their learning period, but when reading I came to Think about something. What I wonder is: is there ever is a reason to define custom type to use instead of the fundamental builtin types? For example, would it be useful to define a type `int_c` as in "int custom"? The reason I think about this is since some code may be compiled for example both a 32-bit compiler and a 64-bit compiler. It seems as if it would be easier since if you change platform and all the integers are defined as `int_c` instead of `int`, since the latter would require changing type in every place an int is used? However, I also know that `<cstdint>` contains definitions of different integer as `int64_t`. However I have not heard of a header with floating Point types. So to conclude: Is there a reason to define custom integers or floats like `int_c` or `double_c` Or int other case what is the best apporach?


What should be in my model and what should be in my controler?

We are writing a system with a sort of quasi-MVC structure (it was never stated as that, but that's what it is). I'm building up a full knowledge of the system and the controller will have to make calls to me to update it; they system itself is something similar to a graph. We need to have a sense of a path between multiple nodes, and a way to identify the original node. I receive connections between two nodes in my original graph building, so knowledge of the full path, and the origin node, is not read in directly but obviously can be inferred once I finish building the graph. My instinct was to write a basic path tracing sort of logic into my model. Every new edge we would infer the path's that exist and any original input nodes by tracing the path forward and backwards as appropriate. Tracing the path forward or backward does require a bit more knowledge of a system the connection between edges and nodes are a little more complicated then just edge 1 connect node A to B. My question is, would doing this still be within the realm of the model? If I do all this path tracing, determining input nodes, identifying paths etc am I doing too much work which I should really be storing in the controller for easier modification later? I need to have some tracing capability to build the original graph before the controller is even initialized, but of course I could have the controller provide methods I call to do path tracing and the like an use the controller implementation when building the graph. I don't _think_ the logic for the graph itself will change, only the way we use it for tasking, and doing things in the model makes it easier because the model can modify it's quasi-immutable objects directly while I'm not allowing the controller to do that without calls to the model (package scope variables).


Productivity comparision FileNet versus WebSphere Process Server

On one project we are looking at where to implement workflows. Does anyone have experience with both FileNet and WPS (or know of any studies), that could say anything about the amount of effort required to create a workflow in the 2 products?


How to start learning J2EE, especially JPA

I am trying to start learning the `J2EE` part of `Java`. But I don't know where to start. I am familier with `Core Java` and mainly, I want to learn `JPA` and basics of `Hibernate` and `Spring Framework`. The main reason for this is I am working on a project which is using all these things. And most of the code is being developed by some senior guys and I have to make some modifications in that. So basically I need to understand their code. Can someone give me a sort of roadmap, like which things I need to know beforehand and in what sequence should I go? Any reference material, like links, books?


What are the benefits of prefixing function parameter names with p*?

I often see projects (in Java projects and teams using Eclipse) that prefix function parameters with `p`. For example               public void filter (Result pResult) ...      I personally don't see any benefit in this, but would like to know what the reasoning is. The best explanation I've heard yet is that it is to distinguish the name of identical named fields.I have my issues with that explanation but I can understand the point.


How can degree of order in a list be measured?

The following questions gave me food for thought:   * Efficient way to shuffle objects   * I'd like to write an "ultimate shuffle" algorithm to sort my mp3 collection When you sort a list - you always have a base-line(numbers, alphabet, ...) which tell you how to order the list. **Question** : When you shuffle a set - how would you measure "degree of order"? For example: 9 8 7 6 5 4 3 2 1 is ordered, even if completely differently than 1 2 3 4 5 6 7 8 9. And 9 8 7 6 1 2 3 4 5 also has some order (if you look at it in chunks: 9 8 7 6 and 1 2 3 4 5). Another example could be 9 2 3 4 5 6 7 8 1. How can you determine if one listing is **_less_** or **_more_** ordered than another. **Note** : since there has been some confusion about the goal of this question - I would like to specify, that I'm _not_ looking for a method to measure randomness. 1234 is just a random set of 4 digits as 4213, but it seems to me that 1234 is _more_ ordered than 4213. The comment about "Kolmogorov complexity" by user61852, or the answer by Mathew Foscarini which mentions measuring the deviation between neighboring numbers in a sequence, are the types of answers I am looking for. I'm not sure if the measure entropy approach in the comment by MichaelT helps identify order in a list - if the comments could be elaborated into answers that would be great.


How can I maintain a SQL schema upgrade that goes out to our users on a regular basis?

I work on a project that uses a SQL database as a back end, and a desktop app as a front end. We do releases on a regular basis, and as part of a release, our client needs to update their SQL server. Our business requires that we are upgradable from version 1.x to 1.y, and the way we've been doing it so far is by following a simple pattern for dozens/hundreds of tables:   * IF NOT EXISTS (XXX) CREATE TABLE/VIEW YYY ...   * ALTER TABLE (XXX) ADD COLUMN (WWW) ...   * CREATE INDEX (ZZZ) on table XXX (if needed)   * So on... The problem I see with this is that the steps laid out above are all laid out in a one-for-one relationship with the table that's being created. This is fine for simpler databases that have no constraints, but becomes a pain when foreign keys/triggers/anything complex becomes involved. I was wondering if there was a pattern out there that could help me clean this up and make modifications to my script easier. I was thinking something along the lines of following these steps for every table in the database:   * perform cleanup from any "old" version   * create/update all tables/columns (without constraints)   * create/update all views based on tables   * create/update all foreign keys / constraints   * create/update all indexes   * create/update all triggers   * ... I use a tool to merge all of the SQL files in my repository into one, but the rhyme/reason to which file gets merged at what point is becoming unclear - often I just give up and hack something in that says "include file X directly before/after file Y". It's becoming unmaintainable (I can still fix problems, but I want to be able to hand off this responsibility). It's this last annoyance that I want to be able to avoid. I want to be able to create a new table by just dropping a script with the content "CREATE TABLE X..." in a "Tables" directory and call it done. Are there any patterns out there that can help me? I'm really looking for some sort of ammunition that I can use when I propose this to my colleagues by saying "see - there IS a solution to this cluster* and THIS is how other companies address it."


Should I be helping and explaining?

This is more of a philosophical question, I suppose, but it seems quite well suited to here, to me. I'm a 20-year-old, second year software engineering student, with a good history in development, working for a software development/consultancy when I'm not studying etc etc etc All through my first year I found myself helping and explaining things to my peers when it came to programming and general software development stuff - data structures, common/important algorithms and the like. I can think of one or two pros to what I'm doing but I feel like I shouldn't have been helping, in case I end up confusing people or passing on bad practices. It bugged me at the time, but I never thought to ask. So: **should I be helping?** Thanks


Programming style in Perl

I work in Java so basically I use OOP paradigm during coding. I am about to start working in Perl and I was wondering what is the paradigm that Perl developers follow. In wiki it mentions that it supports many paradigms but I am not sure I understand this since it is a scripting language. So my question is: Are the object oriented patterns I'm familiar with in Java idiomatic in Perl, or will I need significant change to my design style to write effective Perl? Note: This is not a question to critique Perl. I actually have to work in Perl and would like to understand how the current way I program will change.


What are the reasons for rebuild and redeployment libraries?

It's difficult to understand the meaning of the question from the topic's name. Here is what I mean. I'm watching Uncle Bob's Clean Code Episodes. In many episodes where he is talking about SOLID principles he mentions the problem of rebuild and redeployment caused by code changing. He says that bad architecture causes frequent rebuilds and redeployments. But I have a couple of questions:   1. Why frequent rebuilds and redeployments is bad?   2. Can you enumerate causes of rebuilds and redeployments of dll's?   3. Is there any difference between different languages according to the second question?   4. What causes rebuild and redeployment of dll's in C#? The second question (and the most common) is based on dll's coupling. What should I change in one of two coupled dll's so then I have to rebuild and redeploy the other?


Micro vs Monolithic Server architecture

We are currently working on our new product/project, it is a client-server application directed towards certain specific industrial/service enterprises. We are building a server (C Language and Linux Only) running a custom protocol on top of TCP with a Java front-end. We are about 20% into the coding work and are faced with a situation having to choose between Micro or Monolithic Kernel Architecture. I am aware that Micro vs. Monolithic is usually in relation to kernel architecture, but we are specifically talking about servers. **Why a custom server and not something existing?**   * Our UI needs are significant and very dynamic, thus Web/Web-browser based solutions were not appropriate.   * The statistical processing is significant at the client end and therefore, again, browsers were of little help. (Of course, we could do the processing at the server end and pass on the processed data to the client but that would imply lot of load on the server and wastage of client resources).   * Moreover, with atleast three technologies (JS/HTML/CSS) to manage even a single event makes the whole experience like sweeping the house in the midst of a desert storm - you sweep it n-times, the dust accumulates n+1 times. **What about Micro and Monolithic Server? What are you talking?** Consider the following (hypothetical) client request:               request-id: 123     request-service: HistoricDataSets     request-message: Fetch all records upto the year 2010      On receving such request, a server, typically, does (we are ignoring concurrency techniques like thread and forks for simplicity):   * Parse the request string   * Identify the action (Fetch `HistoricDataSets LIMIT Year (2010)` in our case)   * Interact with the persistance layer (Oracle, lets say, in our example) and fetch the data.   * Format the data as per the protocol. Ex:  response-id: 123   success: true   response-text: DataSets   * Respond to the client with the thus formatted data. This is what we are calling a **Monolithic Server** (akin to a monolithic kernel where all OS workings are done in the kernel space). Consider the same request again, on receipt, this time the server (we have assumed only shared memory as IPC, again for simplicity):   * Puts the request into the shared memory for the `Parser` process   * The `Parser` parses the string, identifies the task and directs the `Executioner` process to execute the tasks.   * The `Executioner` then passes the data to `Fomatter` process which, after formatting the data into a protocol string, returns to the server.   * The server dispatches it to the client (response). Of course, instead of `Parser`, `Executioner` and `Formatter` it could have been a single but separate process. This is what we are calling a **Micro Server** (akin to a micro kernel doing barely minimum that is required). The server effectively is only listening and responding whereas all steps are taken care of by different process(es). * * * Which one to pick? We are confused! While monolithic servers are tried and tested (most HTTP-Web Servers?) and easier to program and can handle concurrency quite well. Micro servers, prima facie, seem swift and in line with UNIX principle of one program to do one task, but are also complicated to develop, esp. keeping concurrency in mind. **Question(s)**   \- What are (possibly could be) the pros and cons of each approach?   \- When to use which? (It could also be interpreted as a general question: When to use IPC?)   \- If Micro kernel is chosen, then what functions need to be a part of core- server and what not? **Similar/Related questions**   * Dangers of huge monolithic application   * External Vs Embedded browser (Tangential)    * Advice for converting Monolithic app into multithreaded (Tangential) * * * **Some information that may be helpful:**   * Our prospective customers can be divided into two categories:      * Large: About 1,700 - 2,000 requests per minute      * Small: About 650 - 700 requests per minute    * Data volume per request cycle (request and the subsequent response) can be assumed to be normally distributed with mean ~ 1.20 MB and worse case about 250-300 MB.   * The product concept is relatively new but has the capability of impacting the core operations, therefore we expect the customer budgets to be flexible only post a certain lag (9-12 months) post deployment, this limits the amount of hardware the client will be willing to commit esp. the small ones.   * Each customer will have his own client-server stack. The server will be running on the customer's hardware managed by the customer's team, while clients will be deployed on the machines of the functional employees   * Remote updates for both client and server application is a must   * Real time `PUSH` services by the server may be 'highly' desired if the product clicks!


How to maintain a demo version of an application?

I need to be able to demo our production application to prospective clients. The way I have it setup today is simple. The demo application is an exact duplicate of the production system, except that the data in the database is obfuscated to protect our current clients' data. This works great because it doesn't require any application changes. Boss dropped a potential BOMBSHELL today and said that the demo system needs to contain a special link and that **ONLY** shows up on demo. He went on to explain that in the future there may be much bigger differences between the demo and production apps (e.g. an entire area of functionality). What do I do now? Some things I have thought about doing:   * Maintain a different branch in subversion specific to the demo system   * Create an installation package that has the changes for demo, then revert and build a production installation package   * Modularize the application (no idea how)   * Say: "Screw you! I will not do it!" (LOL)   * Use some sort of conditional logic in the app to determine if it is a demo or a production app. E.g. (if the URL contains 'demo' then show else hide). If you haven't guessed by now, this is a web application Anyways, I have no experience in this scenario as to which one is better or if none of these are any good. Anyone have an answer, strategy, something!?


Teaching Programming: drawbacks of using unit tests in problem statement for assignments?

I am experimenting with marking assignments for a programming course using unit tests. Is it likely to harm the learning process if I publish some of the tests I use as part of the problem statement? I figure that reading the code will be good practice and provide a more accurate problem statement than I can deliver in words... but I'd like to hear about any drawbacks. I would change the exact numbers that I expect to put in and get out of the tests, and the assignments are more about testing introductory OO concepts than whether they correctly approximate Pi, i.e. I'm not concerned that showing some possible answers would give away too much.


Python web application frontend for equipment diagnostics and interaction

My goal is to have a Python application that runs a web server which hosts the user interface, and based on interactions from a user in their browser, long running tasks get kicked off and through some process, feed status information back to the web server and subsequently back to the browser. The application will not need to be used by more than 1 person at a time, and if 2 or more users are accessing the URL, the state should essentially be shared across all instances. That is, each user does _not_ have unique login session. The main purpose of the application will be to maintain a list of devices it discovers automatically on the network, and poll those devices every 30-60 seconds and update the UI if it is being used. In addition, the user can select one or more of those devices and issue commands or upgrade their software. In the instance of the software upgrade, I would like to have it responsive enough where I could show real time progress bars for each device showing what % of the firmware has been uploaded. My initial thought is something like web.py or Cherrypy for the GUI, now I'm just stuck on the best method to kick off those processes from the web server and how to feed the info back. I was thinking of having some daemon listen for commands on a socket which the web app would send, and it would use sockets to pass state back and forth between the daemon and the web. Then I still need to get that information smoothly from web to client so I was thinking of websockets for that. I'm just looking for recommendations on some good practices for having the web interface communicate back and forth between the actual workers and then how to get the data from worker to web server to client browser. The driving forces behind using the browser based approach is that the system itself must run on low cost hardware running Linux on x86 (not arm) with small amounts of memory. It could be a GUI app which we VNC into a machine to use but the headless method seemed better to me. I'm not 100% tied to this idea if anyone can suggest better alternatives.


Unused dependencies and constructor injection

I have a class that has 3 dependencies. WritabbleDBConnection, ReadOnlyDBConnection and a QueryFilter utility object. I want to do constructor Injection so my class would look something like this.               class PersonDataAccessObject {              public function __construct($dbWrite, $dbRead, $queryFilter) {             // sets to local vars         }              public function A() {} // uses $dbRead              public function B() {} // uses $dbWrite          }      This object would most likely be instantiated in a static factory, which knows how to retrieve the DB connections. The problem I see is every time I build this object I need to pass all 3 dependencies although possibly only one of the will be used for the operations I will need to do. I don't like hiding my dependencies inside a service locator class, since I want to keep my dependencies explicit. Are there any solutions for this? Or do I have to live with unused instances?


Which deployment technologies makes sense in Continuous Deployment?

In my understanding a major point in Continuous Deployment is (well, obviously I guess) that deployment is automatically done as a part of the building process. Conceptually it is easy to understand how the deployment can be done when the target is a website. However it appears hard/impossible to continuously deploy when it is a desktop application deployed via an msi-installer (sorry for my tech background being mainly a Microsoft one)? Are there deployment technologies that cannot be used when continuously deploying? Or rather: Which deployment technologies makes sense in continues deployment?


Why do interfaces require methods over members?

...As this forces us to create getters and setters, which in practice are often totally extraneous? Is there any good language-design reason why interfaces in most (all?) languages do not allow member fields to help fulfill the interface spec? In most extant languages, members are treated fundamentally differently from methods, but does this HAVE to be the case? In a theoretical language, couldn't we have an interface that (a) specified a zero-args method as getter, but accepted a readable member as its implementor, and (b) specified a single- arg method as a setter, but accepted a writable member field as its implementor, given a language that supported specifying direct access control on variables when they are declared? A prototypal language allowing multiple inheritance (to address the very valid point some respondents have made), would be ideal for something like this. Please inform me if something like this already exists.