How easy should a language development framework be to use?

> This is part of a series of questions which focuses on a project called the > Abstraction Project, which aims to abstract the concepts used in language > design in the form of a framework. > > Another page associated to it related to structural typing can be viewed > here. The meta-topic associated to an inquiry about the framework and the > proper place to post can be found here. How easy should it be to use a Language Development Framework? I've written large scale code generation frameworks which also included the ability to send the result to the language-specific compiler. The topic of ease of use comes up from one such framework example: CodeDOM, or the Code Document Object Model. It is a framework written by Microsoft that describes common code structures, but generally left a lot out (expression coercions) and tended to be a bit abstract in its representation of certain constructs, to downright emitting bad code based upon what you were doing: earlier CodeDOM poorly handled emitting `PrivateImplementationType` on `CodeMemberMethod`, when the type used was a generic interface. CodeDOM was my original reason for writing my first code generator. One thing I'm trying to do, to simplify the framework, is reduce the amount of work you need to do something, and focusing on actions versus the specific types that make up those actions. Here's a side by side comparison of how the framework I'm writing works:               //Truncated...     /* *      * From a project that generates a lexer, this is the       * state->state transition character range selection logic.      * */     var nextChar = nextMethod.Parameters.Add(new TypedName("currentChar", typeof(char).GetTypeReference()));     //...     char start = rangeElement.B.Value.Start;     char end = rangeElement.B.Value.End;     /* *      * 'start' <= nextChar && nextChar <= 'end'      * */     currentExpression = start.LessThanOrEqualTo(nextChar).LogicalAnd(nextChar.LessThanOrEqualTo(end));      Versus CodeDOM:               //Truncated...     var nextChar = new CodeVariableReferenceExpression("nextChar");     //...     var start = new CodePrimitiveExpression(rangeElement.B.Value.Start);     var end = new CodePrimitiveExpression(rangeElement.B.Value.End);     currentExpression = new CodeBinaryOperatorExpression(new CodeBinaryOperatorExpression(start, CodeBinaryOperatorType.LessThanOrEqual, nextChar), CodeBinaryOperatorType.BooleanAnd, new CodeBinaryOperatorExpression(nextChar, CodeBinaryOperatorType.LessThanOrEqual, end));      The focus of the framework is language enthusiasts, as well as those interested in generating code or applications. Given its focus on compilation, code generation, and language development, should the framework focus on ease of use or raw power? My primary goal is to increase the availability of such tools, so those interested in the domain don't require a lot of experience in the language theory domain before they can start to work on their own language-centric projects. Given that I'm the author of the framework, my view of "usability" is biased. Thus, I must ask another if the focus and goal make sense to others who aren't associated to the project.


Certifications for software development companies - CMMI, ISO etc

What are the certifications that software development companies usually get? One example would be CMMI, or ISO 9000. What other certifications are out there for software development companies, and how important having them really is for attracting clients?


Writing or extending existing emacs packages: is it worth or should I move to Netbeans/Eclipse?

I'm finishing my master degree course in CS and I've almost become addicted to Emacs. I've used it to write in C, Latex, Java, JSP,XML, CommonLisp, Ada and other languages no other editor supported, like AMPL. I'd like to improve the packages I've been using the most or create new ones, but, in practice, I find that the implementation of Emacs leaves a lot to be desired. There are a lot of poorly-featured/poorly-maintained packages with either overlapping functionalities or obscure incompatibilities, and Elisp just seems to foster the situation by lacking the common features modern lisps have. In contrast Eclipse and Netbeans are actively improved and it does seem they can be effective for non-mainstream languages. I tried Hibachi for Ada in Eclipse and it worked well, there's CUPS for Lisp in Eclipse and LambdaBeans built using NetBeans components. On the other hand those plugins seem to be less active than their Emacs' counterparts, for example Hibachi was archived last year. What's your opinion on this? Which editor should I write extension for? **EDIT:** To answer Larry Coleman (see comment below):   1. I like Emacs as a _user_ because it is efficient both for me and the computer I'm using. It's fast and the textual interface (i.e. minibuffer) allows for quick interaction. It's solid and packages are usually small and easy to manage. If I need to correct or remove something I usually just have to change a row in my .emacs or an elisp file, or delete a directory. Eclipse plugins rely on a more complicated process that screwed my Eclipse configuration a couple of times, forcing me to do a clean reinstall. Emacs works as long as I use the basic packages. If I need something more complicated the situation gets pretty hairy. As a "power user" I think that the best I can hope for is to write a severely crippled version of the extensions I'd actually like to have; in other words, that it's not worth the trouble.   2. I'd like to write extensions for the things I'd like to have automated in Emacs, for example project support with automated tag-table update on file writing. There are a few projects on this that lack integration, documentation, extensibility and so forth. The best one is probably CEDET, for which I believe the Greenspun's 10th rule can be applied. **EDIT:** To comment Larry Coleman's answer I'm pretty sure I can pick elisp programming but the extensions I have in mind don't exist yet despite their relative simplicity and the effort more knowledgeable people poured into related projects.This makes me wonder whether it is so because of the way emacs is developed, i.e. people tend to write their own little extensions without coordination, or its implementation, its extension language not being able to keep up with the growing complexity.


How can a maintenance-only programmer get a raise?

I have been working as a maintenance programmer for a couple of years and am wondering if there is such a thing as a raise for maintenance programmer? I ask because responsibilities don't get wider, you're still doing almost the same things, maybe a little faster as time passes. If it's possible, then what would be the path to get it?


Avoiding Packages with High Efferent Coupling

I use java language to develop android application, after static analysis, the tool warns about high efferent coupling. What is the reason of this warning? Is it about AComModel which is extended by other class? There are 4 classes below which the tool warns us about them. I hope I asked logical question, but I really don't understand what is the problem?               public class AComModel {             public String GetComBusinessKey() {             return "none";         }     }               @JsonIgnoreProperties(ignoreUnknown = true)     public class StepOneCom extends AComModel {              public View vi;         public ArrayList<SummaryViewModel> lstSmr;              @Override         public String GetComBusinessKey() {             return "shvi";         }          }               @JsonIgnoreProperties(ignoreUnknown = true)     public class StepTwoCom extends AComModel {              public ArrayList<AccViewModel> lstAcc;         public SummaryViewModel c1;                   @Override         public String GetComBusinessKey() {             return "shvi";         }          }               @JsonIgnoreProperties(ignoreUnknown = true)     public class StepThreeStepTwoCom extends AComModel {              public StepFourCom stepFourCom;              @Override         public String GetComBusinessKey() {             return "cashadvi";         }     }


Where are the Interface information stored?

I would like to know whether the information in an interface such as the variables which are final and the methods which are abstract and static would all live in method area ??? And what would be there order in case of initialization? Would they be initialized before any of the non static variables or methods?


Company name already taken at github

My research-based company's name is already taken on github (mailed the owner without any luck), what is the most recognized naming conventions for company github accounts besides the name directly? the only ones I found was `ibm-dojo` and `ibm-research`


SpecFlow/Cucumber - Documenting available steps

Our company is looking at implementing BDD in our .NET application. Specifically, SpecFlow. We can foresee a large number of common steps being created ('Given a customer', etc), so what methods have been used to document these, so that the business can reference them? Is XmlDoc on the step definition classes sufficient, or have others found better methods of documentation?


What are some conventions that are often mistaken for language features?

Some programming languages have constructs that because of their frequent use are often mistaken for language features. For example, many people think that `self` is a keyword in Python, but it's just the conventional name for the first argument to a method (you can use any variable name you want):               class Complex:         def __init__(self, realpart, imagpart):             self.r = realpart             self.i = imagpart      Another example: when I was learning R, I thought the syntax for filtering a vector was kind of weird:               d[d %% 2 == 0] # even elements only      At first I thought `d %% 2 == 0` was some sort of lambda that gets magically applied to every element of `d`, until I realized that this is a straightforward application of R's vectorized operations: `d %% 2 == 0` returns a vector like `[TRUE, FALSE, FALSE, ...]`, and then `d` just uses that list to filter values that are at positions marked as `TRUE`. What are some other constructs that may first appear to be specially designed language features, but are just straightforward applications of the language's core syntax & semantics?


Best place to put classes that extend the .net framework?

I have no clue where to put the following class and I've noticed I just keep putting them in a helpers folder which isn't much helpfull towards reusability in future projects. **Example:** I want to have the ability to use the `DisplayNameAttribute` together with resource files. In order for this to work I made a `LocalizedDisplayNameAttribute` which inherits the ´DisplayNameAttribute´ and adds the following properties `DisplayNameResourceName` and `DisplayNameResourceType`. In which namespace/location would you place such a class which is likely to be reused in future projects?


Keep or discard tests that use methods now private

