Revokable BSD - What are the implications?

While examining alternatives to Exim/Dovecot for a dedicated mail server, I came across the lamson project, a python-based MTA. I also found the following fork of the project: https://github.com/moggers87/salmon Quoting from the docs at the fork: > Salmon is a fork of Lamson. In the summer of 2012 (2012-07-13 to be exact), > Lamson was relicenced under a BSD variant that was revokable. The two > clauses that were of most concern: > >   1. Contributors agree that any contributions are owned by the copyright > holder and that contributors have absolutely no rights to their > contributions. > >   2. The copyright holder reserves the right to revoke this license on > anyone who uses this copyrighted work at any time for any reason. > > > > I read that to mean that I could make a contribution but then have said work > denied to me because Mr. Shaw didn't like the colour of my socks. So I went > and found the latest version that was available under the GNU GPL version 3. > > Salmon is an anagram of Lamson, if you hadn't worked it out already. I am familiar with the BSD license but have never seen it modified in this way. I am curious what the implications of this kind of license would be for other developers using the code, especially in paid commercial projects (thinking something like subscription-based webapps here). Assuming the license were revoked, could the user be liable for monetary damages, or would a scenario like this be equivalent to a cease-and-desist, in which case whatever functionality the library was providing would have to be reimplemented? **To Clarify** : Usual caveats with regard to answers are assumed. I ask out of curiosity only and have no intentions on acting or assuming legal risk via the advice posted.


Are there any valid reasons for disallowing characters and limiting the length of passwords?

I've come across quite a few sites that either limit the length they allow passwords to be and/or disallow certain characters. That's limiting to me as I want to widen and lengthen the search space of my password. It also gives me an uncomfortable sense that they might not be hashing. Are there _good_ reasons for either setting an upper length or excluding characters in passwords?


What criteria could be used to rank popular blog posts?

I am building a service that finds popular posts from several blogs. What criteria could I use to define what the most popular posts are? For example, I track Facebook and Twitter share counts for every post of every blog and I rank the blog posts for their share counts. But that isn't the best solution because some bloggers can increase their sharing counts with fraudulent shares. What would be a better set of critera to rank what the most popular posts are?


Is it a bad idea to list every function/method argument on a new line and why?

I work with someone who, every time they call a function they put the arguments on a new line e.g.               aFunction(         byte1,         short1,         int1,          int2,         int3,         int4,         int5     ) ;      I find this very annoying as it means the code isn't very compact, so I have to scan up and down more to actually make any sense of the logic. I'm interested to know whether this is actually bad practice and if so, how can I persuade them not to do it?


How do you explain orthogonality to a non-technical person?

In _The Pragmatic Programmer_ this term is introduced and "linearly independency" is used as an example for orthogonality. How do you explain the same thing to a non-technical person and why independency is a good thing to have? Are there "real-life" (i.e. non-geek) examples for this concept?


So what happens with closed-source law?

Lets say Alice Co. writes a program, and Bob Co. hires a contractor to copy it, and put it on their platform? What is the general legal recourse in these cases? I say general, because most of us are programmers, not lawyers, and we all understand we're not asking for qualified legal advice. But generally. What happens? Do you take them to court? What considerations should be taken? What gives you ground to stand on, and others nothing to stand on?


Basis of definitions

Let us suppose we have a set of functions which characterise something: in the OO world methods characterising a type. In mathematics these are propositions and we have two kinds: axioms and lemmas. Axioms are assumptions, lemmas are easily derived from them. In C++ axioms are pure virtual functions. Here's the problem: there's more than one way to axiomatise a system. Given a set of propositions or methods, a subset of the propositions which is necessary and sufficient to derive all the others is called a basis. So too, for methods or functions, we have a desired set which must be defined, and typically every one has one or more definitions in terms of the others, and we require the programmer to provide instance definitions which are sufficient to allow all the others to be defined, and, if there is an overspecification, then it is consistent. Let me give an example (in Felix, Haskell code would be similar):               class Eq[t] {       virtual fun ==(x:t,y:t):bool => eq(x,y);       virtual fun eq(x:t, y:t)=> x == y;       virtual fun != (x:t,y:t):bool => not (x == y);       axiom reflex(x:t): x == x;       axiom sym(x:t, y:t): (x == y) == (y == x);       axiom trans(x:t, y:t, z:t): implies(x == y and y == z, x == z);     }      Here it is clear: the programmer must define either == or eq or both. If both are defined, the definitions must be equivalent. Failing to define one doesn't cause a compiler error, it causes an infinite loop at run time. Defining both inequivalently doesn't cause an error either, it is just inconsistent. Note the axioms specified constrain the semantics of any definition. Given a definition of == either directly or via a definition of eq, then != is defined automatically, although the programmer might replace the default with something more efficient, clearly such an overspecification has to be consistent. Please note, == could also be defined in terms of !=, but we didn't do that. A characterisation of a partial or total order is more complex. It is much more demanding since there is a combinatorial explosion of possible bases. There is an reason to desire overspecification: performance. There also another reason: choice and convenience. So here, there are several questions: one is how to check semantics are obeyed and I am not looking for an answer here (way too hard!). The other question is: How can we specify, and check, that an instance provides at least a basis? And a much harder question: how can we provide _several_ default definitions which depend on the basis chosen?


IOS app updates that don't require App Store submission

Some apps, I've noticed that developers are able to update their software without submitting them to the App Store. For example, Game of War will occasionally tell you that an update is available and to restart your device. You can then watch the progress bar carefully and see that updates are being pushed to the app. I'm assuming they are using XML to change certain attributes and their location on the server. That's a guess but I don't know. They are able to make significant feature changes to the game, like adding hyperlinks to map locations, push sales promotions, add certain events etc. These methods don't require compilation, as that would obviously require resubmitting the app. What technologies allow this? Are they all server side changes with XML objects being updated on the client? What is apple's policy in the developer terms?


Difference between Optimization and Scalability?

If I quote a paragraph from Wikipedia about _Optimization_ : > In computer science, program optimization or software optimization is the > process of modifying a software system to make some aspect of it work more > efficiently or use fewer resources. In general, a computer program may be > optimized so that it executes more rapidly, or is capable of operating with > less memory storage or other resources, or draw less power. And about _Scalabilty_ : > Application scalability refers to the improved performance of running > applications on a scaled-up version of the system. What's the difference? They both end up improving the performance of the system. Are they the same, if so, why are their names different?


How do I know when should I package my classes in Ruby?

In Ruby, I'm creating a small game development framework. Just some personal project - a very small group of friends helping. Now I am in need of handling geometric concepts. Rectangles, Circles, Polygons, Vectors, Lines, etc. So I made a class for each of these. I'm stuck deciding whether I should package such classes in a module, such as `Geometry`. So I'd access them like `Geometry::Rectangle`, or just `Rectangle` if I `include` the module. Now then, my question isn't about this specific scenario. I'd like to know, **when is it suitable to package similar classes into one module in Ruby?** What factors should I consider? Amount of classes? Usage frequency? Complexity?


Why do we use networking libraries instead of plain NSURLRequests and NSURLConnection ?

in iOS development, I have often seen people creating a networking module to interact with their APIs. This module generally sits on top of a networking framework like MKNetWorkKit or AFNetWorking. In most of the cases, It's all about sending GET,POST request and parsing the response which is in most cases JSON. What extra practical benefits that these libraries provide that an iOS developer should be leveraging which the plain Cocoa Networking APIs lack ? I can understand RESTKit as one exception where it takes care of the conversion of JSON to native objects and also interfaces with Core Data but what about others ?


Implementing MVC pattern in SWT application

I am developing an SWT application (it's basically an Eclipse plugin, so I need to use SWT). Currently my design is as follows:   * Model: In model, I have POJOs which represents the actual fields in views.   * View: It is a dumb layer, it contains just UI and contains no logic (not even event handlers)   * Controller: It acts as a mediator b/w those two layers. Also it is responsible for creating view layer, handling events etc. Basically I have created all of the controls in view as a static like this `public static Button btnLogin` and in controller I have a code like this:               public void createLoginView(Composite comp) {         LoginFormView.createView(comp);  //This createView method is in view layer ie LoginFormView         LoginFormView.btnLogin.addSelectionListener(new SelectionListener() {             //Code goes here         });       }      Similalrly I have done for other views and controls. So that in main class and other classes I am calling just `createLoginView` of controller. I am doing similar thing for other views. So my question, is what I am doing is correct? Is this design good? Or I should have followed any other approach. Since I am new to SWT and Eclipse plugin development (basically I am Java EE developer having 4+ years of exp). Any tips/pointers would be appreciated.


UX designers working one Sprint ahead

Our UX designers usually have a story in Sprint X that the developers will implement in Sprint X+1 (The UX designers and the devs/testers are on one team). I think this makes sense because if you don't have screen mockups and clear specifications you can't really estimate the work during Sprint Planning. However in Scrum you are only supposed to have user stories that provide value to the user. In our case the UX design stories don't provide such value (they are more like a backlog grooming activity). Also usually Scrum coaches don't recommend having complete specifications before the start of the Sprint, a recommendation which I find hard to understand. So do you see any disadvantages in our approach? It seems to work for us, but it goes somewhat against Scrum principles.


Why, in WPF, do we set an object to Stretch via its Alignment properties instead of Width/Height?

In WPF's XAML, we can tell an element to fill its container like this:               <Button HorizontalAlignment="Stretch" VerticalAlignment="Stretch" />      Why is it that when we set an element to Stretch, we do it via the HorizontalAlignment and VerticalAlignment properties? Why did the WPF design team decide to take this approach over having `Width="Stretch"` and `Height="Stretch"`? I presume it was a calculated decision, and I'm curious about the reasoning. CSS, among other technologies, follows the convention that stretching is done via the width and height properties, and that alignment affects positioning _exclusively_. This seems intuitive enough: stretching the element is manipulating its width and height, after all! Using the corresponding alignment property to stretch an element seems counter-intuitive and unusual in comparison. This makes me think they didn't just pick this option for no reason: they made a calculated decision and had reasons behind it. Width and Height use the double data type, which would ordinarily mean assigning it a string would be silly. However, WPF's Window objects can take `Width="Auto"`, which gets treated as `double.NaN`. Couldn't `Width="Stretch"` be stored as `double.PositiveInfinity` or some other value?


Entity Framework vs. Linq to SQL?

I'm a little bit confused about these two terms "Linq to SQL" and "Entity Framework". I have the general idea that both of them somehow allow you to refer to database tables as .net objects or something of the sort, but please explain to me the difference between these two terms.


How can I  define and measure simplicity in code?

There are many answers in my previous question about simplicity relating to readability that helped me see my definition and understanding of simplicity in code was, quite possibly, incorrect. How can I define simplicity in code? What software measurements and metrics are available to measure code simplicity?


Use case notation for login

When a login is needed in a system to perfom any action. How do you express that in a Use Case Diagram? I have a system that will allow employees to perform sells. They must be logged in, but once they are, it is not necesary to log again until the session ends (typical login). I do not know how can I express that that login is compulsory, but only once.


Event subscription from nested classes

Is it OK to have a nested class raise an event and for the parent class that subscribes to that event subsequently raise another event, which it's parent class has subscribed to - thus passing the original event up the class hierarchy? It may be easy to explain like this... _We have..._               Class A     Class B     Class C      _Operation..._   1. Class C raises an event   2. Class B subscribes to that event, on notification it raises another event   3. Class A subscribes to Class B event, on notification it does something So the original event occurred in **Class C** and **Class A** is dealing with it. Using this method means I require event handlers in the middle class (Class B) whose only function is to pass along the notification - this seems a little smelly to me.


Sequence Diagrams

I recently read the book 'UML Distilled' and found the sequence diagrams very useful. My question is that can we show 'data flow' as well on a sequence diagram? This is my first time on sequence diagrams. Nice to see some examples if any.


1 class model or 3 class models? 1 for each - UI, Hardware API Library, and Database

I've always used one class model in all 3 area's of my projects. User Interface, Hardware API (for data collection), Database (entity database context). Every new project only seems to grow in size, which means it gets hard to change the class model because everything uses it. It was suggested to me by seasoned programmer to split up my class model and use a different one for each part of my project. Then convert the data between models with passing data back and forth between the different parts. Which means if one of the models change that you only have to change the code in that section and change the "converters". Is this a general practice? It's definitely more work initially but I am wondering if it will save me time in the future. EDIT: I changed data model to class model as suggested in the comments. Though what I am specifically talking about is data modeled in classes in my application.


'Game loop' in a non-game application?

In real-time games, there is always a game loop that runs every few milliseconds, updates the game with new data and repaints the entire screen. Is this something that is seen in other types of applications, other than games? A 'constant-update-loop'? For example, imagine an application like MSPaint. The user can draw lines on the screen with the mouse. The line that is being drawn is displayed on the screen as it is being drawn. Please imagine this line is actually made of a lot of smaller lines, each 2 pixels long. It would make sense to store each of these small lines in a List. But as I said, the line that is being drawn (the large line, made out of lots of small lines) is displayed as it is being drawn. This means that a repaint of the screen would be necessary to display the new small line that was added the previous moment. But - please correct me if I'm mistaken - it would be difficult to repaint only the specific part of the screen where the new small line was drawn. If so, a repaint of the entire screen would be necessary. Thus it would make sense to use an 'update loop' to constantly repaint the entire screen, and constantly iterate over the list of lines and draw these lines over and over again - like in games. Is this approach existent in non-game applications, and specifically in 'drawing' applications? Thanks


Make use of design patterns in C?

Design patterns are useful for object oriented languages. But how can a **non-object-oriented** language such as **C** make of use them?


Can data classes contain methods for validation?

OK, say I have a data class for a user:               public class User {     private String firstName;     private String lastName;     private long personCode;     private Date birthDate;     private Gender gender;     private String email;     private String password;      Now let's say I want to validate email, whether names are not empty, whether birth date is in normal range, etc. Can I put that validation method in this class together with data? Or should it be in UserManager which in my case handles the lists of these users?


License for Opensource project

> **Possible Duplicate:**   >  Licensing for hosted open source and 3rd party libraries I am newbie in the open source community world. I am planning to develop a open source project, hosted on github. The project would be using other open source components like- NHibernate, FNH, Log4net, CommonLibrary, Autofac, Quartz.Net Scheduler etc etc My questions are:   1. Would there be any restrictions on using above OSS components? for   example: I plan to use MIT license, but Quartz.Net Scheduler uses   Apache license, would there be any restrictions?   2. How do I get a license for my own project? Do I need to register my project somewhere?   3. What is the best practice to mention credits to the OSS compoenents used? Many thanks,


Should we design programs to randomly kill themselves?

In a nutshell, should we design death into our programs, processes, and threads at a low level, for the good of the overall system? Failures happen. Processes die. We plan for disaster and occasionally recover from it. But we rarely design and implement unpredictable program death. We hope that our services' uptimes are as long as we care to keep them running. A macro-example of this concept is Netflix's Chaos Monkey, which randomly terminates AWS instances in some scenarios. They claim that this has helped them discover problems and build more redundant systems. What I'm talking about is lower level. The idea is for traditionally long- running processes to randomly exit. This should force redundancy into the design and ultimately produce more resilient systems. Does this concept already have a name? Is it already being used in the industry? ### EDIT Based on the comments and answers, I'm afraid I wasn't clear in my question. For clarity:   * yes, I do mean randomly,   * yes, I do mean in production, and   * no, not just for testing. To explain, I'd like to draw an analogy to multicellular organisms. In nature, organisms consist of many cells. The cells fork themselves to create redundancy, and they eventually die. But there should always be enough cells of the right kinds for the organism to function. This highly redundant system also facilitates healing when injured. The cells die so the organism lives. Incorporating random death into a program would force the greater system to adopt redundancy strategies to remain viable. Would these same strategies help the system remain stable in the face of other kinds of unpredictable failure? And, if anyone has tried this, what is it called? I'd like to read more about it if it already exists.


Which would be the best platform to develop websites to be used with very slow connections without sacrificing too much the design?

How can we give dial-up users in some remote places or less developed countries, a good experience while using dynamic websites.


Why is Visual Basic easier to learn than Java for COBOL developers?

A friend of mine came from a VMS/COBOL background and we gave her some VB6 to do - she absolutely ran with it. Next we ran her through some Java stuff and it didn't click at all. What's similar about COBOL and VB6 (but not Java) that would make this possible?


Is there a better way to organize my module tests that avoids an explosion of new source files?

I've got a neat (so I thought) way of having each of my modules produce a unit-test executable if compiled with the `-DTESTMODULE` flag. This flag guards a `main()` function that can access all static data and functions in the module, without #including a C file. From the README:                 -- Modules --     The various modules were written and tested separately before being      coupled together to achieve the necessary basic functionality.     Each module retains its unit-test, its main() function, guarded     by #ifdef TESTMODULE. `make test` will compile and execute all the      unit tests, producing copious output, but importantly exitting with      an appropriate success or failure code, so the `make test` command will      fail if any of the tests fail.              Module TOC         __________          test   obj     src    header structures CONSTANTS     ----   ---     ---     ---   --------------------     m      m.o     m.c     m.h   mfile mtab TABSZ     s      s.o     s.c     s.h   stack STACKSEGSZ     v      v.o     v.c     v.h   saverec_            f.o     f.c     f.h    file     ob    ob.o    ob.c    ob.h   object     ar    ar.o    ar.c    ar.h    array     st    st.o    st.c    st.h    string     di    di.o    di.c    di.h   dichead dictionary     nm    nm.o    nm.c    nm.h    name     gc    gc.o    gc.c    gc.h    garbage collector     itp          itp.c   itp.h   context       osunix.o osunix.c osunix.h  unix-dependent functions      It's compile by a tricky bit of makefile,               m:m.c ob.h ob.o err.o $(CORE) itp.o $(OP)             cc $(CFLAGS) -DTESTMODULE $(LDLIBS) -o $@ $< err.o     ob.o s.o ar.o st.o v.o di.o gc.o nm.o itp.o $(OP) f.o      where the module is compiled with its own C file plus every other object file _except itself_. But it's creating difficulties for the kindly programmer who offered to write the Autotools files for me. So the obvious way to make it "less weird" would be to bust-out all the `main` functions into separate source files. But, but ... Do I gotta?


I'm a student learning C++ and I've recently found out about Ruby. Would learning (some of) Ruby help me with C++ or would it just confuse me?

As the title says, I'm a student that will be starting my second year of C++ very soon. I've discovered Ruby, however. While I've heard much buzz about the language before, I've disregarded it because I always thought it wasn't something that would be useful. However, I've found a number of FANTASTIC tutorials on ruby and am interested in learning it (probably because it seems so straightforward).   1. Would playing around with ruby be a good or bad idea? I understand that there's not such thing as bad knowledge, but I'm afraid that Ruby will only confuse me when dealing with C++.   2. How different from C++ is it? I've read it's based on C in some way.    3. I've read some posts on here that Ruby and C++ can hold hands once in a while. How flexible is this relationship? Is it rarely that this would work?   4. How useful is Ruby in the real world? I'm not specifically asking about jobs- I'm more interested in what sort of applications may come from this language. Any specific examples worth looking at?


Techniques to avoid entangling git merges when working on an extensive change

I am absolutely miserable when I get in a situation where I have to merge other developers' changes into mine. When using `git` and working on a really extensive change, that happens a lot. When I start working on a change, I make a new local branch and start working in it. The intent is to push my changes to the remote from it once I am done. The concept seems wonderful if it weren't for one pesky complication: other people are making changes to the same files as you are in the meantime. I am looking for a set of techniques and policies to minimize my exposure to having to reconcile my changes with those of other people who have pushed their change to the same file after I pulled it from the remote, since there is no such thing as locking in git. For example, will pulling from remote into my local branch on a daily basis reduce this exposure overall? Are there other tricks and techniques? Also, if you have a set of git commands that you run to sync up regularly, please share. **I am literally in a situation where I spend more time syncing my changes to other people's than writing code -- and I think this is not an efficient model.** It is either that I am doing something wrong or we are doing something wrong as a team. I am miserable because of it and it seriously affects my quality of life. I understand and acknowledge the benefits of git and I love being able to switch branches so easily. But I feel that the exposure it leaves to merging is an elephant in the room many in the community refuse to or are kindof dogmatically discouraged to discuss.


Does AJAX need to use a server-side language such as PHP/ASP.NET/Java to access a database? Or some sort of web service tied to these languages? Or is AJAX able to communicate directly with the database?


How do I know my data is relational or object oriented in nature?

Just read these lines- >   * If your data is object in nature, then use object stores ("NoSQL"). > They'll be much faster than a relational database. > >   * If your data is relational in nature, the overhead of a relational > database is worth it. > > from- http://seldo.com/weblog/2011/06/15/orm_is_an_antipattern So, how do I know whether my data is relational in nature or object-oriented?


Is there a specific purpose for heterogeneous lists?

Coming from a C# and Java background, I'm used to my lists being homogeneous, and that makes sense to me. When I started picking up Lisp, I noticed that the lists can be heterogeneous. When I started screwing around with the `dynamic` keyword in C#, I noticed that, as of C# 4.0, there can be heterogeneous lists as well: `List<dynamic> heterogeneousList` My question is what is the point? It seems like a heterogeneous list will have much more overhead when doing processing and that if you need to store different types in one place you may need a different data structure. Is my naivety rearing its ugly face or are there truly times when it is useful to have a heterogeneous list?


What is an Enterprise/Automated Deployment tool?

**What is an Enterprise/Automated Deployment tool, and how would it be used?** Examples would be a plus, but please don't turn this into a list. What are the key factors that should be evaluated when looking at such a tool?


Does javascript support numerically indexed arrays with a more optimized algorithm than an associative array?

I know that Python, Perl, Java, Lua and obviously C (as it's the only array that's in ANSI standard afaik) support faster looking of numerically indexed arrays than doing a hash lookup or anything like that. Does Javascript also? As an example in code of what I mean, in the case of Perl:               for(i=0;i<10;i++)     {       # Do something     }      is slower than:               for (1..9)     {       # do something else     }      or:               @var = (1,2,3)     foreach(@var)     {       print $_; # look I'm fancy     }      and faster than:               foreach my $key (keys %hash)      {       print $_; # Look I'm fancy     }      and in python, given the following:               class thisClass:       def methodOne(i):         return i+1          thisDict = {        'number': 1     }      These two operations are similar in speed because both involve a hash lookup into a same-widthed hash:               thisObject = new thisClass     i  = thisObject.methodOne(1)      and:               i = 1+thisDict['1'];      Both of these kinds of lookups are slower than this:               thisTuple = (1,)     i = thisTuple[0]+1      While this:               thisArray = [1,2]          for i in thisArray:      print i      is iterated faster than:               thisTuple = (1,2)          for i in thisTuple:       print i      by which I mean lists iterate faster than tuples. Does Javascript support numerically indexed arrays differently than associatinve arrays? I don't believe Javascript supports more than arrays and associative arrays, but if it does how do they compare to the two speed wise?


From Freelance to Software Company

So I've been teaching and doing freelance work for years. I make great money and I love what i do. However, recently I that I have more personal project ideas than I can work on. I have tons of software ideas that I would love to give attention to. I've made up my mind, I'm going to stop freelancing at the end of the summer and put all my energy into starting a small software company. I was wondering if anyone else has gone down this same path and if so, if you have any advice for me regarding this career change?


Wouldn't Layer Supertype pattern corrupt our domain model?

a) To my knowledge Domain Objects should for the most part be oblivious to technical aspects of a design. Since I view class inheritance as being a technical solution, wouldn't introducing a Layer Supertype pattern into our domain corrupt it? b) If you disagree, please elaborate why Thanks


Are there any benefits to removing unused references in a VS project?

Are there any benefits to removing unused references in a VS project (such as can be done using Resharper), or will VS automatically take care of that when building/deploying?


Array Multiplication and Division

I came across a question that (eventually) landed me wondering about array arithmetic. I'm thinking specifically in Ruby, but I think the concepts are language independent. So, addition and subtraction are defined, in Ruby, as such:               [1,6,8,3,6] + [5,6,7] == [1,6,8,3,6,5,6,7] # All the elements of the first, then all the elements of the second     [1,6,8,3,6] - [5,6,7] == [1,8,3] # From the first, remove anything found in the second      and array * scalar is defined:               [1,2,3] * 2 == [1,2,3,1,2,3]      **But** What, conceptually, should the following be? None of these are (as far as I can find) defined:   * Array x Array: `[1,2,3] * [1,2,3] #=> ?`   * Array / Scalar: `[1,2,3,4,5] / 2 #=> ?`   * Array / Scalar: `[1,2,3,4,5] % 2 #=> ?`   * Array / Array: `[1,2,3,4,5] / [1,2] #=> ?`   * Array / Array: `[1,2,3,4,5] % [1,2] #=> ?` I've found some mathematical descriptions of these operations for set theory, but I couldn't really follow them, and sets don't have duplicates (arrays do). Edit: Note, I do **not** mean vector (matrix) arithmetic, which is completely defined. Edit2: If this is the wrong stack exchange, tell me which is the right one and I'll move it. Edit 3: Add mod operators to the list. Edit 4: I figure `array / scalar` is derivable from `array * scalar`:               a * b = c      => a = b / c          [1,2,3] * 3 = [1,2,3]+[1,2,3]+[1,2,3] = [1,2,3,1,2,3,1,2,3]     => [1,2,3] = [1,2,3,1,2,3,1,2,3] / 3      Which, given that programmer's division ignore the remained and has modulus:               [1,2,3,4,5] / 2 = [[1,2], [3,4]]     [1,2,3,4,5] % 2 = [5]      Except that these are pretty clearly non-reversible operations (not that modulus ever is), which is non-ideal. Edit: I asked a question over on Math that led me to Multisets. I think maybe extensible arrays are "multisets", but I'm not sure yet.


Finding a new programming language for web development?

I'm wondering if there are any _less-biased_ resources that give good, _specific overviews_ of programming languages and their intended goals. I would like to learn a new language, but visiting the sites of each language isn't working. Each one talks about how great it is without much mention of it's weaknesses or specific goals. > Ruby is a dynamic, open source programming language with a focus on > simplicity and productivity. > > Python is a programming language that lets you work more quickly and > integrate your systems more effectively. Having been a PHP developer for years, Vic Cherubini sums up my plight well: > I knew PHP well, had my own framework, and could work quickly to get > something up and running. > > I programmed like this throughout the MVC revolution. I got better and > better jobs (read: better paying, better title) as a PHP developer, but all > along the way realizing that the code I wrote on my own time was great, and > the code I worked with at work was horrible. Like, worse than horrible. > Atrocious. OS Commerce level bad. Having side projects kept me sane, because > the code I worked with at work made me miserable. > > This is why I'm retiring from PHP for my side projects and new programming > ventures. I'm spent with PHP. Exhausted, if you will. I've reached a level > where I think I'm at the top with it as a language and if I don't move on to > a new language soon, I'll be done completely with programming and I do not > want that. Languages I've looked at include JavaScript (for node.js), Ruby, Python, & Erlang. I've even thought about Scala or C++. **The problem is figuring out which ones are built to handle my needs the best.** So where can I go to skip the hype and get real information about the maturity of a platform, the size of the community, and the strengths & weaknesses of that language. If I know these then picking a language to continue my web development should be easy. **Update** I just don't want to get 4 months down the road with some language and find it sucks because each thread has 4MB of overhead, or the max concurrent connections is 999, there is no package to do "X" feature, or support is being phased out for a new language branch.


Is BSD license compatible with Apache?

Can I develop a BSD-licensed software that extends an Apache-licensed software (and vice-versa)?


Is this code bad enough to warrant a rewrite?

This is a web application for payment processing. I've been here maintaining it for nearly two years now, so I have a good idea of the problems with the system. About a half a year after starting here I started a rewrite in php/mysql that ended up not getting used (not because of good reasons like "it hasn't been tested" or "how do we know if it will be stable?" but "php/mysql are not microsoft and are therefore bad" and "we have to buy a license for mysql / we'll have to share our source code if we use it / no shops use anything but microsoft products" - those were thoroughly entertaining conversations. This ended up being a fully functional throwaway prototype. I wasn't happy with the end result (mostly with how the HTML was coupled with code, it would have been hell for a web designer to work with), but it worked and at least I gained complete insight on the input/processing/output of the entire system. The current system we are using works, but is fragile and difficult to add features to without breaking something else or requiring lots of manual fixes down the line. But is it bad enough to need a rewrite in order to move forward and meet the requirements and features new potential clients? I think so. Here's a list of code smell:   * Originally designed in Visual Basic in 2003 or earlier, no major design changes since   * No classes or any kind of object-oriented design   * 3700 line Module1.vb file   * Manual deployment of executables and aspx files   * Complete mess of HTML designed in 2003, under-utilized stylesheets   * New clients were created by copying and renaming pages and functions   * Copied function names, e.g. function1, function2, function3   * Highly coupled with SQL Server   * Redundant database connection->command->reader blocks   * Highly coupled with our current payment processor   * Lots of functions with 6 parameters (many byref because there are no classes)   * No unit testing, have to debug from the start of the application to the finish every time   * No consideration for security   * Coding style is completely inconsistant, save for what VB does   * Settings (including passwords) are hardcoded in compiled files (besides those I've moved to web.config)   * Comments are either dead code (found everywhere, sometimes up to 50 lines), stating the obvious, or non-existant   * Extremely fragile - during revisions, changing code in one place affects stability elsewhere.    * I fixed a byref parameter of one function to not always be empty (so it would actually put a value into the variable it was supposed to be getting, but who could tell if it was used or not?) only to have a block of code with an obvious flaw (that had been there for over 5 years) suddenly start working.   * No test objects - all test data is retrieved from live databases or copies of live databases   * No thought to database table design - tables contain useless and redundant data.    * Code highly coupled with database tables/field names/types/procedures   * Warning 279 Maximum number of warnings has been exceeded.   * No separation of debug code and production code besides if statements (had a huge error with this at the end of 2009)   * Many, many redudant SQL queries to update rows with session data   * Javascript file is completely undocumented and has functions and have useless and redundant names (e.g. testFun, validate1, 1a, 2, 2b, 2c, and so on)   * External documentation is just an overview. I've written decent documentation since then.


How can I debug a JSP?

I'm trying to edit a JSP for a project and I'm getting a NullPointerException somewhere in the JSP when it's requested from my server. My web server (JBoss) is reporting the exception, but it's giving me a bogus line number. It's reporting that the exception happened on line 702, but my JSP is only 146 lines long, so I'm unable to identify which line is choking. What are some good techniques to debug errors in JSPs? I'm using IntelliJ 9 Ultimate as my IDE. Thanks


Where does the tradition of shell prompts in code snippets come from?

Most code samples I see that demonstrate shell code preface each command with `$`. Having a prefix makes sense, but I'm confused as to why `$` is used in particular. Some other symbol, like `!`, that can be copied and pasted into a prompt without affecting the command's execution makes far more sense to me. So where does this notation come from?


Can we call final field as object's constant?

We call `static final` fields as `constant`, rather I should say `Class constant`. So can we call just `final` fields as `Object's constant`? Is it right to say this?               Edited ::      Consider the following code :               class JustFinal     {         final int a=20;         final int b;              JustFinal(int x, int y){             //a=x;             b=y;         }              public static void main(String arg[])         {             JustFinal jf = new JustFinal(100,200);         }     }      In the above code field `a` will have a same value for all the object instances and field `b` can have a different value for a different object instance. Shouldn't we call the `final field a` as `CONSTANT` and `final field b` as `OBJECT's CONSTANT`?


What ASP.NET MVC can do and Ruby on Rails can't?

ASP.NET MVC and Rails have similar area of use, are built around same architecture, both frameworks are relatively new and open source. So as a Rails programmer I'd like to know, what ASP.NET MVC can do and Ruby on Rails can't, and visa versa?


Obscurity of Lisp in collaborative projects

I'm playing with the idea of learning Scheme but I have a few misgivings. From what I understand Lisp makes heavy use of macros that allow programmers to drastically change the language itself. I understand why that's useful, but how does this affect collaborative projects? How much confusion can this cause if other developers implement obscure macros, with or without documentation? Are there well defined guidelines for avoiding this confusion or are there language features that help avoid it? I ask because my current job is C++ and we have to use an in house framework. Our senior developer has tried to extend C++ to make it as Java-ish as possible. We have to spatter our code with obscure macros to make everything a smartpointer (in house of course, not the standard library kind) and homebrew exceptions etc. As a result, everything we write turns into a heaping mess and when these magic macros break we have no idea how to fix them. Obviously job security comes into play, but let's forget about politics and assume everyone is here for the right reason. From what I've read, the C preprocessor is very primitive compared to Lisp. So would a situation like this be 1000 times worse in Lisp or would it be better somehow?


How to make C++ template stack work with basic data types and compound variables?

Templates are nice for similar algorithms of different data types. Say I make a template stack of a basic data type...               Stack<int> stck(10);     stck.Push(5);      I'd pop it...               int x = stck.Pop();      x would be 5. If I call pop again, there are no items, so I have the method just return 0 for null. It could be something else, but whatever. But now, if I change the template type to a compound variable (a structure type - say, RECT), and the stack is empty, it can't return 0. It expects a RECT type, but I don't have any left. How do I make this work for basic data types and compound variables? Exceptions?


Is it a bad decision to release code that is not open source

I work for a company that owns several closed source software. One of our software is used to service clients and generate income so it has commercial value to us (and it pays my salary). I've talked about open sourcing the code, but the option of open sourcing under something like the MIT or GPL or any other open source license that allows competitors to install it and offer it to our clients for cheaper has met clear resistance. What about showing the code but not under an open source license? The arguments I've been getting against this is that this move will confuse clients and developers and will get us more bad publicity than any good thing. The developer of PAINT.NET used to release his code and got a lot of flack when he started reminding competitors that the code is only for educational purposes and isn't really open source. I've also been told that open sourcing for the sake of open sourcing doesn't make sense, bla bla bla, and that unless I have a plan for how that's going to bring more revenue, it's not for us. Well, honestly I don't have a plan, but I thought why not try. Of course I can't say if this will help us or hurt us. I don't want to take the responsibility for a move that might hurt a company that's doing well and get people laid off. As I said, an open source license does not look like an option, so it's between closed source or showing the code but still under a normal copyright license. But as I said there's resistance to showing the code because of the worry that competitors will use our code to create their own. Does anyone know of any facts that can help with this decision, whether in favor or against showing the code.


When making responsive design how many versions of account for?

I am learning how to make responsive layouts for sites and web applications. It's said we need to use media queries to find out the width(resolution) and then select the layout(wireframe) for that screen. I would like to know how many layouts(wireframe) should I make for?   Please advice as per your experience. For example:   * 960x    * 480x    * 800x


Directly modifying superglobals

I've seen people (who generally write good code) directly alter the `$_POST` array with code like this:               // Add some value that wasn't actually posted     $_POST['last_activity'] = time();          // Alter an existing post value     $_POST['name'] = trim($_POST['name']);          // Our pretend function     // Pass the entire $_POST array as data to work with in the function     // The function update_record() will read only the values we actually need     update_record($_POST);          // ...That sure was easier than creating a new array      //  with only the $_POST values we actually need.      It makes sense that `update_record()` should not access $_POST directly, so we can pass other arrays of data to it for instance, but surely this is lazy, bad design, or possibly just wrong? However, we are still passing a valid array to `update_record()`, so why create a new one? This is not the point of the question, just an example of usage. However, I have heard plenty of people say that this should not be done with `$_REQUEST` data, and it's bad practice. But why? Looks harmless enough. Examples:   * Setting a default `$_GET` (or post) value that doesn't really exist   * Adding `$_POST` values that weren't actually posted after a form submission   * Directly sanitizing or filtering the `$_GET` array values _or keys_ very early in the script (fallback sanitation... why not?)   * Setting a `$_POST` value manually before form submission to populate an input with a default value (when the input reads `$_POST` for it's default value; I have done this)   * Making up your own `$_SERVER` values? Sure, hey why not?   * How about the others, like `$_COOKIE` and `$_SESSION`? Of course we have to modify those directly right? Then why not the others? Should direct modification of superglobals **_never_** be done, or is it OK to do in **_some_** instances?


Is secretive systems development really possible?

> An agency wants to develop a highly secret computer system using public > contractors. So they hire different companies to implement different > components of the system. When all the components are put together the > system is functional, but each component on it's own does not reveal the > true nature of the system. Often the nature of the system is controversial, > illegal or dangerous. That scenario has been played out many times in movies and books, but is it really possible to build such a computer system in the real-world without at least one company knowing the nature of the system. As an example, in the movie Batman: The Dark Knight. Batman uses contractors to build a spy network that allows him to use mobile phones as sonar devices. He claims in the movie that no one knows the nature of the system, because it was out sourced to many different parties. Sounds good in science fiction, but in the real world can systems been engineered this way. While I know parts of a system can easily be outsourced. Could an agency build a large complex computer system using contractors without anyone knowing the nature of the system?


Is it really possible to have libraries not depend on other libraries?

I often see the advice that you should try to make each library independent. And yet in reality I can never seem to achieve this. Is this BS advice or is it actually possibly in any realistic way? Example: I write a 2D Vector library, I then use that to make a 2D collision library. I then build a 2D physics library that uses both the 2D Vector Library and the 2D Collision library. Am I seriously expected to figure out a way to make the physics library not depend on the other 2 libraries? Likely I'll eventually want to be able to serialize/deserialize the physics and collision data which will mean I'll want to make them further depend on some serialization library. Another example: I have a string library with lots of string functions (think `endsWith(str, ending)` and `startsWith(str, start)` or whatever. I then write a templating library that uses my string library. I rarely seem to be able to write a new library that doesn't use other libraries. I could write interfaces and then write adaptors for all of those to attempt to decouple one library from another but it's unlikely to be performant and often the models of the different libraries mean that even if I could decouple with an interface trying to use a different library than the one originally decoupled will end up being impossible or massively non-performant. So, is that original advice BS or is there some way to actually apply the advice in the real world?


Selling software instead of on-demand work

Doing on-demand work stresses me out and is not good for my back. What tips could you offer if you have experience in spotting needs and writing custom software to suit ?


Planning poker with visually impaired colleague

At the office we just got a new colleague who is visually impaired. I'm in charge of organizing the planning poker sessions and the new colleague must participate as a member of the team. We have these nice sets of poker cards with planning poker numbers on them, but that doesn't help of course for our new colleague. Until now we fixed this problem by just naming the estimates, letting the new colleague say their estimate right after the rest had put down their card, then the rest flips their card and I name the estimates in a row. **My question(s):** Is there any one who has experience with this kind of situation and have a better solution? Is there such a thing as Braille poker cards? The current solution does work, but I think this can be improved for us all by for example Braille poker cards.


How to insert/update a large amount of data into mysql using php

I have an excel sheet which has a large amount of data. I am using php to insert the data into mysql server. I have two problems 1) I have to update a row if the id already exists, else insert the data. 2) BIG PROBLEM : I have more than 40,000 rows and the time out on the sql server which is set by the admin is 60 seconds. When i run the update/insert query it will take more than 60 seconds, and because of this there will be a timeout. So the whole process will fail. Is there a way I can do this ? Currently I am checking the student id if it exists, then update otherwise insert. This I feel is taking a lot of time and causing the server to time out. Also I have this field in the mysql stating the last time the data was updated(last_update). I was thinking of using this date, and if it is past a particular date(ie last time i ran the program) then only those rows should be updated. Will this help in anyway ? And what is the query i can run so as to check this date in the mysql database, that if it is past a particular date only those rows need to be updated and not everything else. (Please help me with an example query for the above!!!!!!!!!!!!!!!!!)


What types of programming require practical category theory?

Category theory has applications in theoretical computer science and obviously is central to abstract mathematics. I have heard that it also has direct practical applications in programming and software development. What type of programming is practical category theory necessary for? What do programmers use category theory to accomplish? Please note my use of "necessary" and "require" in this post. I realize that in some sense most programmers will benefit from having experience in different types of theories, but I am looking for direct applications where the usage of category theory is essential, i.e. if you didn't know category theory, you probably couldn't do it. Also, I'd like to clarify that by "what type of programming," I am hoping less for a broad answer like "functional programming," and more for specific applications like "writing bank software" or "making operating systems."


What is the best way to track database changes across a large team

What is the best way to track any change made to the SQL Server database before moving to production in case of a large team ? We have used excel sheets but quite often things get missed which come out with SQL compare only during moving changes to production?


How should I refactor switch statements like this (Switching on type) to be more OO?

I'm seeing some code like this in our code base, and want to refactor it: (Typescript psuedocode follows):               class EntityManager{          private findEntityForServerObject(entityType:string, serverObject:any):IEntity {              var existingEntity:IEntity = null;              switch(entityType) {           case Types.UserSetting:                 existingEntity = this.getUserSettingByUserIdAndSettingName(serverObject.user_id, serverObject.setting_name);                     break;                  case Types.Bar:                 existingEntity = this.getBarByUserIdAndId(serverObject.user_id, serverObject.id);                 break;                  //Lots more case statements here...         }         return existingEntity;      }           }      The downsides of switching on type are self-explanatory. Normally, when switching behavior based on type, I try to push the behavior into subclasses so that I can reduce this to a single method call, and let polymorphism take care of the rest. However, the following two things are giving me pause: 1) I don't want to couple the serverObject with the class that is storing all of these objects. It doesn't know where to look for entities of a certain type. And unfortunately, the identity of a type of ServerObject varies with the type of ServerObject. (So sometimes it's just an ID, other times it's a combination of an id and a uniquely identifying string, etc). And this behavior doesn't belong down there on those subclasses. It is the responsibility of the EntityManager and its delegates. 2) In this case, I can't modify the ServerObject classes since they're plain old data objects. It should be mentioned that I've got other instances of the above method that take a parameter like "IEntity" and proceed to do almost the same thing (but slightly modify the name of the methods they're calling to get the identity of the entity). So, we might have:                       case Types.Bar:                 existingEntity = this.getBarByUserIdAndId(entity.getUserId(), entity.getId());                 break;      So in that case, I _can_ change the entity interface and subclasses, but this isn't behavior that belongs in that class. So, I _think_ that points me to some sort of map. So eventually I will call:               private findEntityForServerObject(entityType:string, serverObject:any):IEntity {              return aMapOfSomeSort[entityType].findByServerObject(serverObject);          }          private findEntityForEntity(someEntity:IEntity):IEntity {         return aMapOfSomeSort[someEntity.entityType].findByEntity(someEntity);     }      Which means I need to register some sort of strategy classes/functions at runtime with this map. And again, I darn well better remember to register one for each my my types, or I'll get a runtime exception. Is there a better way to refactor this? I feel like I'm missing something really obvious here.