When writing object-oriented code from scratch, I try to follow these steps:   1. Write a test that fails.   2. Write a **function** that makes the test pass.   3. When enough tests and functions are complete, refactor functions with similar signature into a **class**.   4. When the class functionality is complete, **make private** as many of the class methods as possible. The last step seems sound to me, since object orientation is all about hiding complexity behind abstractions, and keeping the public part of those abstractions as small as possible. However, this leads me to discard many of the tests that I wrote when still working with plain functions -- since they are now testing the private part of a class' API. This makes me uncomfortable because:   * remaining tests are suddenly forced to **"cover more complexity"**.  For instance: if I wrote a method to `swap_rows` in a matrix while inverting it, but that method is now private and only used from the public method `invert`, then the `test_invert` has to somehow convey to the reader that "swapping rows happens while inverting". More importantly, that remaining test possibly will not pinpoint that it is the swapping of rows that has been broken by a careless change (and not any other part of the inverting process).   * private class methods may **become public again** when writing client code that has a reasonable cause to access their results. This is difficult to foresee. Recovering the tests from a previous commit is possible but it feels like wasted time. A solution would be to refactor the methods out into a helper class that is package private. However, this looks like abusing object-oriented principles for the sake of TDD principles; also, it makes me wonder if there will ever be a good reason to make something private at all. I realize I am asking here about "how to grow an architectural design", and that this cannot be done in a completely "bottom-up" approach; but I would like practical advice on keeping or discarding such early tests while still figuring out the shape of a piece of software. This question is similar, but here I do not question that it is possible to get an initial public API right with TDD: I seek for good advice on how to get there. This answer is useful, but I do not think I am trying to adapt my coding to my tests, but rather my tests to my -- still uncertain -- design. To summarize: should I keep or discard early tests while writing object- oriented code from scratch? Should I still strive to make as many methods as possible private, or is this leading me to a bad design and the forced removal of tests is just a symptom thereof?


Decorator Pattern in Head First Design Patterns

I'm trying to teach myself some design patterns using a book that I was recommended, Head First Design Patterns. I came to the chapter on the Decorator Pattern, and although I understand the purpose of it, I'm a bit fuzzy on it's layout. Here is their basic UML of the Decorator pattern: Imgur (Sorry for the link, but SE won't let me upload a photo here for some reason) Here is how they wrote out the code:               public abstract class Component {         String description = "Unknown Description";              public String getDescription() {             return description;         }              public abstract double cost();     }          public class ConcreteComponent extends Component {         public ConcreteComponent() {             description = "I am a concrete component";         }              public double cost() {             return 1.99;         }     }          public abstract class Decorator extends Component {         public abstract String getDescription();     }          public class ConcreteDecorator extends Decorator {         Component component;              public ConcreteDecorator(Component component) {             this.component = component;         }              public String getDescription() {             return component.getDescription() + " with a decorator";         }              public double cost() {             return .20 + component.cost();         }     }      My question is, what is the need for a Decorator class in this situation? Why not leave getDescription() abstract and let ConcreteComponents and ConcreteDecorators implement it the way they need? As a follow up, are there actual benefits to creating a Decorator class? This example doesn't seem to cover why it's useful or how it could be useful.


Rails Google Cloud Messaging with heroku

I'm looking at using GCM to send notifications from my rails app to an Android app. The getting started guide says:               In the resulting configuration dialog, supply your server's IP address.      I'm using Heroku, so the IP address is changing frequently correct? Can I still use GCM? Was looking at using the rails gem and I couldn't find any documentation related to Heroku.


Does HTML5 have a feature that enables a user to add an icon to the Apps screen when "installing", and if not, when are they planning to add it?

I know that the mobile bookmark bubble might sort of work for iOS, but it isn't going in the same section. And for Android, bookmarking is really not going to cut it for a mobile HTML5 application install since users just don't think to go to their bookmarks and that bookmark process takes two or three steps. To me this issue of getting the application (bookmark) installed pretty much makes the rest of the HTML 5 features aimed at mobile HTML much less useful. I can't realistically expect users to prefer the bookmark install and launch process over regular apps, so I can realistically expect them to ignore my mobile HTML5 application and use a native app. The groups behind mobile HTML 5 features do seem to be pushing for HTML 5 apps adoption with things like Application Cache etc. To me it seems obvious that the bookmark bubble is not going to cut it. Someone please tell me they have addressed this or at least are working on it?


Is there a language or design pattern that allows the *removal* of object behavior or properties in a class hierarchy?