It's hard to judge how good your own product is. Is there a name for this issue?

I was just talking to my partner about how hard it is to personally judge how good your product is after a while because you use it so often. You literally spend hours on your computer doing nothing but work on this "consumer facing" application, and you start to feel a little fatigue of using it over and over and over, at least a hundred times a day. You get scared this fatigue may mean the product you are building may have the same effect on the users and might mean you are doing something wrong. Is there a name for this in product development? For the fact that as a designer+ programmer+everything else, your product might not suck as much as you think simply because you spend way too much time with it, or a variation of this?


How do global cancel/exit commands work in bash?

As I have done multiple times before, I've written bash scripts, and just general commands that go nowhere. They just blink the little command line cursor at me for infinity until I control+C the command. When I do cancel the command, what exactly is going on when I do this? Am I somehow stopping and killing the current PID I'm working on? Does it jump to a different run-level and execute something to terminate the command? On a slightly different note, I've never been able to figure out how to set up something like this in a script or program I've worked on. Since I mostly program in Ruby, can I setup something like a certain key press stops the program? Every time I've looked into doing something similar, I always end up getting hung up when it comes to user input, whether that is a loop waiting for a condition, or something like this:               def Break()       user_break = gets.strip     end          def Main()     Function1()     Break()     Function2()     Break()     [...]     end      It seems and is incredibly bulky, and definitely isn't easily scaled up or down.


Callbacks: when to return value, and when to modify parameter?

When writing a callback, when is best to have the callback return a value, and when is it best to have the callback modify a parameter? Is there a difference? For example, if we wanted to grab a list of dependencies, when would you do this:               function GetDependencies(){         return [{"Dep1" : 1.1},                  {"Dept2": 1.2},                  {"Dep3" : 1.3}];     }      And when would you do this?               function RegisterDependencies(register){         register.add("Dep1", 1.1);         register.add("Dep2", 1.2);         register.add("Dep3", 1.3);     }


How to deliver 3 different parameters to class in one method (2 of 3 are optional)

I need your help how to implement it nice and well. It's quite a simple problem. I can solve it but I need help on how to do that better. My class has logic working using three parameters. It gets them from another class. The problem is:   1. the first parameter is enum (it's required)   2. the second parameter is another enum (it's optional - there is possibility that this parameter doesn't exist)   3. the third parameter is vector of other enums (it's optional - there is possibility that this parameter doesn't exist). How to handle these parameters to my class? Any ideas? I'd like to get these parameters in one method, e.g. `updateParameters(...)`. Maybe I should have overloaded methods for every possibility, but it's not nice I guess. I can't get some container with parameters because I have different types.


C++ control reaches end of non-void function

I have a function, which looks something like this:               ClassA& ClassB::Check(int x){         //some calculations in a loop, if a condition is met, a reference to a ClassA object is given     }      I'm getting the "control reaches end of non-void function" error. As far as I understand, this is because, the function wont always return something, am I right? The function is getting the mouse coordinates and checking witch objects was selected. If something was selected, then do stuff, otherwise do nothing. What would be the best option to solve this? Should I create and return an object with some kind of flag to check against?


Improving programming and math skills at home

Apologies if this sounds like a blog. I'm currently completing tertiary eduction in order to be accepted into a CS course at university, and I would like to know what options are available to me to improve my knowledge of programming and mathematics at home. I did not finish high-school, and have a pretty basic understanding of mathematics though I've never struggled with it. I'm not sure what level of mathematics I am at, suffice to say I would struggle with solving complex algebraic equations. I've never had any formal education in programming, but I've been doing it since I knew what it was. I'd say that I have OK practical knowledge, but next to no understanding of anything advanced. To improve my mathematics knowledge, I need a list of topics which should be covered, starting from the level of an average 16/17 year old. I'd also need to know which topics to cover before others. My first thought is to buy a highschool maths textbook to start with. I'm not sure what I should be doing to improve my programming knowledge, but I sure know that I am far, far off from answering questions such as: "Using only line drawing primives, construct a wireframe 3d car demo where the player can drive the car." (to use an example from a pretty out-there job application task). I'm not sure what I am expecting in the way of answers, perhaps just advice from people who have been in similar situations. I've got a year before I enter the CS course and I want to come in with all guns blazing. Thanks.


Should ALL divs float left?

I'm designing within an application that I inherited. I have done a lot of work to "consolidate" the CSS which was extremely overworked through much copying and pasting without a lot of strategy behind it. One curious thing I found was to style ALL divs as:               <style>     div{ float: left; }     </style>      Do any other applications do this? I would be "unfloating" divs all the time because the majority of my use of divs is in fact a division of content, forcing a new line for items like cell phones and tablets. In my practices, I will style a div float-left if I specifically need it to do that.


should I store common data between two tables in a third separate table in my database?

If I have 2 tables in my database, let's say for instance 'buyers' and 'sellers' but I collect a common set of data for both for instance telephone number, email address, address etc. Is it better practice to have one common table for 'contact_details' with a reference to the table and row that the contact details are for, or as they are seperate entities are they better off in seperate tables entirely?


Advertisements & GPL

I'm planning on providing some GPL software to visitors after they interact with an advertisement. This advertisement will generate revenue for our company, so this would fall under commercial usage. I understand the GPL requires us to either provide the source or a written promise to provide the source upon request when distributing the software commercially. I'd like to know if providing a link to the the software creator's website, with instructions on getting the source, would be sufficient to satisfy this clause in the GPL?


Java: legal issues related to writing a commercial app in Java

I developed scientific software for use in my own scientific research. I am considering porting it to another language such as Java, and releasing a closed-source, commercial version of it for sale. I have been looking into Java, but I have some questions about the legal issues related to licensing Java for a commercial application, and the people who answer the phone at Oracle tell me that they do not talk to developers. I have carefully read the JDK license agreement here. But I still have questions. Does anyone reading this have any experience releasing commercial, closed-source, applications running on Java? If so, can you send me some links to information about the legal issues? My own web searches keep coming up with the same stuff. My understanding is that I would have to redistribute Java 6 with my application, and that my application would have to check to see if Java is installed in the end user's computer, and then install Java if it is not installed, or if a newer version of Java needs to be installed. Many of these end user computers might be in large organizations which might not have purchased Oracle licenses. Can my commercial application distribute the Java platform for free in this way without paying a fee to Oracle? Or are there fees or other restrictions involved? Can you please post a link to any information on the web about this? From what I have read, the only fees seem to be related to the commercial features of Java, which are limited to tools for optomizing large enterprise applications. But I would like to hear from other developers, and to read the information that you might link to on the web in your replies, if you are willing. Alternatively, I would consider writing my application in C++ or in c#.net instead.


Game-dev-oriented Code Kata?

(I ask here because gamedev.stackexchange.net isn't as exposed to programmers as this site) Code Kata are good programming exercises ( see Code Kata ). I think the provided exercices are good for general problem solving. Now I'm mostly interested into all that is specific to game developpement and similar typical constraints. I mean not the low level stuff (like manipulating texture bits, that's too specific) but more like buffered event systems implementation or similar systems used in typical games. Maybe basic fast collision. Is there a list of game-dev-oriented code kata somewhere?


Does functional programming add complexity in code?

For the entire past year I've been written Scala code (coming from a Java background). I really liked how you could create simpler and cleaner code, with vals, case classes, map/filter/lambda functions, implicits and the type inference. I've used it mostly for an Akka-based application. This year I'm on a Scala project with a new team, who really like functional programming. They heavily use Scalaz, and the code is filled everywhere with applicatives, context bounds, reader/writer/state monad, even the main method is "wrapped" in an I/O monad. Their reasoning is that this makes the compiler "work for us" in asserting that the code is correct, and each function is free from side effects. Even so, from my point of view all this syntax really gets in the way of the business logic. For instance, a type of "MyBusinessObject" is fine, as well are types like "List[MyBusinessObject]", "Option[MyBusinessObject]" or even "Future[MyBusinessObject]". They all have a clear meaning and purpose. On the other hand, code like:               def method[M[_]: Applicative] = {       case (a, b) => (ca[M](a) |@| cb[M](b)) {         case t @ (ra, rb) =>           if (ra.result && rb.result) t.right           else t.left       }     }      does it add complexity to the program, or is it just me that I'm not used to this way of programming?


Large csv's to html report

I am working on a web front end + front end services. I receive good sized csv files (10k lines). My service processes them and condenses them into one larger csv file (up to 300k lines). This larger file will be turned into an html/pdf report after some extrapolation. My questions are:   1. Taking 17,000 files and turning them into 1 takes FOREVER (18 hours last time I tried it). The current process is to take a line of the csv, parse it to see if it exists in my master array, and either create a new entry or add the data to an existing entry in the array. Is there a better way to do this? It seems the last item would take exponentially longer than the first.   2. Once this large file is created, parsing it seems to take quite a while as well. Should I move away from writing to a csv output and go with JSON for speed of data massaging? or even a lightweight db?


What is Component Oriented Programming, and how is it different from OOP?

What exactly is Component Oriented Programming, and how is it different from Object Oriented Programming? Thanks


Where do put INotifyPropertyChanged Interface in Model or ViewModel

I am new to MVVM pattern I have a window which has 3 text boxes namely Name,Address,Description ,a save button and a listview which displays the above fields Name,Address,Description respectively .When the save button is clicked I want to save the fields into database as well as show the record in the listview as well. Where do I put INotifyPropertyChanged interface Model or in ViewModel or in both place?


Call the database every time, or create an object in memory, and if so, how and how often to update?

I'm creating an app in javascript/nodejs and using neo4j as database. Let's say I have an entity `User` in my database. It has a bunch of properties, like `boxes_collected` and `places_visited`, which keep updating independently of one another throughout the course of running my app. So far I have functions that talk to the database to update these properties directly. But it's getting a bit messy and I'm thinking of making a single high level object/class that handles everything in a much cleaner, nicer, and eloquent way. Here's a tiny version of my "model" to better explain what I mean: Suppose I have a function like this               function UpdateUserValue_plants(number) {// update database}      But then if were to create a `User` object and incorporate the above into it,               var User = function User(plants, other...) {         this.plants= plants;     }          User.prototype.updateValue_plants = function(number) {         this.plants += number; // first update the model itself     }      Then when am I supposed to update the database? And wouldn't I be doing the updatation twice that way: first the object's property, _then_ the database? Is there an elegant solution to this?


Something confusing about Single Responsibility Principle

1) > In fact if two responsibilities are always expected to change at the same > time you arguably should not separate them into different classes as this > would lead, to quote Martin, to a "smell of Needless Complexity". The same > is the case for responsibilities that never change - the behavior is > invariant, and there is no need to split it. I assume even if non-related responsibilities are always expected to change for the same reason ( or if they never change ), we still shouldn't put them in the same class, since this would still violate high cohesion principle? 2) I've found two quite different definitions for SRP: > Single Responsibility Principle says that a subsystem, module, class, or > even a function, should not have more than one reason to change. and > There should never be more than one reason for a class to change Doesn't the latter definition narrow **SRP** to a class level? If so, isn't first quote wrong by claiming that **SRP** can also be applied at subsystem, module and function levels? thank you


Code Plagiarism: How hard or how easy to detect this?

Suppose you want to develop an application, in midst of development you find out that one similar application already exists, highly recognized and used. It's a cross platform application but it's unknown whether this application is open source or not. However you decide to reverse engineer it without taking care of its license and eventually you succeed in it. And now you are using some portion of it for your application, which in some manner improvement of the application and -being based on same idea and targeting some platforms that the original application also covers- comes into straight competition of it. Can original developer detect that you plagiarized the original code? If yes how?


Super user powers in development environment?

Is it too much to ask for when I ask the IT department to give my development team an environment where we can use whatever software that we can download without having to have security check those tools? Of course, the software can be checked by security before deploying to Test, and the development environment can be on a VLAN that is not accessible from outside. This would greatly aid us by allowing us to use whatever open-source testing tools that we want. I'm asking because we have such tight restrictions on the software approval process, and I hear of other teams that have an environment where they can configure their local server however they want and they can use whatever tools they want. What's the norm out there? Thank you for any comments!


Code formatting : Laying out functions based on call hierarchy within a class file?

A suggestion from Bob Martin's "Clean code" has me scratching my head.. "If once function calls another, they should be vertically close and the caller should be above the callee" So far, I've been more or less sticking close to the .Net guidelines, which group class members by type (properties, ctors, functions) and visibility (public / prot. / private). The tip seems like trouble at first.. but it "just might work". I personally have encountered cases where I liked this layout - easier to drill down when you're in the right call chain. The idea behind the tip seems sound but other scenarios like "let me look at the public interface of this class" might get worse. Maybe Uncle Bob is banking on the small classes and IDE support for viewing types... Has anyone tried this out for an extended period ? Update: Seems like a code-snippet is in order               class SomeType()     {       /// fields, ctors, et. all       public void Method1()   { // calls HelperMethod1 and HelperMethod2 }       private void HelperMethod1 { // calls HelperMethod3 }       private void HelperMethod3 {}       private void HelperMethod2 {}            public void Method2 () { // and so on... }          }


How do you get past the Analysis to Paralysis when working on a new project?

I've been struggling with how to get my project going. I've got an old software package that is in need of desparate rewrite. I haven't compiled the source code since 2004. It still sells, it's stable but does require the “Run this program in compatibility mode for:” on a lot of the newer windows systems. It's also one of those hard coded 640 X 480 screen resolution programs. Yuck! I can't seem to get started with this rewrite. I'm constantly fiddling around with different things. I'll play around with different fluid layouts for a while. Then I start looking at how the main menu should work and look. I quickly find out that there's this thing called "Cool Bars" and I'll spend hours playing with that. Then I start thinking about stuff like "Oh I need to make sure that the screen sizes are preserved so when the application gets relaunched it remebers how the screens were positioned." Which leads to what happens if they have two monitors? Which leads to what happens if they have a quad screen? Yikes it's got to stop. I have always been a slow starter. I think about stuff long and hard up front. This has always plagued me. Once I get my mind made up though bam... I'm off and running. I'm looking for advice from some other one-person software companies that can help someone like me get off to a quicker start? ### Success Thanks to everyone for your motivation. I finally have a plan in place. I wish I could split the vote between @haylem and @ThorbjørnRavnAndersen. I went to download.com and filtered the downloads by my software category. I sorted by "Editors Pick" and downloaded a couple of the highest rated programs. On the second hit I found the final piece of inspiration I needed. I love yellow sticky notes. ![enter image description here](http://i.stack.imgur.com/086P7.jpg)


EJB Lifecycle and Relation to WARs

I've been reading up on EJBs (3.x) and _believe_ I understand the basics. This question is a "call for confirmation" that I have interpreted the Java EE docs correctly and that I understand these fundamental concepts:   * An EJB is to an App Container as a Web App (WAR) is to a Web Container   * Just like you deploy a WAR to a Web Container, and that container manages your WAR's life cycle, you deploy an EJB to an App Container, and the container manages your EJB's life cycle   * When the App Container fires up and deploys an EJB, it is given a unique "identifier" and URL that can be used by JNDI to look up the EJB from another tier (like the web tier)   * So, when your web app wants to invoke one of your EJB's methods, it looks the EJB up using some kind of service locator (JNDI) and invoke the method that way Am I on-track or way off-base here? Please correct me & clarify for me if any of these are incorrect. Thanks in advance!


Starting a career in quantitative finance

I've been reading John Hull book (Options, Futures and Other Derivatives) mostly on curiosity. I've read other books about financial markets in the past (like Elder's Trading for Living and the novel Reminiscences of a Stock Operator). But I'm really hooked by the John Hull book. My background is mostly scientific computing: number crunching, visualization and image processing. Mostly in C++, with some C, Fortran, Python, Ruby here and there. I've been thinking on moving on to quantitative finance - I'd like to do that. What would be the best way to start? Any tips?


What is the difference between Single Responsibility Principle and Separation of Concerns

a)What is the difference between **SRP** and **SoC**? Perhaps that **SRP** is applied at class level, while **SoC** can be applied at _system_ , _subsystem_ , _module_ , _class_ or _function_ levels. b) If answer to _a)_ is yes, is then _SoC_ applied at _class level_ a synonym for **SRP**? thank you