A well-know shortcoming of traditional class hierarchies is that they are bad when it comes to model the real world. As an example, trying to represent animals species with classes. There are actually several problems when doing that, but one that I never saw a solution to is when a sub-class "looses" a behavior or properties that was defined in a super-class, like a penguin not being able to fly (there are probably better examples, but that's the first one that comes to my mind, having seen "Madagascar 2" recently). On the one hand, you don't want to define for every property and behavior some flag that specifies if it is at all present, and check it every time before accessing that behavior or property. You would just like to say that birds can fly, simply and clearly, in the Bird class. But then it would be nice if one could define "exceptions" afterward, without having to use some horrible hacks everywhere. This often happens when a system has been productive for a while. You suddenly find an "exception" that doesn't fit in the original design at all, and you don't want to change a large portion of your code to accommodate it. So, is there some language or design patterns that can cleanly handle this problem, without requiring major changes to the "super-class", and all the code that uses it? Even if a solution only handle a specific case, several solutions might together form a complete strategy. [EDIT] Forgot about the Liskov Substitution Principle. That is why you can't do it. Assuming you define "traits/interfaces" for all major "feature groups", you can freely implement traits in different branches of the hierarchy, like the Flying trait could be implemented by Birds, and some special kind of squirrels and fish. So my question could amount to "How could I un-implement a trait?" If your super-class is a Java Serializable, you have to be one too, even if there is no way for you to serialize your state, for example if you contained a "Socket". So one way to do it is to always define all your traits in pair from the start: Flying and NotFlying (which would throw UnsupportedOperationExceiption, if not checked against). The Not-trait would not define any new interface, and could be simply checked for. Sounds like a "cheap" solution, in particular if used from the start.


Can the concept of Entropy be used to analyze source code in a useful way?

It seems logical to me that one could define a context for static source code analysis that included rules to produce a relative value of complexity. I know it is not like in the physical sense because souce code doesn't have "Energy" but I'm betting there have been efforts, at leat academic, to draw a parallel. Has anyone any knowledge of this and if so, to what end has it produced useful results?


Getting My Head Around Immutability

I'm new to object-oriented programming, and one concept that has been taking me a while to grasp is immutability. I think the light bulb went off last night but I want to verify: When I come across statements that an immutable object cannot be changed, I'm puzzled because I can, for instance, do the following:               NSString *myName = @"Bob";     myName = @"Mike";      There, I just changed myName, of immutable type NSString. My problem is that the word, "object" can refer to the physical object in memory, or the abstraction, "myName." The former definition applies to the concept of immutability. As for the variable, a more clear (to me) definition of immutability is that the _value_ of an immutable object can only be changed by also changing its location in memory, i.e. its reference (also known as its pointer). Is this correct, or am I still lost in the woods?


Rewriting/decoupling important service of the Django website in Erlang

We have application written entirely in Django, which consist of three separate components. Admin, Service for generating invoices + API and UI for users. Problem is, that they are very tightly coupled (even they're kind of split, each components has it's own settings, and can run 'standalone' - well, this is often not really true, since they all share same models and some functionality from the views, ie. error on the UI means most of the time that invoice generating service is down also. Problem is, that generating invoices is very crucial part of our business. We also push some data to the client, and we use AMQP, websockets, tornado and celery to do this. I looked on Erlang and found out, that it's exactly perfect fit for our invoice generating service. We could exchange Celery, Tornado and AMQP (it is written in Erlang anyhow as far as I know), just for Erlang. We are at very early stage, where only one invoice is created every few hours, so it's not that big of a deal now, but I can imagine how big problems this might cause in the future. My question is, whether it's good to do such decoupling now (when the problem really does not exist), or focus on the adding new features to the product and start to solve this once this will start being an issue? Part of the problem is, that quite big part of the application logic is in the Django models itself. We use quite a lot signals, pre/post save hooks etc., so we would lost this functionality by for instance writing to the database directly from Erlang, but I feel, that this might save us a lot of pain in the future.


Inversion of Control in ASP.NET MVC

I was going to refactor my ASP.NET MVC application and inject some IoC. Last time I was using IoC, Unity was all the rage, but I hated it. It was difficult to setup and had very nondescript errors. Does anyone have any suggestion or preferences?


Buzzword for "performance-aware" software development

There seems to be an overabundance of buzzwords for software development styles and methodologies: Agile development, extreme programming, test-driven development, etc... well, is there any sort of buzzword for "performance- aware" development? By "performance awareness", I don't necessarily mean low-latency or low-level programming, although the former would logically fall under the blanket term I'm looking for. I mean development in which resources are recognised to be finite and so there is a general emphasis on low computational complexity, good resource management, etc. If I was to be snarky, I would say "good programming", but that doesn't seem to get the message across so well...


Understanding Visitor Pattern

I have a hierarchy of classes that represents GUI controls. Something like this:               Control->ContainerControl->Form      I have to implement a series of algoritms that work with objects doing various stuff and I'm thinking that Visitor pattern would be the cleanest solution. Let take for example an algorithm which creates a Xml representaion of a hierarchy of objects. Using 'classic' approach I would do this:               public abstract class Control     {         public virtual XmlElement ToXML(XmlDocument document)         {             XmlElement xml = document.CreateElement(this.GetType().Name);             // Create element, fill it with attributes declared with control             return xml;         }     }          public abstract class ContainerControl : Control     {         public override XmlElement ToXML(XmlDocument document)         {             XmlElement xml = base.ToXML(document);             // Use forech to fill XmlElement with child XmlElements             return xml;         }     }          public class Form : ContainerControl     {         public override XmlElement ToXML(XmlDocument document)         {             XmlElement xml = base.ToXML(document);             // Fill remaining elements declared in Form class             return xml;         }     }      But I'm not sure how to do this with visitor pattern. This is the basic implementation:               public class ToXmlVisitor : IVisitor     {         public void Visit(Form form)         {         }     }      Since even the abstract classes help with implementation I'm not sure how to do that properly in ToXmlVisitor? The reason that I'm considering Visitor pattern is that some algorithms will need references not available in project where the classes are implemented and there is a number of different algorithms so I'm avoiding large classes.


Connecting to users local machine from my WebApp

I have a Web App that i have developed I am looking to develop a plugin for this app so that i can pull information from the users accounts package such as sage or quickbooks(offline version). Ideally I would like to do this without them having to have a static ip etc. Unfortunately this is way over my head I currently have no idea on how to do this. Please can some one guide me in the right direction I will probably use json data between the webapp and the client service that I will make and im fine with that part its just the initial connection that I am confused about. Any help would be really really appreciated I hope this makes sense. Thanks Ash


Is PHP-GTK widely used?

Is PHP-GTK widely used for desktop application? Is it recommended to use? Is there a big company who uses PHP GTK?


Do programmers need to know about graphic designing?

I want to know your opinion. Do programmers (like me) need to know about design? For example drawing, web design, image manipulation etc.               Edited      Actually, I like web, enterprise and mobile programming. Thanks :D


Does it make sense to use jQuery in modern-webkit-only web applications?

I'm lately working on a few mobile web apps for Android (2.3+) and iOS (4+). Their browsers support most of ECMAScript5, which is very powerful, and I wanted to use language features where possible, resorting to jQuery only when I had to. Turns out the only thing I use jQuery for is to have a shorter alternative for `document.querySelectorAll`. Might as well get rid of it. If I only have to support modern WebKit browsers, is it a good idea to get rid of jQuery (and other general-purpose libraries)? They are a layer of indirection, after all. (The apps don't have to make AJAX calls so far, I guess that's one thing that's going to get ugly. But is it worth keeping jQuery just for that?)


The ViewController design in iOS vs MVC in tradiational web apps design

As I came from the background of webapps and move to iOS programming, I am wondering why we can't just apply the MVC design approach to native apps, i.e. in iOS, the view and controller are tightly coupled, are there any reason?


Computer science curriculum for non-CS major?

I would like to have some ideas for building up my foundation CS skills. I have started programming computers 10 years ago and have made a pretty good career out of it. However, I cannot stop thinking that the path that brought me here was very particular, and if something goes wrong (e.g. I get laid off) it would be harder to find a job here in the US on the same salary level, OR in a top company. The reason I say that is that I am a self-learner; my degree is not in Computer Science so although I master C/C++/Java, I do not have the formal CS and mathematical background that many other software developers (esp. here in the US) have. When I look at job interview questions from Apple, Google, Amazon, I have the impression that I'd flunk those technical interviews at some point. Don't get me wrong, I know my algorithms and data structures, but when things dive too deeply into the CS realm I am in trouble. What can I do to close the gap? I was thinking about a MSc in CS, but will I even UNDERSTAND what's going on there if I'm not a CS undergrad? Should I go back to basics and get a BSc in CS instead? I always tend to go into self-study mode when I want to learn new stuff, but I have the impression that I will need more formal education in CS if I want to have a shot at working at those kinds of companies. Thank you!


Choosing between the view and the controller for my code

I'm aware there are a lot of topics about MVC design but it's hard to find good explanations: what I should do, what are the consequences of the different possibilities... So I'm working on an ASP .NET MVC application with a HTML/Javascript front- end. Currently there is a view which allows the end-user to edit some objects like the others users. The form is automatically generated based on some meta- data. But these objects are rather complex, with many system properties and need to be edited by non-expert users. As we don't want to spend much time on the view, we decided to just hide all the input fields except the most simple ones like first name, last name, phone... My question is, does this filtering should be done in the controller or in the view ? Should I Ignore the most complex input fields in the view or only returns the needed fields from the controller ? Also my controller returns the data from the model without any post- processing. So it is done in the view. I could do it in the controller in order to save some ajax-calls and a little bandwith but I don't know if I should adapt the controller to the view or the view to the controller.


How to improve skills in software architecture

What is the best way to improve your skills in software architecture? We were taught design patterns in university, and I see plenty of books with simple and straight forward examples, but aside from them, how can you learn good architecture? In other words, how does one evolve into a great architect? What are the prerequisites?


protect purchased games to be downloaded on other pc

I want to make a downloads managing system on my website, that when you purchase a download, you can always re-download it again for free. (i have read that Steam does something similar) The problem is, that someone would be able to create a account, purchase something and then give the account password to friends and family, so they can all download copies for free. Is there a way to prevent this? Or is it impossible.


Is there any reason lazy initialization couldn't be built into Java?

Since I'm working on a server with absolutely no non-persisted state for users, every User-related object we have is rolled out on every request. Consequently I often find myself doing lazy initialization of properties of objects that may go unused. `protected EventDispatcher dispatcher = new EventDispatcher();` Becomes...               protected EventDispatcher<EventMessage> dispatcher;          public EventDispatcher<EventMessage> getEventDispatcher() {         if (dispatcher == null) {             dispatcher = new EventDispatcher<EventMessage>();         }         return dispatcher;     }      Is there any reason this couldn't be built into Java? `protected **lazy** EventDispatcher dispatcher = new EventDispatcher();` * * * As mentioned below in the comments, I realize a language could theoretically evolve to include most anything you want. I'm looking for a practical measurement of possibility. Would this conflict with other features? Is the implementation simple enough to work well with the JVM as it exists? And even, is it a good idea?


Are "backwards" terminators for if and case unique to shell scripting?

In bash at least, `if` and `case` blocks are closed like this:               if some-expr     then         echo "hello world"     fi          case $some-var in     [1-5])         do-a-thing         ;;     *)         do-another-thing     esac      as opposed to the more typical close of `end` or `endif`/`endcase`. As far as I know, this rather funny convention is unique to shell scripting and I have never seen such an odd block terminator anywhere else. Sometimes things like this have an origin in another language (like Ruby's `elsif` coming from Perl), or a strange justification. Does this feature of shell scripting have a story behind it? Is it found in other languages?


Further decoupling using static libraries

I've been thinking for a while about reasons that prevent a lot of programmers — myself first of all — from writing clean, modular and expressive code while developing, for example, CocoaTouch apps. What I discovered is that my top-three of reasons are following:   1. **UI code.** Device-specific UI/UX, general clutter, 'quick fixes and workarounds' and so on.   2. **Poor Controller-View decoupling.** Sometimes Controller ends up doing job that the View is responsible for.   3. **Sparse test harness.** Of course, those problems stem from lack of discipline or habit to write clean code. But it is difficult to discipline yourself if the _environment allows you not to do that_. It is easy to sort laundry if you have a set of dedicated drawers, but if you have one drawer, it will slowly turn into mess — unless you are very disciplined. And then I tried to apply that idea of 'sorting drawers' to address my code problems — and I thought that it is possible to sort MVP components as follows:   1. **Model** is actually a framework of classes responsible for dealing with data. Model is reusable, as it is a set of routines to work with data.   2. **View** is actually a framework of classes responsible for presenting information graphically. It doesn't depend _that_ much on environment and it definitely can be reused.   3. **Controller** is a framework of classes responsible for coordination of aforementioned layers and working with user interaction paths. Application itself is something like (?) a big controller. Since it glues together a defined set of models to a defined set of views, it is not reusable and depends heavily on those + platform etc. So given the M and V are somewhat reusable, and C is not — maybe it makes sense to force separation of M and V? The best way to ensure they are separated is to put them in static libraries. After that they can be linked to the app, which contains only controller code. This approach seems to me quite good because:   * only controller depends on something here   * developer can write separate test suites for those modules   * user interface classes can be reused in other apps easily   * model classes can be extracted to cross-platform codebase while maintaining the old facade   * commits are limited to three really distinct modules — what's more distinct than a separate library? What do you think? Does this sound like an idea to follow?


Find product using summation C# Problem?

I am trying to write a simple program to find the product of two numbers (X, Y) without using multiplication. Meaning that I will only use summation to find the product. I am trying to use the "Divide-and-Conquer" technique, and am using the obviously known concept that: 5*6 = 5+5+5+5+5+5               Multiply(uint X, uint Y)     {              if (Y < 1)             return 23423432453; //any very big random number              if (Y == 1)             sum = sum + X;              else // if (Y != 1)         {             halfY = Y / 2;             if (Y % 2 == 0) // if Y is even #                 return Multiply(X, halfY);             else //if Y is odd #                 return Multiply(X, halfY) + Multiply(X, 1);         }         return sum;     }      **EXPLANATION** 1) I see the problem as (for example) a 5x6 grid. My idea is to keep recursively dividing the number of columns Y until I reach that Y=1 (Y=1 is the base case). When Y=1, the number of rows in each column would be simply "X" and I can just add X+X+X ... according to the #of columns Y, and save the result in the variable               sum      , then I just return "sum" at the end. 2) In this part of the code,                else //if Y is odd #            return Multiply(X, halfY) + Multiply(X, 1);      I added "Multiply(X, 1)" to compensate for the "1" that will be lost due to the integer division operation. \----- As an illustration: For example 5*6, where X=5, Y=6:                                               Multiply(X,Y)                            //Y=6                               /                       \                    Multiply(X, Y/2)                   Multiply(X, Y/2)       //Y=3, Y=3                  /         |        \               /      \          \        Mult(X,Y/4) Mult(X,Y/4) Mult(X,1)  Mult(X,Y/4) Mult(X,Y/4) Mult(X,1) //Y=1,1,1,1,1,1             |           |           |           |            |        |     //BASE CASE!      sum= X + X + X + X + X + X = 5+5+5+5+5+5 = 30 * * * The code seems pretty logic to me, but it won't give me the right output. Is the idea incorrect? Any help in what is wrong would be greatly appreciated. Thanks.


How to start learning Spring framework with all its associated functionalities?

I am going to delve into the nuances of Spring. I have a little information about this framework. So I am not going in blind. But still I will like to start it as a beginner and then move up the levels to all the associated functionalities. I have RAD and apache tomcat installed. Does anyone know of any good sites or pdfs that will give me a good bottom up approach with proper examples?


Why Firefox caching work will reset in version 3 but version 16 don't?

I am developing a web application and have the app deployed into Tomcat server. Tested on IE and Firefox and are working fine. Meaning when I close the browser and reopen the app, the data will be reset. When deploy to Websphere, the data is reset only in IE but Firefox don't. Meaning Firefox will cache the old data. I did try to clear the cache in FF but still failed. I did a test in FF3 and FF16, FF3 will reset the value but FF16 doesn't, I am just so curious why this could happened? Now I don't know whether this is my code problem or is actually the FF caching problem. Any clue on this?


Advantages of Scala vs. Groovy with JAVA EE 6 Applications

Please let me first emphasize that I am not looking for flame wars. I just want advice from people who have real experiences. I started learning JAVA EE 6 as real newbie and am having a difficult time choosing what tools to use. The first question I have is - what are the advantages of using Scala vs. Groovy with Java EE 6 apps over Java? I've seen on some blogs people mentioning Scala can mean writing less code but as a newbie I don't know what other advantages and disadvantages there are. The second question is whether I'm better off choosing Netbeans 6.9 or Helios 3.6.1? I realized that with eclipse I can easily mix EE 6 applications with Groovy or Scala without any problems (I only did this by displaying a String message from Scala and Groovy classes.). With Netbeans the only advantage I can think of is having separate Java project libraries and using the jars in my web app. But I also realize to the extent of my little knowledge Netbeans has better support for Java EE 6. Please need your expert advice. Thanks.


What are your recommendations for porting a huge VC++6 project to later VS version?

We have a huge legacy C project which runs in VC++6. And I hope this will be ported to later versions of visual studio. But I think it will be a huge work. Actually, I just tried to recompile the project with VS2005 and got so many errors. So, do you have any experience of this type of porting? Any recommendations?


What are the various premature optimizations traits / types?

For code review technique training, I have to cover various topics. One of them is premature optimization. I found 3 traits of it as:   1. It's generally evil; causing **inverse effects**.   2. It's an **unnecessary pain** , causing no gain.   3. It demands lot of effort to achieve **little benefits** Is there any other trait which am I missing ? Also, to illustrate them, I usually get a good examples for only 1st scenario. Can someone suggest any solid example for 2nd and 3rd scenario also ? Example for 1st scenario: > Using char instead of int for smaller loops to save bytes!               for(char c = 0; c < 20; c++) {} //Evil: Accessing 'char' costlier than 'int'      [Note: I am not worried about the fact that compilers usually itself takes care of premature stuff. This training is meant just for illustration.] This question is not about, "What optimizations are premature?"


Should I use an aggregate root when designing my repository?

I have an entity that is called Master which is composed of a number of Slave entities. There can only be one Master in my database and I want to query repositories to get the Slave for a given id. I initially created a SlaveRepository and queried that by id. That seems fine and works and other developers could use my repository. Then I thought about aggregate roots and created a MasterRepository and returned the Master and then did a loop on that to get the required Slave entity. The problem I felt here is once I expose this to other developers they would have to do the same, so I through about having a method on the MasterRepository called GetSlaveByID(string id) and then I could get the Slave directly (hides the loop functionality). Now, should my repository return a Slave even though it is called a MasterRepository? And more importantly which is the right way to go? I am in the early stages of trying to apply DDD and TDD so there are probably lots of things I need to think about before deciding which is the correct way I guess.


Less vs Stylus vs Sass

I'd like to start using a CSS pre-processor to cut down development time. Which one of these is the fastest from this perspective?


What are the advantages of programming to under an OS as opposed to bare metal executive?

Assume you are presented with an embedded system application to program, in C, on a multi-core environment (think a Cavium or Tilera) and need to choose between two environments: Code the application under Linux in SMP mode or code the application under a thin bare metal executive (something like a very minimal RTOS), perhaps with a single core running UP Linux that can serve control tasks. For the purpose of this question, assume that both environment provide the same level of performance guarantees in any measurable aspects of run time performance, including number of meaningful action per second, jitter, latency, real time considerations - the works. (and yes, I realize this is by far not a trivial assumption at all, bare with me). How would you justify going with a Linux SMP based solution rather then a bare metal thin executive solution? The question may seems silly. It certainly seems obvious to me - but I have to convince someone that does not think the same. Could you help make a list of arguments in favor of choosing a real SMP aware OS (Linux) vs. a bare metal executive assuming performance guarantees are NOT an issue? Many thanks


Business person turned into coder? How and why? Inspire the non-technical

I graduated with a Business degree. Two years later, I finally realized the power of programming - the power to "invent." I wish I realized this in high school. Nevertheless, I tried to self-teach C# but found it difficult. Then I pivoted to learn PHP two months ago and I have been able to build things I thought was beyond my abilities. Has anyone had the same experience? Or self-taught programming? What lessons did you learn?


Are these good reasons for moving to Microsoft web development platform?

**Background** I do PHP and Ruby on Rails development in my spare time, and have learned quite a bit on my own. I chose those technologies because of the low cost of entry, since everything is open-source and freely available. I develop on Linux and have been learning that from using it too. **Problem** Now I'm at a place where I want to get deeper in my knowledge of web development, but I'm personally having a hard time learning, because:   * I'm finding that since everything is community-maintained there is no real "structure" to advancing knowledge.   * So far I've learned from doing, and looking up specific problems as I encounter them. I don't know if that's the right way to do it in general, or if it's just not the best way for me. What I don't like about this approach is that you don't get any insight into the problem, because you just need to fix it and get moving with the project you're actually working on! As an example, working in Rails hasn't given me more than just basic knowledge of Ruby, because I can't learn both Rails and Ruby to an advanced level at the same time (maybe that's just my brain's limitation?)   * I find that a significant portion of my time gets spent just getting set up, resolving LAMP-stack issues for PHP/MySQL, or Ruby gem dependencies and conflicts **Question** I am considering trying out C# and the .NET world for a few reasons, and I would like _more experienced developers' thoughts on whether my thinking is sound or flawed_. My main reasons for wanting to switch are:   * it seems like a more structured environment, I guess specifically because it's not community-driven. Does that make for a more linear learning experience?   * I personally prefer working in visual environments, and Microsoft has Visual Studio. I've used several IDEs for PHP and Ruby and they're quite good, but just going by what I've heard Visual Studio is excellent to work with.   * Microsoft has free "Express" versions of their software to try out, so there's a low cost of entry there now too   * since Microsoft's is a "closed"/integrated environment, do you save time in the initial set up? I.e., do you spend less time setting up Apache/nginx, MySQL, MongoDB, version control, etc.


Should an image be able to resize itself in OOP?

I'm writing an app that will have an `Image` entity, and I'm already having trouble deciding whose responsibility each task should be. First I have the `Image` class. It has a path, width, and other attributes. Then I created an `ImageRepository` class, for retrieving images with a single and tested method, eg: `findAllImagesWithoutThumbnail()`. But now I also need to be able to `createThumbnail()`. Who should deal with that? I was thinking about having an `ImageManager` class, which would be an app-specific class (there would also be a third party image manipulation reusable component of choice, I'm not reinventing the wheel). Or maybe it would be 0K to let the `Image` resize itself? Or let the `ImageRepository` and `ImageManager` be the same class? What do you think?


Best way to remove list items from an existing record

Ok more of a conceptual question here: Say I have an existing record of type Meeting. When I go to edit the meeting I have a listbox with all current meeting participants, and one with all employees. I then add a few employees from the master list and remove a couple from the meeting list. What is then the best approach to update my MeetingParticipant database with the new roster? The add records are no problem, but when I go to update, my callback doesn't know which items I have removed. Here are the solutions I've considered/implemented so far, but I'm hoping someone has a better answer :).   1. Immediately resolve the record deletion when the employee has been removed from the list. (this is what I usually implement, but I'd rather find a way where I can simply update the entire collection upon form submission)   2. Remove all MeetingParticipant records for the meeting and repopulate with the new list. (could possibly cause some referential integrity problems for employees who's status did not change)   3. Iterate through each of the MeetingParticipant records, searching the new list to see if it's still on the list or not. (seems like a lot of overkill) If it matters, we're working w/in the .Net framework using MVC & LINQ.


Using XML as data storage

I was thinking about the XML format and the following quote: > “XML is not a database. It was never meant to be a database. It is never > going to be a database. Relational databases are proven technology with more > than 20 years of implementation experience. They are solid, stable, useful > products. They are not going away. XML is a very useful technology for > moving data between different databases or between databases and other > programs. However, it is not itself a database. Don't use it like one.“ > -Effective XML: 50 Specific Ways to Improve Your XML by Elliotte Rusty > Harold (page 230, Part 4, Item 41, 2nd paragraph) This seems to really stress that XML should not be used for data storage and should only be used for program to program interoperability. Personally, I disagree and .NET's `app.config` file that's used to store a program's settings is an example of data storage in an XML file. However for databases rather than configurations etc XML should not be used. To develop my point, I will use two examples:   A) Data about customers with fields that are all on one level i.e. there are a number of fields all relating to one customer with no children   B) Data about configuration of an application where nested fields and properties make a lot of sense So my question is, Is this still a valid statement and is it now acceptable to store data using XML? EDIT: I've sent an email to the author of that quote to ask for his input/extra context.


Why does shared state degrade performance?

I've been working under the share-nothing principle of concurrent programming. Essentially, all my worker threads have immutable read-only copies of the same state which is never shared between them ( _even by reference_ ). Generally speaking, this has worked really well. Now, someone has introduced a no-lock singleton cache ( _e.g. a static dictionary_ ) that all the threads are accessing concurrently. Since the dictionary is never altered after startup there are no locks. There haven't been any Thread-Safety issues, but now there is a performance degradation. The question is... since there are no locks why does the introduction of this singleton create a performance hit? What exactly is going on under the covers that could explain this? To confirm, accessing this new singleton is the only change and I can reliably recreate this simply by commenting out the call to the cache.


User Stories with design elements in Scrum

We're implementing a Scrum workflow and I'm trying to wrap my head around user stories, when they're completed, iterations, etc. One thing we often do is work on a story during an early iteration, get it fully working but "ugly". We use plain buttons, no images, just the text to show that it's working the way they should. We show our customer, make sure they are happy with how it's working, then we usually use images they provide to finish up the design of the feature and complete it. In this instance, would we complete the user story when it's functionally complete, and make a second user story that says something to the effect of "as a user I want xyz to be visually appealing" to take care of the design phase? Or would we just move the user story from the first iteration to later on in the project once we get the design elements and can complete it? If that's the case, I can see us only completing maybe one or two stories in the first few iterations and completing a TON of stories in the final few iterations. How do you all handle this scenario?


How to implement a simulation pattern for a repository?

Let's say I have a repository of functions. These functions work with business objects within a database, CMS or other third party API. For example, my repository interacts with virtual files and documents in a document management system. I want to be able to implement a simulation mode in my repository such that when I execute commands, I want to see the result of it without it actually doing anything. This is to reduce the risk of someone executing a series of commands in my repository and doing something dangerous. I want them to first see the output and confirm before executing. My question is, what are some good patterns to implement a simulation mode for a repository? I can think of a few off the top of my hat: Wrap all business objects in another class, such that when you would call File.Delete, your actually calling the wrapper class and it checks in simulation mode is enabled. The problem is that many third party libraries and SDKs don't let you subclass their business objects. How would you pass in the the simulation mode (everytime an object is instantiated?). Another option would be to implement a SimulatedRepository. However, I don't want to duplicate any existing code in the repository. Meaning, I don't want to simulate everything to the point that it does nothing, I only want to simulate create, update and delete commands, not the business logic. Perhaps I need to implement another layer in my application? Suggestions would be appreciated. I also wonder if this design philosophy is popular in most enterprise environments and how its done. I would think that allowing administrators to run a simulation and measure results before actually executing them is vital in a mission critical scenario where you are working with another client's data.


Is restricting sessions to an absolute IP likely to have a wide impact on mobile networks?

Our website currently restricts a cookie-based session to the IP address that was originally sent the Set-Cookie HTTP header. In the past a user's IP would rarely change, so this didn't present much inconvenience. However, some of our clients accessing via 3G devices are experiencing session failures due to this IP restriction. I know little about the network infrastructure used for mobile networks. Do the majority of providers attempt to route connections to a common public IP in order to maintain compatibility with websites like ours, or should I consider restricting sessions to an IP range instead?


Software design by pseudocoding?

Do you know a good way to design (i.e. write down) software with a method based on pseudocode? I'm new to software design and read some information about UML. My humble class hierarchies are good so far, however, after it gets complex I notice that with "seeing the whole" picture I could have used a different structure for more future extendability. As Python is good to prototyping I'm almost fine with just starting to write, but not quite. So I tried UML class diagrams, but they don't seem to help me much. The problems I solve there I can trivially do in my head. But I do notice additional design requirements once I start to pseudocode the actual methods. So if you wanted to design by pseudocode, how would you do it? I believe for me a method which is roughly 1-to-1 with code works best. But most UML software doesn't even show the method's code (as opposed to pictures in e.g. GoF). Someone claimed UML is for documentation and presentation only and not that great for design? I also get that feeling. I thought pure UML and some simplistic whiteboard sketches were the way to design software until googling I found Envision APDT. So is agile development something I should look out for or do they randomly call that agile - I thought agile is about schedule only? Or am I designing incorrectly (with UML) - does anyone design by pseudocode? How can I find a good tool for that?


Proper Data Structure for Commentable Comments

Been struggling with this on an architectural level. I have an object which can be commented on, let's call it a `Post`. Every post has a unique ID. Now I want to comment on that Post, and I can use ID as a foreign key, and each PostComment has an ItemID field which correlates to the Post. Since each Post has a unique ID, it is very easy to assign "Top Level" comments. When I comment on a comment however, I feel like I now need a PostCommentComment, which attaches to the ID of the PostComment. Since ID's are assigned sequentially, I can no longer simply use ItemID to differentiate where in the tree the comment is assigned. I.E. both a Post and a Post Comment might have an ID of '5', so my foreign key relationship is invalid. This seems like it could go on infinitely, with PostCommentCommentComment's etc... What's the best way to solve this? Should I have a field in the comment called "IsPostComment" or something of the like to know which collection to attach the ID to? This strikes me as the best solution I've seen so far, but now I feel like I need to make recursive DataBase calls which start to get expensive. Meaning, I get a `Post` and get all PostComments `where ItemID == Post.ID && where IsPostComment == true` Then I take that as a collection, gather all the ID's of the `PostComments`, and do another search `where ItemID == PostComment[all].ID && where IsPostComment == false`, then repeat infinitely. This means I make a call for every layer, and if I'm calling 100 Posts, I might make 1000 DB calls to get 10 layers of comments each. What is the _right_ way to do this?


can I sell a software that uses a GPL library and another BSD licensed library?

This is the first time I have dealt with licensing issues so I am sorry if I am making any stupid assumptions. My issue is that I have written a program in Python that uses PyQT for the GUI and also uses another library licensed under BSD. PyQT comes with GPL v2 and GPL v3 as well as a commercial license. From what I have read until now (including the GPL license), I understand that you can sell a software that is licensed under GPL. However, there is an issue if you're not the original author and you are reusing source code that is licensed under GPL. So here are my questions:   1. In my case since I am using PyQT I believe that I should license my program under GPL as well? Also if this is the case I can sell my software provided that I release the source code as well right?   2. If PyQT is released under GPL which as far as I understand gives you freedom to sell your software if you use the library why do they also provide a commercial license? Is it only for the case where you do not want to release the source code?   3. Since I am also using a library that is licensed under BSD it is OK to license my software only under GPL and mention that my program uses this library in the License.txt and the About section of my program?


Is rotating the lead developer a good or bad idea?

I work on a team that has been flat organizationally since it's creation several months ago. My manager is non-technical and this means that our whole team is responsible for decision-making. My manager is beginning to realize that there are several benefits to having a lead developer, both for his sake (a single point of contact and single responsible party for tasks) and ours (dispute resolution, organized technical guidance, etc.). Because the team has been flat, one concern is that picking one lead developer may discourage the others. A non-developer suggested to my manager that rotating the lead developer is a possible way to avoid this issue. One developer would be lead one month, another the next, and so on. **Is this a good idea? Why or why not?** Keep in mind that this means _all_ developers -- All developers are good, but not necessarily equally suited to leadership. And if it is **not** , how do I recommend that we avoid this approach without seeming like it's merely for selfish reasons?


Fixed window size app development for Mac OS X

I am developing a rather eye-candy application which is to be released on Mac App Store. Due to its graphics intensive use, it would save a great deal of time on UI end if the app could be released with a fixed size main frame-dialog. I did try doing a search regarding App Store policies on the matter but could not find anything. Is the distribution of fixed-size frame [productivity] apps are allowed within the App Store if they conform with other design guidelines?


Why is SQL's BETWEEN inclusive?

Semi-open intervals (`[a,b)`, where `x`belongs to the interval iff `a <= x < b`) are pretty common on programming, as they have many convenient properties. Can anyone offer a rationale that explains why SQL's `BETWEEN` uses a closed interval (`[a,b]`)? This is esp. inconvenient for dates. Why would you have `BETWEEN` behave like this?


What popular "best practices" are not always best, and why?

"Best practices" are everywhere in our industry. A Google search on "coding best practices" turns up nearly 1.5 million results. The idea seems to bring comfort to many; just follow the instructions, and everything will turn out fine. When I read about a _best practice_ \- for example, I just read through several in Clean Code recently - I get nervous. Does this mean that I should _always_ use this practice? Are there conditions attached? Are there situations where it might _not_ be a good practice? How can I know for sure until I've learned more about the problem? Several of the practices mentioned in _Clean Code_ did not sit right with me, but I'm honestly not sure if that's because they're potentially bad, or if that's just my personal bias talking. I do know that many prominent people in the tech industry seem to think that there are no best practices, so at least my nagging doubts place me in good company. The number of best practices I've read about are simply too numerous to list here or ask individual questions about, so I would like to phrase this as a general question: **Which coding practices that are popularly labeled as "best practices" can be sub-optimal or even harmful under certain circumstances? What are those circumstances and why do they make the practice a poor one?** I would prefer to hear about specific examples and experiences.


Explanation of satellite data from a programmers perspective

I have started reading Part 2 of Introduction to Algorithms and in the section **The structure of the data** the author/authors says in the context of sorting a sequence of numbers: > In practice, the numbers to be sorted are rarely isolated values. Each is > usually part of a collection of data called a record. Each record contains a > key, which is the value to be sorted, and the remainder of the record > consists of satellite data, which are usually carried around with the key. > In practice, when a sorting algorithm permutes the keys, it must permute the > satellite data as well. If each record includes a large amount of satellite > data, we often permute an array of pointers to the records rather than the > records themselves in order to minimize data movement. Can some one explain what the authors mean here ? Why the term _satellite data_ ? What is the intuition behind this concept ? And also how this concept relates to a higher level programming platform like Java ?


What does &callback= do

I am trying to create a timer that ever x minutes it will call to a server, get a JSON file and do something with it. The merits of that system are not in question right now, the question involves getting the JSON file. Currently I am using kimonify from KimonoLabs to create a JSON file from some other site. They suggest I use               function kimonoCallback(data) {         // do something with the data         // please make sure the scope of this function is global       }            $.ajax({         "url":"http://www.kimonolabs.com/api/9ey3ljcs?apikey=d753b0c5546495826e7aaa5422f59e30&callback=kimonoCallback",         "crossDomain":true,         "dataType":"jsonp"     });      At the same time I was pursuing other methods and was getting a parse error, and I found this solution. So far both used `&callback=` what is so special about `&callback=` that makes it more preferable to something like `.done()` or `success:` I am guessing it has something to deal with Access-Control-Allow-Origin.


Which Continuous Integration for Selenium 2 with TestNG

So I have a Selenium Automation project (using Maven). I'd like to be able to set my tests to run overnight and possibly email a report daily to the team. Which CI would be most suitable for TestNG.xml suites? I tried Hudson but I couldn't figure out a way to execute TestNG files from the build? Thanks in advance.


What are the implications of the cache when using notifyDataSetChanged?

I use Volley to return JSON from an API. I parse this JSON and add `StoreItem` objects to a List, then use an adapter to display in a listview. I use the cache functionality in Volley, and I'm wondering how I can approach the issue of deleting/adding items. I know I'll need to make a POST/DELETE request with Volley to actually save/destroy the items in the database, but for user experience purposes I don't want to have to reload the view with a fresh Volley request. I also don't want the cache to update the view without recognizing the item that was just added/destroyed. The android documentation for notifyDataSetChanged says: > Notifies the attached observers that the underlying data has been changed > and any View reflecting the data set should refresh itself. In this case is the underlying data the cache, my server database, or the Items in the list? Please let me know if I can clarify this question.


Best datatype to store a ternary, or three-state variable

_Disclaimer: I know that datatypes are a little bit subjective to which scripting/programming language you are using, I like to write in Python as a matter of preference; though I am happy to hear about any lanugage/implementation._ What is the best datatype to store a three-state variable? Something capable or representing Positive, Neutral, and Negative. Example: Integers `-1`, `0`, `1`.   * Pro: Very concise.   * Pro: Potentially efficient, Could be stored as a single 2-bit signed integer.   * Pro: could be used as a scale, such as a floating point multiplier. Example 2: `0`, `null`, `1` (or any permutation)   * Pro: Non-neutral use case can be binary.   * Con: Requires dynamic datatype    * Con: Potentially not concise. Example 3: `+`, `` (empty string), `-`   * Pro: Very concise.   * Con: May utilize string logic to determine state.   * Pro?: Intuitive graphical representation.  Perhaps there is some clever binary logic that can do something clever that I can't even imagine, perhaps there relies too much considerations of the use case. Also, are there any considerations when adapting a ternary state to store in a database engine? Like Innodb for reference.


Methods to keep an external service up to date that polls your service periodically?

Sorry if the title is hard to understand, it is easier if I describe the scenario to get the question across. I have a service that collects data, performs business logic and does all the normal stuff. I now have to perform an integration that will provide a set of data (for sage accounts) via an endpoint (`http://example.net/import-feed`). This endpoint can be polled by the external service at any time to pull the latest changes. When a piece of data is updated, say a payment or a date this needs to be added to the feed. This payment or date could be changed multiple times before the service gets polled. The question is what is the best methods to keep track of **all** or the **last change (probably best)** made to the record/row/data and pull all of these changes into the feed. The external service will then send notifications back to my service letting me know if adding that update was successful or not. Currently the only method I can think of is track the last modified time and the last time it was imported, and a status saying if it needs to be imported/updated. These imports/updates would then be pulled from the feed. I hope you understand the problem, I have had a hard time trying to find information on this type of integration. It may just be me not using the correct terms. So, what are the methods for this?


What is meant by 4 GL?

I came across the term 4GL(generation language) in reading about Oracle ADF Busniess components . I want to know what exactly is 4GL ? This is the actual quote from the book Oracle Fusion Guide: > Oracle ADF Business Components is the business services layer of choice in > Oracle Fusion application development. Compared to other persistence layers, > ADF Business Components provides exceptional built-in business application > functionality and maximally declarative experience that makes it a perfect > match for those who seek an end-to-end fourth generation language (4GL) Java > EE development architecture.


RESTful API design - should a PUT return related data?

I have an API which allows a user to update their system status; and a separate call to retrieve system status updates from other users. Would it make sense to unify them under a PUT request where a user would request a PUT update with their own status update, and they would receive the status updates of other users? My solution would allow the PUT request to call the GET request method internally. The reason behind this is that when a user updates their system status they should be informed of other users status immediately, and I don't feel that having 2 seperate requests is necessary - and should be optional. I intend to keep the GET request for other users status as a status update for a user is not necessarily required in order to retrieve other users status', but once they update their own status is it vital that they get information about other users.


Different database for Membership and our web data or use just one?

Is better to keep our Membership stuff on the DefaultConnection and create another connection (another database) for our data? Or just one database for all? If I have a _MyAppContext_ and I want migrations for that context, It seems that I cannot have migrations for _UserContext_ (In other words, I can just migrate one context) So, having two different databases I can migrate or the users (maybe membership migration is weird) or the web data. Or, I can mix the _UserContext_ and _MyAppContext_ in one _UserAndAppContext_ and migrate all in one place, but this mixing also seems weird. What's the normal way to do this, one or two databases and what should be migrated?


Immutable Method in Java

In Java, there is the `final` keyword in lieu of the `const` keyword in C and C++. In the latter languages there are mutable and immutable methods such as stated in the answer by Johannes Schaub - litb to the question How many and which are the uses of “const” in C++? > Use const to tell others methods won't change the logical state of this > object. >   >   >     struct SmartPtr { >         int getCopies() const { return mCopiesMade; } >     }ptr1; >   >     ... >   >     int var = ptr.getCopies(); // returns mCopiesMade and is specified that > to not modify objects state. >   How is this performed in Java?


Why does Javascript treat days and months differently?

I've noticed that in JavaScript, when creating a `Date`, months are zero based, and days aren't. For example:               var foo = new Date(2012, 1, 1)      produces February 1st 2012 Why is this?


Handling REST Response Formats

It seems that newer websites (and API's especially) make use of request formats by adding the expected format to the end of the URL path.               /path/to/resource.html     /path/to/resource.json     /path/to/resource.xml      Are their any problems with this approach? Are there any studies or outlines of the pros and cons of doing this instead of just listing the resource without a file type extension?


What is the point of dynamic allocation in C++?

I really have never understood it at all. I can do it, but I just don't get why I would want to. For instance, I was programming a game yesterday, and I set up an array of pointers to dynamically allocated little enemies in the game, then passed it to a function which updates their positions. When I ran the game, I got one of those nondescript assertion errors, something about a memory block not existing, I don't know. It was a run-time error, so it didn't say where the problem was. So I just said screw it and rewrote it with static instantiation, i.e.:               while(n<4)     {     Enemy tempEnemy = Enemy(3, 4);     enemyVector.push_back(tempEnemy);     n++;     }     updatePositions(&enemyVector);      And it immediately worked perfectly. Now sure, some of you may be thinking something to the effect of "Maybe if you knew what you were doing," or perhaps "n00b can't use pointers L0L," but frankly, you really can't deny that they make things way overcomplicated, hence most modern languages have done away with them entirely. But please-- someone -- What _IS_ the point of dynamic allocation? What advantage does it afford? Why would I ever not do what I just did in the above example?


Using ng-init to initialize data in Angular controller

Recently I came across the following in one of our projects. In one of our mvc views they are passing model data to an Angular controller through ngInit directive               In xxx.cshtml
      I pointed out that according to Angular documentation ngInit directive is not to be used to to initialize controllers. https://docs.angularjs.org/api/ng/directive/ngInit Instead what I suggested was to send the ID in ngInit directive and
      Then after that use $http [https://docs.angularjs.org/api/ng/service/$http] service to get the remainder of data from the Angular controller. The developer is refusing my idea saying it's faster to just send all the data through ngInit directive instead of having to do another call to get the data inti the Angular controller. What do you guys think about this scenario? The only point I have right now is that this code is FUGLY and it not according to standards. How would you convince a developer to follow the path I suggested. Or am I completely wrong here?


Delphi IcmpPing Exception only in release, ok in debug

The following code is a test of the IcmpPing routine called from the icmp dll. In debug it works fine but in release it throws an error. The error is caused by the "IcmpCloseHandle" call because calling IcmpSendEcho has somehow changed the handle. It has the feel of a memory problem but so far the only fix I have found it to take a copy of the handle and use that for the close handle call. I have trimmed the code to down to minimum including having the ip address as an integer (127.0.0.1 = $0100007F little endian). What am I doing wrong? I have tested this problem on 2010, XE2 and XE4 all with the same problem. Any ideas * * *               unit icmptest1;          interface          uses     //  Windows, Messages, SysUtils, Variants, Classes, Graphics,     //  Controls, Forms, Dialogs, StdCtrls;       Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,       Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls;          type       TSunB = packed record         s_b1, s_b2, s_b3, s_b4: byte;       end;            TSunW = packed record         s_w1, s_w2: word;       end;            PIPAddr = ^TIPAddr;       TIPAddr = record         case integer of           0: (S_un_b: TSunB);           1: (S_un_w: TSunW);           2: (S_addr: longword);       end;           IPAddr = TIPAddr;            PICMP_ECHO_REPLY = ^ICMP_ECHO_REPLY;       ICMP_ECHO_REPLY = packed record         Address : IPAddr;         Status : ULONG;         RoundTripTime : ULONG;         DataSize : WORD;         Reserved : WORD;         Data : Pointer;       end;            PIP_OPTION_INFORMATION = ^IP_OPTION_INFORMATION;       IP_OPTION_INFORMATION = packed record         Ttl : byte;         Tos : byte;         Flags : byte;         OptionsSize : byte;         OptionsData : Pointer;       end;          type       TForm34 = class(TForm)         Button2: TButton;         procedure Button2Click(Sender: TObject);       private         { Private declarations }       public         { Public declarations }       end;          function  IcmpCreateFile : HWnd; stdcall; external 'icmp.dll';     function  IcmpCloseHandle(const IcmpHandle : HWnd) : longbool; stdcall; external 'icmp.dll';     function  IcmpSendEcho(const IcmpHandle: HWnd; const DestinationAddress: IPAddr ;const RequestData: Pointer;const RequestSize : WORD;const RequestOptions : PIP_OPTION_INFORMATION;const ReplyBuffer : Pointer;const ReplySize : DWORD;const TimeOut : DWORD) : DWORD; stdcall; external 'icmp.dll';          var       Form34: TForm34;          implementation          {$R *.dfm}     {$T+}          function IcmpPing1(): Boolean;     var       dwSize : DWORD;       DW: DWord;       IPAddr: TIPAddr;       EchoReply: ICMP_ECHO_REPLY;       hICMP : HWnd;       Hc: HWnd;          begin       Result := False;       hICMP := IcmpCreateFile;       Hc := hICMP;            if hICMP <> INVALID_HANDLE_VALUE then       begin         try           dwSize := SizeOf(ICMP_ECHO_REPLY) + 8;                IPAddr.S_addr := $0100007F; // 127.0.0.1                ShowMessage(Format('1: %x',[hICMP]));           DW := IcmpSendEcho(hICMP, IPAddr, nil, 0, nil, @EchoReply, dwSize, 500);           hICMP := Hc;           ShowMessage(Format('2: %x',[hICMP]));                Result := (EchoReply.Status = 0);         finally           try             IcmpCloseHandle(hICMP);           except             on e:exception do               ShowMessage(e.Message);           end;         end;       end;     end;          procedure TForm34.Button2Click(Sender: TObject);     begin       ShowMessage(IntToStr(Byte(IcmpPing1())));     end;          end.


How do people write so many lines of code per day?

I know that many websites, video games and other software contain thousands of lines of code while being developed by a single person in a short amount of time. How are those people able to write thousands of LOC day after day? For me, it seems a huge number: I rarely write more than a few hundred lines per day, and often spend my time _removing_ code instead of adding LOCs. Is it really written by hand, or do they use some code generators?


Question I was asked during a job interview

I was asked during a job interview the following question, to which I couldn't find an answer then, and this thing is still bothering me. I was hoping someone might know the answer here: Consider two banks that communicate through an encrypted channel, where you are able to listen to the communication between them: ![enter image description here](http://i.stack.imgur.com/rUNov.png) Bank A is about to send some credit card numbers to Bank B (you can refer to the credit card numbers as decimal or binary number of some length of your choice - it doesn't matter). Now, suppose that you somehow gained access to Bank A's database, where it holds credit card numbers, and you are given a chance to plug your dok into it, and run any code you'd like on it. How will you then be able to steal Bank A's credit card numbers? I hope I didn't omit any important details (I should've write that down). Is it doable?


GDI + double rendering

I know that GDI custom controls are usually implemented as window controls and they receive WM events as a normal window, if a control receives the WM_PAINT it needs to repaint itself. My question is: if I were to render with GDI my window client area and create all the controls there by rendering them on (without using window controls) in double buffering, will there be problems regarding "which area needs to be redrawn"? There would be no more WM_PAINT events to redraw a specific control


R chart in a C# windows form

I see that R has very nice plotting capabilities that I would like to use in a C# windows form. There is some integration between C# and R but is it also possible to have a R chart in a windows form? Basically doing all calculations in C# and pasding results to R to plot and see everything in the windows form app. Any idea to help me on this? Thanks.


Multi-lingual support implementation in a website

I'm developing a **Multi-lingual** website which is being developed in custom `PHP` and using `MySql`. To implement the multi-language support, I've come to think of this approach (steps below). Please criticize and give your opinion and suggestions on the implementation technique. You can also suggest any better solution, if any. **METHOD 1**               1- Store the user preferred language id/code in `Cookie` (on first visit, the default language code).     2- The **database** will have a table named `languages` with the following columns:          ---------------------------------------------      lang_id | language | lang_place | lang_text     ---------------------------------------------         1    | eng      | menu[1]    | Home         2    | eng      | menu[2]    | Options         3    | eng      | menu[2][1] | My Account         4    | eng      | menu[2][2] | Settings         5    | eng      | menu[2][3] | Logout         6    | eng      | menu[3]    | Orders                              .                         .              So on for other languages      **METHOD 2**               1- Same as of method 1     2- The **database** columns will be:          ---------------------------------------------      lang_id | language | lang_data      ---------------------------------------------         1    | eng      | {                               "menu1":"home",                             "menu2":{                                   "name":"options",                                 "button1":"my account",                                 "button2":"settings",                                 "button3":"logout"                              }                           }                              .                         .              So on for other languages      I highly appreciate your help in this regard.


What Things are Most Conducive to a Productive Programming Environment?

Many of us have worked in multiple environments over the years, and have found that some are more productive than others. In many cases, it's not directly related to the abilities of the developers, but instead to their environment. I myself have experienced this, being in places where I seemed to develop faster, and better. And yet other places I seem to be dragging time, and developing less thoughtfully. What do you think creates a productive development environment?


Should mock objects for tests be created at a high or low level

When creating unit tests for those other objects, what is the best way to create mock objects that provide data to other objects. Should they be created at a 'high level' and intercept the calls as soon as possible, or should they be done at a 'low level' and so make as much as the real code still be called? e.g. I'm writing a test for some code that requires a `NoteMapper` object that allows Notes to be loaded from the DB.               class NoteMapper {              function getNote($sqlQueryFactory, $noteID) {             // Create an SQL query from $sqlQueryFactory             // Run that SQL              // if null              //     return null             // else             //    return new Note($dataFromSQLQuery)         }     }      I could either mock this object at a high level by creating a mock NoteMapper object, so that there are no calls to the SQL at all e.g.               class MockNoteMapper {              function getNote($sqlQueryFactory, $noteID) {             //$mockData = {'Test Note title', "Test note text" }             // return new Note($mockData);         }     }      Or I could do it at a very low level, by creating a MockSQLQueryFactory that instead of actually querying the database just provides mock data back, and passing that to the current NoteMapper object. It seems that creating mocks at a high level would be easier in the short term, but that in the long term doing it at a low level would be more powerful and possibly allow more automation of tests e.g. by recording data in an out of a DB and then replaying that data for tests. Is there a recommended way of creating mocks? Are there any hard and fast rules about which are better, or should they both be used where appropriate?


How to conciliate OOAD and Database Design?

Recently I've studied object oriented analysis and design and I liked a lot about it. In every place I've read people say that the idea is to start with the minimum set of requirements and go improving along the way, revisiting this each iteration and making it better as we continuously develop and contact the customer interested in the software. In particular, one course from Lynda.com said a lot of that: we don't want to spend a lot of time planning everything upfront, we just want to have the minimum to get started and then improve this each iteration. Now, I've also seen a course from the same guy about database design, and there he says differently. He says that although when working with object orientation he likes the agile iterative approach, for database design we should really spend a lot of time planning things upfront instead of just going along the way with the minimum. But this confuses me a little. Indeed, the database will persist important data from our domain model and perhaps configurations of the software and so on. Now, if I'm going to continuously revisit the analysis and design of the model, it seems the database design should change also. In the same way, if we plan all the database upfront it seems we are also planning all the model upfront, so the two ideas seems to be incompatible. I really like agile iterative approach, but I'm also looking at getting better design for the database also, so when working with agile iterative approach, how should we deal with the database design?


What are the qualifications for working with development of operating systems?

I always saw a lot of ads of programming jobs before. But I never saw an ad of operating systems development job before. I also never met personally someone who worked as operating system's programmer or something related to osdev before (I once saw a teacher at college talking about it, but I can't remember if she was talking about osdev). I would like to know:   1. What are the qualifications for an osdev position (years of experience, college/university, languages, etc)?   2. What a beginner that wants to work in this area should do?   3. How the work a of an OS developer looks like?


Alternative to XML / XSLT for artifact generation?

## The scenario: A system needs to produce a variety of artifacts to present to end-users during the normal course of business. Examples of these artifacts would be permits, invoices, or receipts -- imagine any online app that gives you one of those "print this page for your records" pages. I'm working on a system that produces artifacts like this, but we're expected to be able to recall a previously-generated artifact and present it again when it's needed. Currently, the system retains transactional data and recreates the "artifact" page as needed from that online data. This presents a number of problems:   * More data is needed during transactional processing than is used in artifact generation. Once the transaction is complete, though, we're unable to archive the transactional data because it may be needed to reproduce the artifact at some point in the future.   * Artifact generation is slightly more expensive than it needs to be, because each time we pull up one of these artifacts, we're re-generating it. Frankly, this isn't a huge deal in practice, but it bugs me.   * If we ever change the way a specific artifact is generated, an old artifact will be "upgraded" if it's reproduced. Although this seems like a virtue, I maintain that since the whole objective is to show the artifact as it was originally generated, this is a detriment. The two most reasonable design fixes that leap to mind are PDF generation and XML / XSLT. I'm not very excited about the PDF option because I really don't think I need to store the static portions of each artifact over and over again. The XML / XSLT option still seems to have merit. In this approach, I'd need to assemble an XML document for each artifact containing only the data needed for that artifact plus a reference to the proper XSLT document. New versions of the artifact would be deployed with a new XSLT, such that old XML uses old XSLT, and new XML uses new XSLT, and so on. ## The question: Is there another killer design or technology I'm missing that would fit this need? This is a .Net system, for what it's worth.


Software Architecture and MEF composition location

**Introduction** My software (a bunch of webapi's) consist of 4 projects: Core, FrontWebApi, Library and Administration. Library is a code library project that consists of only interfaces and enumerators. All my classes in other projects inherit from at least one interface, and this interface is in the library. Generally speaking, my interfaces define either Entities, Repositories or Controllers. This project references no other project or any special dlls... just the regular .Net stuff... Core is a class-library project where concrete implementation of Entities and Repositories. In some cases i have more than 1 implementation for a Repository (ex: one for azure table storage and one for regular Sql). This project handles the intelligence (business rules mostly) and persistence, and it references only the Library. FrontWebApi is a ASP.NET MVC 4 WebApi project that implements the controllers interfaces to handle web-requests (from a mobile native app)... It references the Core and the Library. Administration is a code-library project that represents a "optional-module", meaning: if it is present, it provides extra-features (such as Access Control Lists) to the application, but if its not, no problem. Administration is also only referencing the Library and implementing concrete classes of a few interfaces such as "IAccessControlEntry"... I intend to make this available with a "setup" that will create any required database table or anything like that. But it is important to notice that the Core has no reference to this project... **Development** Now, in order to have a decoupled code I decide to use IoC and because this is a small project, I decided to do it using MEF, specially because of its advertised "composition" capabilities. I arranged all the imports/exports and constructors and everything, but something is quite not perfect in my "mental- visualisation": **Main Question** _Where should I "Compose" the objects?_   I mean: Technically, the only place where real implementation access is required is in the Repositories, because in order to retrieve data from wherever, entities instances will be necessary, and in all other places. The repositories could also provide a public "GetCleanInstanceOf()" right? Then all other places will be just fine working with the interfaces instead of concrete classes... **Secondary Question** _Should "Administration" implement the concrete object for "IAccessControlGeneralRepository" or the Core should?_


What type of Password Reset/Forgot Password (verification) mechanism would you recommend

I am looking for ways to verify the user in order to reset their passwords. 2 commonly used ones:   * Email verification   * Secret question I wonder which will you recommend? I am trying to avoid having to use email at all (users won't need to provide emails, most hosts limit emails sent). But Secret Question alone seems a little unsecure. What do you think?


Are there any notable programmers that started late in life?

So I'm starting to get disgruntled... I'm 25 and trying to learn programming and am having trouble grasping some of the concepts and I feel its because I'm getting started so late in life. So I'm just curious if there were any notable programmers that got their start late in life?


Parallel computing and mobile computing

I have been working as software developer for past 4 years on a variety of software products (Financial ERP system, Online Web development, Trading software and now a Supply Chain mgmt software). Most of the work has been in Core Java. Lately, I do feel that I should start looking into specific technical "principles" and/or domain such as Parallel Computing and Mobile Computing and not be working for long just on a software solution for the sake of working as a software developer. In short, I want to give a direction to my existing skill set so that I know more than just the programming language. Can anyone please guide me on how I should go about learning these domains? I am really interested in parallel computing, but I am not much aware of other such domains I can look into.


Are there open source alternatives to Bitbucket, Github, Kiln, and similar DVCS browsing and management tools?

I am aware of several tools/services that provide DVCS browsing and management such as Bitbucket, Github, Kiln, SCM-Manager and Rhodecode. However, the use case I am considering is one such that:   1. Any source code must reside on an employers internal servers.   2. The solution must be open source.   3. It should provide a Bitbucket or Github like experience, including a project wiki, repository browsing and management, and social coding aspects such as code review.   4. The solution should have mercurial support (if not support for other DVCSs). Of these, only SCM-Manager and RhodeCode come close as they can be installed on your own servers and are open source. However they do not have the Bitbucket or Github experience. There is no issue tracker or wiki and the UI, while functional, is not up to par with Github or Bitbucket. I can get close with Trac or Redmine with their repository browsers but unfortunately they do not have any repository management capabilities. Are there other open source tools out there that would provide a similar experience to Bitbucket, Github or Kiln?


Is it recommended to use DocBlock even if I'm not using phpDocumentor?

I'm developing a simple website for a client. I have read about **phpDocumentor** and **DocBlocks** , and I thought that documenting my classes and functions will be very useful. I'm almost sure I will **not** generate any documentation for the site, since it's a pretty simple website, and guess what? It doesn't have an API... But is it still recommended to write DocBlocks in my code? From what I know many programmers even don't write simple comments, but DocBlocks.   I'm not going to generate any readable documentation by the client/ next programmer but I still think that making some comments that are more than just simple text will be better. _edit -_ If you think that DocBlocks are redundant in my case, are there any other "standards" for writing comments / documentation?   The last time everything that doesn't have a standard makes me feel stupid, that I'm not sure if it's better to write `if(){` or `if () {`, `/* */` or `//`, etc. I'm new to the documentor and DockBlocks, and I'm still not sure if I have to write this question here or in StackOverflow. Thank you very much anyway!


What to put in a Stored Procedure documentation?

I was tasked to document our stored procedures.   * Target audience: Technical    * Purpose: To have a good documentation in preparation for migration. I'm assuming someone has already done it.


Difference in orientation of Sobel mask gives different edge detector result

I am implementing a Canny Edge detector for a class which I have based off the code found here. For the first derivative mask that I will convolve with the image, I am using the Sobel mask, although the website uses the Prewitt. As you can see in the samples on the website, the code is perfectly functional. However, I noticed different results when I changed the "orientation" of the Sobel gradient mask as I explain below. The typical mask for taking the derivative in the x direction in my class notes is shown to be:               [-1 0 1]     [-2 0 2]     [-1 0 1]      For the y direction it is:               [-1 -2 -1]     [0 0 0]     [1 2 1]      For an experiment, I changed the orientation for the x direction to:               [1 0 -1]     [2 0 -2]     [1 0 -1]      And for the y direction:               [1 2 1]     [0 0 0]     [-1 -2 -1]      Oddly enough, this gives me two different results, which I did not expect, since I don't think the "direction" that I am using for taking the gradient should give me a different result. First result:   ![Default_mask_orientation](http://i.stack.imgur.com/rFD0y.jpg) Second result:   ![enter image description here](http://i.stack.imgur.com/HroFv.jpg) Why am I getting this different result? Where should I investigate next?


Why is Adobe Air so underrated for building mobile apps?

I've worked with Adobe Flash-related technologies for the past 5 years. I've seen small bugs in some apps, but I don't understand why many big companies don't consider Adobe Air for their mobile apps. I've seen many mobile developer job postings that require Android or iOS expertise, but not too many that require Adobe Air expertise. This puzzles me because you can deploy Adobe Air apps to Blackberry, iOS **and** Android. Also, in my opinion, it's much easier to develop a game with Flash, than it is with the Android SDK, for example. Does Adobe Air really have weaknesses that I've never seen?


How to develop on Windows and test and run on Linux?

I am one of two developers for some internal software (written in python) in my company. Software is a server application designed to run on a dedicated Linux box. Currently, we have one box holding our SVN repository and this box is also used for testing. The problem is that I am developing it on my workstation using Eclipse on Windows and this app can't run on Windows. How to properly organize such environment so that you can don't lose valuable time on transferring the project and code around so that you can test it? Currently I am doing svn checkout, change some code and then upload it to the development server for testing (not via svn). Test it on the server, change something, test it again etc. After all of that comes the commit. This constant uploading and testing is driving me crazy. I've tried to keep the project on the server (checkout to home dir) but this causes a whole lot of problems with Eclipse. Obviously I don't have a lot of experience in this, so I am asking what are the best practices concerning this kinds of problems?