How useful is it to double major in Electrical Engineering and Computer Science?

I'm halfway through a double major in both and love the subjects equally as much, I'm just starting to really dislike the people in Electrical Engineering so much so that I kind of want to stop taking the classes in EE. Are there any jobs that would require or be especially helpful to have both majors completed?


How to name a private method in a language which doesn't support privacy?

What's the coding standard for naming a private method in a language which does not have the private modifier? Specifically, I am talking about Javascript. Below I've placed an underscore at the end of my private method's name, but a colleague told me that underscore is usually for class fields.               var MyClass = Class.create({         initialize: function() {             alert('constructor');         },         publicMethod: function() {             alert('i am public');         },         privateMethod_: function() {             alert('i am private');         }     });


Has anyone used functional testing tools to grade student lab exercises?

I'm working on classes that cover software tools and languages. Obviously the classes are going to be more valuable if the students actually **do** some of what they're supposed to be learning, so I'm planning to incorporate lab work. Has anyone used automated functional testing tools to grade lab assignments? Lab 1 is to install Apache, so the testing server looks to see that your lab machine is listening on port 80, and responds with the default index page. Lab 2 is to create a page that takes `?name=MyName` and responds "Hello, MyName!", so the testing server GETs `?name=random` and expects "Hello, random!". If you haven't used them this way yourself, what tools **might** be a good candidate?


Where in computer science education does "reuse and integration" find comprehensive coverage?

**This intro is only my naive attempt at a mile-high snapshot helping me to position my question.** Any user trying to answer my question, that tries to nail down one aspect of programming, will have to overcome my naive understanding, simply because of my idiosyncratic education. So here I'm placing my subject in the array of topics outlining programming and software activities:   1. Fundamentals of programming (software design patterns, idioms, models)   2. Code reuse and integration (libraries, frameworks, apis)   3. Continual development (documentation, commenting, version control)   4. Maintenance best practices (systems administration) * * * I'm interested to focus my programming skills on code reuse and integration topics. This topic may certainly begin with software programming languages and the differences between functional and object-oriented programming. However, what I wish to focus on _in detail and at some length are the variety of uses of libraries, frameworks, and apis._ My programming education comes from what I can readily find on the internet and in books. Earlier this year I enrolled in a class on fundamentals at Coursera, Programming Languages, by professor Daniel Grossman, which attempts to prepare students for programming in any language. Reuse was mentioned only as a property of functions and object. _You can start your search for 'reuse and integration' in fundamentals and not get close._ Since I started learning some Ruby, php I've put together a better understanding of 'reuse and integration', but its all cobbled and patchwork. Published materials are mostly #1 and then some idiosyncratic mix of #2-4. _You can read a lot of books and still not understand how all of these abstractions fit together._ I've even participated in a discussion here at p.se on the pedagogical problem of cargo-cult programmer students who " _...copy-paste code from previous, similar-looking assignments..._ " While my own answer to this reflects my appreciation for the OP's concern, and yet my imagination can't help envying these students who can draw with such ease from previous projects _just a little bit._ I've not read the book or participated in a class or heard a discussion which attempts to survey the reuse and integration paradigms in their totality. Where in computer science education does “reuse and integration” find comprehensive coverage?


Software attribution / design credits

We just completed developing a web app for a client. And like I usually do, I added developed by "My Company" at the footer at a very small insignificant size. I sent the client an End user license stating some of the following in summary               you can't resell, redistribute, etc without our notice     ...     you can't remove the attribution or design credits      the client got back to me and complained, telling me now that he was also developing for someone, and that 'I can't add my attribution' without his/her consent, but? Although I sign a NDA within summary states that I cannot disclose the software to anyone else. There was no agreement before the project that am not to add design credits or attribution. I know every software I install have that, and so is every products from companies, mostly technological products. How does this work (adding design credits)?


What is the shortcoming of custom factory comparing to generic factory

I have a factory method as given below               public class AutomobileFactory     {         Dictionary<string, ICar> internalFactory = new Dictionary<string, ICar>();         public AutomobileFactory()         {             internalFactory.Add("fiat",new Fiat());             internalFactory.Add("ford", new Ford());         }              public ICar Create(string carType)         {             return internalFactory[carType];         }     }      It is a very humble code. Now, I referred Factory pattern with generics. But I am not able to understand what extra this generic approach can offer. **QUESTION** What is the shortcoming of the above given factory when compared to the generic factory?


How would an algorithm that splits/sorts numbers into three groups to make them equally large work?

I have to write an algorithm to split/sort numbers into three groups to make them equally large. To be more specific: I have three groups, let's call them **A** , **B** and **C**. Then I have a lot of numbers. Each number has assigned a group to which it belongs, but the thing is, that one number could belong to one of two or one of three groups (to one of them, but we don't know exactly to which one). Sample data:               Number | Group      1      | A (this number HAVE TO be in group A)      2      | A      3      | B      4      | C      5      | AC (this number can be in group A or C)      6      | BC (can be in group B or C)      7      | A      8      | B      9      | ABC (can be in group A, B or C)      ...       One of the correct results of this sample can be:               A: 1, 2, 7      B: 3, 8, 9      C: 4, 5, 6       It doesn't matter which group is chosen if there were multiple groups assigned to one number (it would be best if it is chosen randomly). The goal is to split those numbers to make each group equally large (or as close to it as possible). My question is: How would you write algorithm to achieve the desired result? Pseudo code or verbal description is enough.


Paradigms fit for UI programming

This is a more specific question (or actually two, but they are related) coming from the comments of OOP technology death where someone stated that OOP is not the right paradigm for GUI programming. Reading the comments there and here I still have the feeling there are things to learn: which programming paradigms are considered good fits and why are they better than others (perhaps with examples to illustrate?) _I removed the tk-example from the title and question_


Are there good places to link people to for software licenses "in plain english" similar to how Creative Commons does?

If you click the cc-wiki link at the bottom of this site, you get a nice plain-english description of what you are and are not allowed to do. The legal stuff is there too, but as someone looking to use a library, I don't want legalese, I want a list of what I can and cannot do. Does a similar resource exist for software license, such as MIT, BSD-3clause, BSD-4clause, BSL, GPLv2, GPLv3, etc?


As per IEEE 12207, who has to perform SW integration testing?

As per IEEE 12207, who has to perform Software integration testing (SOIPL): SW Testing team or SW Development team?


How have Guava unit tests been generated automatically?

Guava has unit test cases automatically generated: > Guava has staggering numbers of unit tests: as of July 2012, the guava-tests > package includes over 286,000 individual test cases. Most of these are > **automatically** generated, not written by hand, but Guava's test coverage > is extremely thorough, especially for com.google.common.collect. How they were generated? What techniques and technologies were used to design and generate them?


Strange names for revisions?

I'm working at a company that has a strange policy. They can't stick to a single name for a software revision. For some reason they have branches, versions, releases and perhaps another term. They never explain what these mean. What is the standard way to separate out different revisions to be less confusing?


Is software development a field suitable for people who have unconventional methods of solving problems?

I tend to think very independently, often coming up with unconventional, sometimes unorthodox, ways of solving problems. I do not like to listen to authority, such as having to write code a certain way or following strict guidelines and formats. Would the software engineering field be tough for someone like me? If not, what fields of computer science do allow for that?


Order of executions in C++ streams

It is obvious that first cout prints 7 7 but why the second one prints 8 8 7 ? Why not 7 8 8? How does such constructions work in c++?               int ink(int *x){          *x += 1;          return *x;     }                    int main(){         int *a;         int b = 6;              a = &b;              cout << ++b << " " << b << endl;            cout << b << " " << ink(a) << " " << b;              return 0;      }


Questioning pythonic type checking

I've seen countless times the following approach suggested for "taking in a collection of objects and doing X if X is a Y and ignoring the object otherwise"               def quackAllDucks(ducks):       for duck in ducks:         try:           duck.quack("QUACK")         except AttributeError:           #Not a duck, can't quack, don't worry about it           pass      The alternative implementation below always gets flak for the performance hit caused by type checking               def quackAllDucks(ducks):       for duck in ducks:         if hasattr(duck,"quack"):           duck.quack("QUACK")      However, it seems to me that in 99% of scenarios you would want to use the second solution because of the following:   * If the user gets the parameters wrong then they will not be treated like a duck and there will be no indication. A lot of time will be wasted debugging why there is no quacking going on until the user finally realizes his silly mistake. The second solution would throw a stack trace as soon the user tried to quack.   * If the user has any bugs in their quack() method which cause an AttributeError then those bugs will be silently swallowed. Once again time will be wasted digging for the bug when the second solution would simply give a stack trace showing the immediate issue. In fact, it seems to me that the only time you would ever want to use the first method is when:   * The block of code in question is in an extremely performance critical section of your application. Following the principal of "avoid premature optimization" you would only realize this of course, after you had implemented the safer approach and found it to be a bottleneck.   * There are many types of quacking objects out there and you are only interested in quacking objects that quack with a very specific set of arguments (this seems to be a very rare case to me). Given this, why is it that so many people prefer the first approach over the second approach? What is it that I am missing? Also, I realize there are other solutions (such as using abcs) but these are the two solutions I seem to see most often for the basic case.


What is a good design for a container, assignment and items

------------- 1    * -------------- *       1 --------         | Container |--------| Assignment |-----------| User |         -------------        --------------           --------               ^                     ^               |                     |           ----------            -------------           |        |            |           |     ---------- ----------  ---------- ---------------     | Flight | | Dinner |  | Booking| | Reservation |     ---------- ----------  ---------- ---------------      This problem is one that I've stumbled upon in several different occasions but never found an elegant solution for: In my system model (in rails), which maps to the database, I need to have `Users` that can be added to `Containers` through `Assignments`. Now, there can be many things that can be containers:   * A `Flight` is a `Container`. It can hold `Users`. In such a case the concrete `Assignment` is a `Booking`.   * A `Dinner` is a `Container`. It can hold `Users`. In such a case the concrete `Assignment` is a `Reservation`.   * And many more. You get my point. So I have Abstract notions of `Container` and `Assignment`. `Containers` hold `Assignments` and I also have concrete implementations of them, with each concrete implementation of `Container` matching a concrete implementation of `Assignment`. The straight forward design is as above. My main problem with it is that it doesn't express the relation between each concrete container and the concrete assignment. Any ideas how to better design this?


Web developer to software engineer

I'm currently a web developer building web apps in PHP and Javascript. I really enjoy the programming aspect more so than the front end design side of things. I would to like to start to focus my attention on this with the aim to becoming a software engineer in next couple of years. So my first thought was to go and learn C++ but is this the best thing to start? In the future I would like to work on developing things such as operating systems and native applications. When I look at at engineering jobs at say, Google, Facebook, Apple, they all appear to ask for **C/C++ AND OR JAVA**. Currently, I know none of these, but I am familiar with generic programming concepts such as loops, functions, oop etc. Also, out of C/C++ and JAVA which is the more probably chance of it getting me ahead in my career? My problem would be that while learning say 'C++' what would I use it for? I currently have no use for it but really would like a career as a serious engineer rather than just web based stuff. I have a mac and PC running linux and would like to start with some example projects and tutorials to just get a good understanding of the language


How to interact with C++ API through http commands?

I have a C++ API, I want to send commands through http to run any c++ method from this API. I'm using libmicrohttpd. What steps should I follow to do such a work?


Contract review for international contracting

I am intending to work as an independent contractor, writing software for a client based in another country. My work will be provided electronically so I won't need to relocate. However, there is a legal dilemma, as I see it:   1. If the draft contract stipulates that governing law is the law of the country where the client is based, I will find it very difficult to find a lawyer willing to review the contract. (This has been my experience.)   2. If the draft contract stipulates that governing law is the law of my country, the client will face the same problem: _they_ will find it very difficult to find a lawyer willing to review the contract. Right?   3. _There is no realistic third option_. The contract has to stipulate a choice of law - anything else would be ridiculous. Let me go into more detail on why option 1 is difficult:   * Lawyers in my country, who know only my country's law, will simply throw up their hands and say "Can't help you - unless you get the stipulated law changed".   * Expatriate lawyers from the client's country, working in this country, even if they are from the right state or province, will probably be too busy working for corporate clients to be interested in my (from their perspective) petty little contract review.   * So, it looks like my only option remaining is... hire a lawyer based in the client's country? And interact with them by phone/VOIP, email and fax? Is this possible? Will it even be _legal_ for them to take on me as a client? How can I get a recommendation? Is there anything I'm missing?


Security comparison between xmlHttpRequest and HttpRequest

Is there a difference between HttpRequest and xmlHttpRequest in terms of security? Is one more secure than the other? Is it more secure to send important data such as passwords via HttpRequest than via xmlHttpRequest ? Is data packing in both done the same way?


Load Balancing for Listeners

How should we load balance listeners to a 3rd party service? e.g. We need to read gtalk messages via XMPP Listener and build an application using the interactions of the user with a chatbot. In such a case, how would we ensure that we can have XMPP listeners on multiple servers and we load balance the messages between the listeners? Thanks in advance.


Should you ever release something that you yourself could hack?

Being the creator of a program, you are probably in a better position than anyone to be aware of security vulnerabilities and potential hacks. If you know of a vulnerability in a system you wrote, is that a sign that increased security MUST be added before release, or should this be evaluated on a case by case basis to determine the severity of the security gap?


Why are data constructors with the same name disallowed in different type constructors?

The following declaration gives an error:               type Vec2d = (Float, Float)     type Vec3d = (Float, Float, Float)     -- Rect x y defines a rectangle spanning from (0,0) to (x,y)     data Obj2d = Rect Float Float                | Translate Vec2d Obj2d     -- Cuboid x y z defines a cuboid spanning from (0,0,0) to (x,y,z)     data Obj3d = Cuboid Float Float Float                | Translate Vec3d Obj3d      namely `Multiple declarations of 'Translate'`. Now, I wonder why this limitation was introduced? If the limitation were not there, one could write `Translate (1, 1) Rect 2 2` and `Translate (1, 2, 3) Cuboid 1 1 1`, which sounds natural. I don't (immediately) see how this could result in a parsing problem bidding to disallow using the same name, the type could be inferred by the argument (`Rect 2 2` is an `Obj2d`, `Cuboid 1 1 1` is an `Obj3d`). I'm sure there is a good reason the language designers chose to disallow using the same name for data constructors of different types, but I'd like to learn: why, when it's not obviously necessary? (And type disambiguation is the bread-and-butter business of Haskell!)


Why are cyclic imports considered so evil?

Seriously, what's the big deal about having a few cycles in one's import graph? I see it as a lesser evil than having super fine grained imports that make keeping track of where to look for what code an absolute nightmare.


Can the Turing machine be classified?

Can the Turing machine be classified e.g. as a Mealy machine? Why not? Can a Turing machine be input to another Turing machine without complication like halting problems? Thanks


My experiences are server side programming and database management, I want to learn C++, where do I start?

The title is the topic, since I'm mainly a web developer,my hacking ability is limited to those loose type languages like PHP and Javascript. But I want to be more capable programmer. I saw Hip Hop PHP made by Facebook and realized that C++ is a must, I mean they reduced the CPU usage by 50% and added 1.8% performance improvement. So I made up my mind that I need to get serious in C++ language. Can you please show me where to start, some friendly tutorials. because I read some tutorials in C++ and noticed that it's very different from PHP.