Correct For Loop Design

What is the correct design for a `for` loop? Felix currently uses               if len a > 0 do       for var i in 0 upto len a - 1 do          println a.[i];        done     done      which is inclusive of the upper bound. This is necessary to support the full range of values of a typical integer type. However the for loop shown does not support zero length arrays, hence the special test, nor will the subtraction of 1 work convincingly if the length of the array is equal to the number of integers. (I say convincingly because it may be that 0 - 1 = maxval: this is true in C for unsigned int, but are you sure it is true for unsigned char without thinking carefully about integral promotions?) The actual implementation of the for loop by my compiler does correctly handle 0 but this requires two tests to implement the loop:               continue:       if not (i <= bound) goto break       body       if i == bound goto break       ++i       goto continue     break:      Throw in the hand coded zero check in the array example and three tests are needed. If the loop were exclusive it would handle zero properly, avoiding the special test, but there'd be no way to express the upper bound of an array with maximum size. Note the C way of doing this:               for(i=0; predicate(i); increment(i))      has the same problem. The predicate is tested after the increment, but the terminating increment is not universally valid! There is a general argument that a simple exclusive loop is enough: promote the index to a large type to prevent overflow, and assume no one will ever loop to the maximum value of this type.. but I'm not entirely convinced: if you promoted to C's size_t and looped from the second largest value to the largest you'd get an infinite loop!


Distributed Version-Control for Small Projects

When it comes to very small projects (just a few devs), how effective are distributed version-control systems (e.g., git) compared to systems with a central repository? I like the idea of having a central repository because it seems much more elegant and organized. However, after watching Linus Torvalds's Google Talk, I have my doubts. Are all those benefits really noticeable with such a small project, though?


Does learning to develop for iOS create a lock-in?

If I begin my career (first job) with developing on the iOS platform, does that lock me in into iOS and Mac OS X development only? By locking me in I mean will that create barriers for me to switch technologies as I would be mainly working with Objective-C. If yes, does that make my career choices limited? I'm interested in comparing this with Android development, which if pursued will leave me with Java skills (correct me if I'm wrong) which I can use elsewhere.


Should I use a Class or Dictionary to Store Form Values

I am working on a C# .NET Application, where I have a Form with lots of controls. I need to perform computations depending on the values of the controls. Therefore, I need to pass the Form values to a function and inside that function, several helper functions will be called depending on the Control element. Now, I can think of two ways to pass all the Form values: i) Save everything in a Dictionary and pass the Dictionary to the function or ii) Have a class with attributes that corresponds to each of the Form element. Which of these two approaches , or any other, is better?


UI Developer Interview Question

I keep getting the following question in interviews; and judging from the reactions I've gotten, I'm not giving the best answer. "What methodology do you use for developing user interfaces?" Which seems like a rather broad question. Besides dividing work between markup, stylesheets, and javascript (control logic), what are the best practices? What am I missing in this question? Any thoughts?


Can I fork Linux source code, change it around to suit my desires, and claim it as my own kernel without doing any of the originating work?

Is it acceptable form to take Linux kernel source from any version, change it, claim it is mine, and then distribute it for monetary gain? In such a case open-source software is entitled to a sort of "grab, change, sell" mechanism in which anyone can just tinker with something to look different from the original source, make it work their way, and sell it as if they made it entirely themselves. Isn't that illegal?


When writing an interpreter, how should the type inference algorithm change the parsed AST? Should it?

_When writing an interpreter, how should the type inference algorithm chance the parsed AST? Should it?_ Or parsing and inference are done necessarily simultaneously? I have implemented a strongly typed functional language interpreter, in which each function can be declared only one time (i.e., with no signature variants). As soon as the non-typed implementation parser was concluded and working, I have written the type inference algorithm, feeded by the parser's resulting AST. Hindley- _Damas_ -Milner is working like a charm, but the program use it and if the type checking passes, it just forgets about the matter and pass the AST to the interpreter. To the moment, the "target language" (i.e., the one in which the interpreter is written) have satisfied the interpreter type needs, but **I am wondering if this approach is usual: to discard all the type inference fruits after an "ok" result.** Also, would writing a compiler instead of an interpreter make any difference is this sense?


Eloqua API Full Code Example in JAVA

**Is there anyone out there who has mastered to retrieve some data programmatically from Eloqua?** First of all, I'm more or less a newbie, as far as JAVA. I can follow tutorials, take directions and will Google till my fingers bleed. I understand the basics and am slightly familiar with OOP. My main problem is that I have a Friday deadline (and tomorrow is Thanksgiving). At any rate, all the Eloqua code snippets (that I've been able to find) illustrate one aspect of a specific issue, and that's it. In my case, **I would greatly appreciate a JAVA project of some sort** , with all the necessary files to do web services (WSDL, SOAP and perhaps WSIT) and the main class and all that included. No, I don't want you to do my work for me! Just give me enough to find my way around, enter the information I need to retrieve and all that. I'll take it from there. Any pointers, links or suggestions?


What's up with the Class::get(id) idiom in PHP

I am a new PHP developer (coming from .NET). The experienced php dev that I work with said that calling a static get method on a PHP class with an ID as a parameter is common in PHP. Is there a name for this idiom? Is there a reason why developers do this? Can someone point to a link to an example class? I would like to understand more of what he is saying. He is talking about code like this I think, to pull car #1 from the database:               $car = Car::get(1)


Is Java "dead in the water" as a consequence of Oracle buying Sun and subsequently suing Google

Google has led many useful Java features (guava, gson); now that Oracle has purchased Sun, will it affect its future enhancements and utilization as a development language? What exactly, or even approximately, are the legal ramifications? I thought Java was open source and would therefore remain unaffected ... ? Should Google just buy Oracle to get rid of the whole mess, that would be cool wouldn't it ? Do you think this is the beginning of the end for Java as a widely used language ? Its continued success as an open source/free technology is now doubtful?


General rules for writing a X compiler to Z in Y

Suppose X is the input language, Z is the output language, then f is the compiler, which is written in language Y.               f = X -> Z      Since f is only a program, I think Y can be any language, right? So we can have compilers f1, f2, each written in Y1, Y2.               f1 = f Y1         f2 = f Y2          g = Z -> M     h = g . f    # We get a compiler X -> M      Take cpython compiler for example, X is Python, Z is the Python VM code, Y is C.               cpython = Python -> PythonVMCode C     interpreter = PythonVMCode -> Nothing     interpreter2 = PythonVMCode -> MachineCode      Python sources are compiled to the Python VM code, the .pyc files, then interpreted by the interpreter. Looks like it's possible there exists a compiler which can directly do Python -> MachineCode, though much hard to implement:                  hardpython = interpreter2 . cpython       We can also write another compiler do the work Python -> PythonVMCode, in another language, say Python itself.               mypython = Python -> PythonVMCode Python     mypython2 = Python -> PythonVMCode Ruby      Now, here is the complicated example PyPy. I'm just a newbie of PyPy, correct me if I'm wrong: PyPy doc http://doc.pypy.org/en/latest/architecture.html#pypy-the-translation- framework > Our goal is to provide a possible solution to the problem of language > implementers: having to write l * o * p interpreters for l dynamic languages > and p platforms with o crucial design decisions. We can think l is X, p is Y. There exists a program which translates all RPython programs to C:                rpython_compiler = RPython -> C  Python           pypy = Python -> Nothing RPython           translate = compile the program pypy written in RPython using rpython_compiler           py2rpy = Python -> RPython  Python      py2c = Python -> C Python       py2c = rpython_compiler . py2rpy      RPython programs are just like VM instructions, rpython_compiler is the VM. **q1.** pypy is the interpreter, a RPython program which can interpret Python code, there is no output language, so we can't consider it as a compiler, right? Added:   * I just found that even if after the translating, pypy is still a interpreter, only this time written in C.   * If we look deep into the interpreter pypy, I believe there must exist some kind of compiler, which compiles the Python sources to some AST, then execute like this:               compiler_inside_pypy = Python -> AST_or_so      **q2.** Can compiler py2rpy exist, transforming all Python programs to RPython? In which language it's written is irrelevant. If yes, we get another compiler py2c. What's the difference between pypy and py2rpy in nature? Is py2rpy much harder to write than pypy? **q3.** Is there some general rules or theory available about this? More compilers:               gcc_c = C -> asm? C  # not sure, gimple or rtl?     g++ =   C++ -> asm? C     clang = C -> LLVM_IR  C++     jython = Python -> JVMCode java     ironpython = Python -> CLI C#      **q4.** Given f = X -> Z, a program P written in X. When we want to speed up P, what can we do? Possbile ways:   * rewrite P in more efficient algorithm   * rewrite f to generate better Z   * if Z is interpreted, write a better Z interpreter (PyPy is at here?)   * speed up programs written in Z recursively   * get a better machine ps. This question is not about the tech stuffs of how to write a compiler, but the feasibility and complexity of write a certain kind compiler.


The optimal recipe problem

Suppose I have a list of Ingredients In My Fridge which are going off soon, and a list of Recipes which use up various Ingredients. (Some of which I don't currently have.) Is there an algorithm which produces the optimal set of Recipes, where an optimal set maximises the number of Ingredients In My Fridge used up and minimises the number of Ingredients I Have To Buy From The Store? (Alternate formulation: In a card game, I can combine some Cards according to various Rules; I can also obtain new Cards in various ways. How do I find the best set of Rules to use up the most Cards I have for the minimum effort in obtaining new Cards?)


Gevent - Make blocking calls non-blocking

I have the blocking code shown below. Is calling `monkey.patch_all()` enough/optimal to make it non-blocking? Does Gevent handle iterations like these?               # front page     def front_page():         database = db.posts.find() # find all items in posts collection              return render_template(                                'index.html',                                 database=database                               )               # single post     def single_post(slug):         post = [v for k,v                      in db.posts.find_one(                                          {'slug': slug}                                         ).iteritems()                ] # iterate over found items and store it as post              return render_template(                                'post.html',                                 title=post[3],                                 body=post[0],                                 slug=post[2]                               ) # extract the title, slug and body


Can this argument be enough?

We have two C++ classes named `Important` and `Small` The class `Small` use a few methods and attributes from the class `Important`, but not all. Since our application is performance critical, instead of copying all attributes (possibly pointers) of `Important` that are needed by `Small` and redefine the few methods in `Small`, we decided to just let `Small` hold a pointer on `Important`. Can performance justify such a design choice?


GRE CS Subject Test: Can you recommend the top books to read?

I am a long time professional C programmer planning to get admitted for a Masters degree in Computer Science. The University requires that I submit GRE CS subject test scores. I'm planning to sit for it this coming October, and have until then to prepare for it. I do not have a CS undergraduate degree, so suggestions of reading my undergraduate texts wouldn't be helpful. Which books would you recommend for me to purchase and read that will cover maximum percentage of the test topics? The test breakdown includes: > **I. SOFTWARE SYSTEMS AND METHODOLOGY — 40%** > > A. Data organization > > Data types > > Data structures and implementation techniques > > B. Program control and structure > > Iteration and recursion > > Procedures, functions, methods and exception handlers > > Concurrency, communication and synchronization > > C. Programming languages and notation > > Constructs for data organization and program control > > Scope, binding and parameter passing > > Expression evaluation > > D. Software engineering > > Formal specifications and assertions > > Verification techniques > > Software development models, patterns and tools > > E. Systems > > Compilers, interpreters and run-time systems > > Operating systems, including resource management and protection/security > > Networking, Internet and distributed systems > > Databases > > System analysis and development tools > > **II. COMPUTER ORGANIZATION AND ARCHITECTURE — 15%** > > A. Digital logic design > > Implementation of combinational and sequential circuits > > Optimization and analysis > > B. Processors and control units > > Instruction sets > > Computer arithmetic and number representation > > Register and ALU organization > > Data paths and control sequencing > > C. Memories and their hierarchies > > Performance, implementation and management > > Cache, main and secondary storage > > Virtual memory, paging and segmentation > > D. Networking and communications > > Interconnect structures (e.g., buses, switches, routers) > > I/O systems and protocols > > Synchronization > > E. High-performance architectures > > Pipelining superscalar and out-of-order execution processors > > Parallel and distributed architectures > > **III. THEORY AND MATHEMATICAL BACKGROUND — 40%** > > A. Algorithms and complexity > > Exact and asymptotic analysis of specific algorithms > > Algorithmic design techniques (e.g., greedy, dynamic programming, divide and > conquer) > > Upper and lower bounds on the complexity of specific problems > > Computational complexity, including NP-completeness > > B. Automata and language theory > > Models of computation (finite automata, Turing machines) > > Formal languages and grammars (regular and context-free) > > Decidability > > C. Discrete structures > > Mathematical logic > > Elementary combinatorics and graph theory > > Discrete probability, recurrence relations and number theory > > **IV. OTHER TOPICS — 5%** > > Example areas include numerical analysis, artificial intelligence, computer > graphics, cryptography, security and social issues.


Introducing "20% time" at a workplace

20% time it's the culture of an employer allowing it's employees to spend 20% of their time working on projects that they find interesting - it may be inventing a new app, or improving an existing process, etc. Some people _may_ know this as skunk work, however that term may not mean anything (or something entirely different) to you. There are many documented cases of great products being born out of 20%/skunk work at a company. It seems like a win/win situation; the company potentially gain a great new product or application, and the developer has the opportunity to flex his/her creative muscles and innovate. I tried on numerous occasions to introduce some form of 20%/Skunk working at my previous employer with no success. How can I better justify it to management? What's the "right" way to approach this kind of work arrangement?


A vector of pointers to different derived classes of the same base class

I am writing a game in C++ which has different enemy types. I have defined a base **_Enemy_** class and I also have derived classes **_enemy1_** , **_enemy2_** etc. Now for updating these enemies in each iteration of the game, I want to have an array: **_EnemyArray_** with its elements pointing to the existing enemies so that I can make sure to update them all with their own version of **_update()_** , etc. One way of doing this, would be to define separate arrays for each enemy type and that would be a clean way of solving the problem. However, I was wondering if the fact that these enemy classes are all derived from the same base class makes it possible to somehow have my EnemyArray as an array of **_Enemy_** 's and do some modifications later.


What is a Neural Network in simple words

Can you please explain neural networks in _simple words_ with an example?


Single responsibility: how does this code cause problems?

Given the following interface               interface Modem {         public void Dial(string pno);         public void Hangup();         public void Send(char c);         public char Recv();     }      Uncle Bob writes > However, there are two responsibilities being shown here. The first > responsibility is connection management. The second is data communication. > > ... > > Should these two responsibilities be separated? That depends upon how the > application is changing. If the application changes in ways that affect the > _signature of the connection_ functions, then the design will smell of > Rigidity because **the classes that call _send_ and _read_ will have to be > recompiled and redeployed more often than we like**. Can anyone explain to me how is the highlighted statement true? Why would I have to recompile code that calls the sending/receiving methods if the connection signature changes? I could have injected a ready made connection to the code using it.


Mobile App Development-Architecture/Platform: Main performance concern: device/UI responsiveness

I am currently investigating different alternatives for building a mobile instant messaging application for iOS and Android, using an XMPP server (probably ejabberd) as the back-end. Main requirements are a nice UI and of course good performance on most devices. I have identified three different alternatives, two of which include using the Marmalade SDK Option A): Use Marmalade C++, creating the UI with Marmalade Libraries such as IwNUI/INUI. In this option, the UI is created in C++ code. My assumption is that this should be good in performance, however I am not sure how easy it is to achieve a nice, custom UI that has a good/modern feel to it, such as other high-quality apps. Another advantage: This would target iOS/Android with one code base. Option B): Also Marmalade, using the C++ s3eWebView api to load local web pages packaged in the application package. UI would be designed in these web pages using HTML/CSS/JavaScript. For the application logic, JavaScript or C++ can be used, as there is a JavaScript Bridge (http://docs.madewithmarmalade.com/display/MD/The+Javascript+interface) to communicate between C++ and JavaScript code. Would also target iOS/Android in one go. Option C): Non-Marmalade: Go with two code bases. Use Objective-C (i.e. "standard way") for iOS, and Google Android SDK for Android. Build the app twice. I am currently leaning towards Option B, as this would allow for use of one code base, and leverage existing HTML5/CSS/JavaScript technologies (nice especially for UI), together with the ability to use C++. However, my concern is whether device/UI responsiveness will be acceptable with this. I have run some preliminary tests for simple things such as loading CSS3 dropdown menus into an s3eWebView via C++, and this seems fairly responsive (i.e. menu drops down quickly and smoothly).


How deterministic are SessionIDs from SHA'd GUIDs?

Assume I'm using the following code to generate pseudo-random sessionID's:               sessionID = SHA-512(GENERATE-GUID())      The GUIDs are pretty deterministic, i.e. I see lots of GUIDs with a lot of the same hexadecimals. My simple question is: How deterministic are my resulting sessionID's? The algorithms for SHA are supposed to create very different hashes even if a small number of bits are different due to its cascading effect, so how easily could you "guess" (within reasonable time) another sessionID from the resulting hashes?


Is it possible to modify a native executable and change (dynamic) library it depends on?

Say I compile a simple application called `myproggy` that depends on the `libfoo` dynamic library. Assuming I have another dynamic library `libbaz` that implements absolutely the same interface (in other words it has definitions of the same functions as libfoo), is it possible to modify the `myproggy` to depend upon `libbaz` without the need for rebuild? I can easily do this in the case when I can dynamically load the library, but what if I can't, and I also can't re-compile the library? I am also aware of the security issues related to this.


How should this relationship be structured in a relational database?

In a recent project I was asked to implement an events system. An `Event` had to have a `Location` which was originally specced out as simply a physical location with some optional extra notes. Then the spec changed (as they have a habit of doing) and we needed to have "online" events too. These would not have a physical address but would still need notes on how to attend (e.g. the URL, joining instructions). We decided to adapt the existing Location table by adding an `IsOnline` field and it wound up looking like this:               +-----------------+     +---------------+     |      Event      |     |    Location   |     +-----------------+     +---------------+     | Id              |  .--+ Id            |     | Name            |  |  | Name          |     | Summary         |  |  | Address       |     | Date            |  |  | Postcode      |     | Capacity        |  |  | IsOnline      |     | LocationId      +--'  | Notes         |     +-----------------+     +---------------+      An example of a physical and an online entry in the Location table look like this:               +----+----------------+--------------------------------------+----------+----------+---------------------------------------+     | Id |      Name      |               Address                | Postcode | IsOnline |                 Notes                 |     +----+----------------+--------------------------------------+----------+----------+---------------------------------------+     |  1 | Physical Event | 10 Downing Street, London            | SW1A 2AA |        0 | Ask the policeman to let you in       |     |  2 | Online Event   | http://programmers.stackexchange.com | null     |        1 | You will need a stackexchange account |     +----+----------------+--------------------------------------+----------+----------+---------------------------------------+      It works (currently) for our simple use case but it is clearly a bit of a hack and it got me thinking - what would be the correct, normalized way to model this kind of relationship (Where an entity must have an A or a B but not both)?


If I were to claim I knew C++, what libraries would you expect me to know?

I'm unsure as to the definition of knowing a programming language, so I'm picking C++ as an example. How much does it take to someone to be qualified as knowing C++?   * Should they just know the basic syntax?   * Template and generic-programming?   * Compiler flags and their purposes (Wall, the difference between O1, O2 and O3)?   * STL?   * Garbage collection strategies?   * Boost?   * Common libraries like zlib, curl, and libxml2?


Integrated PowerShell Console Window

I would like to have a tab open for PowerShell inside of my VS2012. There are other consoles that I have access to, such as "Command Window" and "Package Manager Console" Is there any way to get a Powershell console window open? I've attached an image that shows where I would like the PS window.![enter image description here](http://i.stack.imgur.com/zgwn8.png) http://i.imgur.com/kDs9Yhv.png


Simple C: How do I scan this information in properly?

OK this is a simple question but for some reason I just can't get it right. I have to scan from a file hundreds of lines of code and store it in a array (which I can normally do a ok job with) however At one point the code will specify a number that then corresponds to the next batch of chars ints and floats going into various arrays. As I know I am not describing this correctly here is a example. one line of the file I am reading will contain something close to this. > 0221 T 2 S P 850 150 0.90 0.75 500 24 2 2012 G A 7 9600.00 0.1 1000 > Name_of_place > > 0104 L 1 F 400 1.00 0.75 500 24 2 2012 G A 7 9600.00 0.1 1000 Ballroom the problem I am having is This part here > 0221 T **2 S P 850 150** 0.90 0.75 500 24 2 2012 G A 7 9600.00 0.1 1000 > Name_of_place > > 0104 L **1 F 400** 1.00 0.75 500 24 2 2012 G A 7 9600.00 0.1 1000 Ballroom The rest after this is Generally the exact same however at this point the number at the front descides all the values that are going in. I am almost completely lost on how to write a way that can scan this and store the data into arrays correctly


How to name a variable when the word is both a noun and a verb

I have run into a corner-case problem with the general guidance of:   * nouns for variables   * verbs for functions Specifically, I have a case where the word is ambiguous - it can be either a verb **_or_** a noun. And in some cases when we're discussing the application, it will be used _both_ ways in the same sentence. My intent is to make sure the program will remain readable to future developers as well as myself when I return to sections of code months later. One of the examples is with a `battery`. A `battery` has a `charge` and you can also `charge()` a battery. I think that having both `Battery.Charge` and `Battery.Charge(value)` will be confusing to future developers. My current solution is to simply pick a different word for one or both of those cases (the variable and the function). My problem with that approach is the `Battery` object's variable and function for `charge` won't align with design discussions involving the `Battery`. **My question is if there is another / better way to handle this conflict in naming convention?** * * * Some additional reading on the subject. None really addressed the particular of my question.   * Meaningful concise method naming guidelines   * Naming conventions for variables   * The selected answer from What naming guidelines do you follow?


Custom maven mojo and tools

I'm writing maven plugin which depends on several java tools. I'm quite happy with it and want to share it with the community. I'm interested in correct way to handle dependency to these tools:   1. Use usual dependency way - put to central repository. But I'm not owner of these tools and I'm not going to maintain them. But I could start discussion with author   2. As I saw like several other plugins require for user to download these tools and provide path to them through configuration. But they are java tools, as well this is much less convenient for the end users I'm asking community what would be the best and "right" in maven way to handle this.


RESTful Design: Multiple Relationships Between the Same 2 Entities

I am in the process of designing RESTful web services and got stuck at one point. The design is very simple with 3 entities:               - Project     - Status     - Employee      The part I am having trouble with is capturing the relationships:               - A project has a current status (1 to 1 between Project and Status).     - A project has multiple 'possible subsequent status' (1 to many between Project and Status).      The Visual Studio designer does not allow these two different relationships to be defined between these two entities. I am aware that it is just a modelling tool but at the same time, I am willing to know if this is the right approach. Also, with this design, I am not sure how to access the Status entities using these two relationships.               http://serviceRootURL/Project(2)?$expand=Status // For current status     http://serviceRootURL/Project(2)?$expand=SubsequentStatus // For subsequent status      Is it possible to use arbitrary relationship names with the expand keyword? _(The question probably touches OData a little bit as well since I am trying to make my library OData-compliant.)_


Are there advantages to using a DVCS for a solo developer?

Right now, I use visual svn on my server, and have ankhsvn/tortoise on my personal machine. It works fine enough, and I don't have to change, but if I can see some benefits of using a DVCS, then I might give it a go. However, if there's no point or difference using it without other people, then I won't bother. So again, I ask, are there any benefits to using a DVCS when you're the only developer?


Getting my feet wet with open source - creating a small project on my own VS contributing to a big one?

I want to contribute to the open source community, but I've never done it before, and I have some concerns regarding the collaboration process - I am afraid that I will just "get in the way" of other developers, and since (I assume) that they are pretty polite guys, they will feel bad about telling me to bug off. I imagine things like adding the feature X in 1.3.0, just to realize that there was actually such thing in 1.1.5, but it was intentionally removed in 1.1.8 because of Y. Being an independent contractor (a freelancer) I work very rarely with other developers, as a team, and I do understand that the software collaboration is a complex area (I've read a couple of books on management of big teams, seems to be a delicate area, at least to me). To my actual question - should I start with something small (that I will create), and wait for other contributors to join it (ones that will know how "the stuff works", so I can slowly get my head straight on the collaboration part), or I should try to join a big project, which has a lot of activity in it, so I can see the big picture (but risking to be a pain for them) ?


Should I encourage junior developers to use explicit or implicit typing?

I am looking to solicit the community's opinion on whether or not it would be advisable to teach junior developers to code with implicit typing (using var) or should I encourage the use of explicit types. This is not really a question about the advantages or disadvantages of implicit typing. Junior developers (at least the ones that I deal with) tend to develop very long lasting coding habits in their first years as professional developers and I am trying to think through the potential downside of starting a developer off with the implicit typing approach. Are there specific scenarios that would warrant the advocacy of explicit typing? What about as part of the discipline of TDD? **And on the issue of ReSharper...** @Eben Geer mentioned ReSharper in his answer. Should we keep the default suggestion to use implicit typing in the inspection templates that our junior developers use?


Feature code + infrastructure code - how to structure the commits / JIRA issues?

Say that you work on a feature described by a **single JIRA ticket** and during the work, you:   1. Create **feature-specific code** like the GUI or specific use-case behavior.   2. Some of the code was generic so you placed this **infrastructure code** in a shared library. As an example (deliberately simple), say that the ticket is about changing a message somewhere in the application and that the message should contain the current year somewhere in it. So you first amend your PHP code where the message is and also create a helper function `getCurrrentYear()` in your `DateUtils` library. What is the best practice now to store these changes to a source code repository and assign those code changes to JIRA ticket(s)? (Assigning commit to a JIRA ticket means in our case adding a tag to a commit message, for instance _"Implemented feature #123"_.) As I see it, there are these main options:   1. Create one commit and assign in to the given JIRA ticket.   2. Create two commits (one for the use-case logic and one for the infrastructure code). Assign both of them to the single JIRA ticket.   3. Assign only the feature-specific commit to the JIRA issue and leave the other unassigned (when viewing the ticket in JIRA, only the first commit will be visible in the "source code" tab).   4. Similar to 3 but you have a generic ticket like "Infrastructure improvements". Is there a best practice / recommended way? What are some of the benefits and problems of the various possibilities?


Database Design - Optimise Relationships

I am about to embark on a redesign of an application, one where querying the database is particularly annoying. I intend to redesign the database as much as possible but the data shape cannot change too much. The database has a main table and 10 other tables each representing a record type. The main table has all of the data the record types have in common. Record ID, DateLogged etc. Around 30-40 columns in total. The other tables are all completely different as each record type is very different from another. They all have about 20-30 columns each. The main table has a column called type, which is an int. However nowhere does it reference what record types the type numbers refer to. You can just figure it our by looking at the procedures. The main table has to join with each type table to allow searching. I have added an image representing what I am trying to describe. ![enter image description here](http://i.stack.imgur.com/FbdZp.png) Is there a better way to create these relationships? I would like to ditch the verbose stored procs used with ADO.NET and move to EF. I need to think of a better way to relating the data so people in the future wont need to work out the relationships by scouring stored procedures for clues.


Designing a robust architecture for multiple export types?

I'm looking for patterns or architectural guidance for an upcoming feature I'm designing. Basically, it's an export feature with multiple export targets, and I'm looking to find a way to make it generic enough where plugging in new export targets don't require a lot of core changes. By export targets, I'm simply referring to different types of output, whether that be PDFs, PowerPoint presentations, Word documents, RSS, etc. I have a base set of data, which is represented in JSON and XML. This data are used to construct images (using any number or export types [e.g., PNG, JPG, GIF, etc), graphs, textual representations, tables, and more. I'm trying to find a way to abstract all the rendering and layout into some kind of rendering or layout engine that handles the addition of further export targets. Any help/suggestions/resources as to how to approach this would be greatly appreciated. Thanks in advance. For a pictorial representation of what I'm trying to achieve. ![enter image description here](http://i.stack.imgur.com/aAvE9.png)


TDD: What happens before the first unit test?

I mostly understand the theory of TDD, but I can't figure out how to get started. I sit down to write a unit test for a personal project and realize . . . I have no idea what I am testing. What objects, what functionality, etc. E.g., let's say I want to write an app to help our family manage chore assignments. Here are some questions in my mind: How do I go from this idea to my first test? How much should be decided before I start, and how much do I figure out after I start writing tests? When do I make decisions like whether to store data in a text file or a database? Should I have user acceptance tests before I get started? Should I have the UI designed? Should I have a spec? (I do realize at least some of these example questions are probably in a "gray area"). In addition to the title question about getting to the first unit test, could you also give an example of what the first unit test for a project like the sample project might look like?


How to handle multi-processing of libraries which already spawn sub-processes?

I am having some trouble coming up with a good solution to limit sub-processes in a script which uses a multi-processed library and the script itself is also multi-processed. Both, the library and script are modifiable by us. I believe the question is more about design than actual code, but for what it's worth, it's written in Python. The goal of the library is to hide implementation details of various internet routers. For that reason, the library has a "Proxy" factory method which takes the IP of a router as parameter. The factory then probes the device using a set of possible proxies. Usually, there is one proxy which immediately knows that is is able to send commands to this device. All others usually take some time to return (given a timeout). One thought was already to simply query the device for an identifier, and then select the proper proxy using that, but in order to do so, you would already need to know how to query the device. Abstracting this knowledge is one of the main purposes of the library, so that becomes a little bit of a "circular- requirement"/deadlock: To connect to a device, you need to know what proxy to use, and to know what proxy to create, you need to connect to a device. So probing the device is - as we can see - the best solution so far, apart from keeping a lookup-table somewhere. The library currently kills all remaining processes once a valid proxy has been found. And yes, there is always only one good proxy per device. Currently there are about 12 proxies. So if one create a proxy instance using the factory, 12 sub-processes are spawned. So far, this has been really useful and worked very well. But recently someone else wanted to use this library to "broadcast" a command to all devices. So he took the library, and wrote his own multi-processed script. This obviously spawned `12 * n` processes where `n` is the number of IPs to which he broadcasted. This has given us two problems:   1. The host on which the command was executed slowed down to a near halt.   2. Aborting the script with `CTRL`+`C` ground the system to a total halt. Not even the hardware console responded anymore! This may be due to some Python strangeness which still needs to be investigated. Maybe related to http://bugs.python.org/issue8296 **The big underlying question** , is how to design a library which does multi- processing, so other applications which use this library and want to be multi- processed themselves do not run into system limitations. My first thought was to require a pool to be passed to the library, and execute all tasks in that pool. In that way, the person using the library has control over the usage of system resources. But my gut tells me that there must be a better solution. * * * **Disclaimer:** My experience with multiprocessing is fairly limited. I have implemented a few straightforward which did not require access control to resources. So I have not yet any _practical_ experience with semaphores or mutexes. **p.s.:** In the future, we may have enough information to do this without the probing. But the database which would contain the proper information is not yet operational. Also, the design about multiprocessing a multiprocessed library intrigues me :)


Generic rule parser for RPG board game rules - how to do it?

I want to build a generic rule parser for pen and paper style RPG systems. A rule can involve usually 1 to N entities 1 to N roles of a dice and calculating values based on multiple attributes of an entity. For example: Player has STR 18, his currently equipped weapon gives him a bonus of +1 STR but a malus of DEX -1. He attacks a monster entity and the game logic now is required to run a set of rules or actions: Player rolls the dice, if he gets for example 8 or more (base attack value he needs to pass is one of his base attributes!) his attack is successfull. The monster then rolls the dice to calculate if the attack goes through it's armor. If yes the damage is taken if not the attack was blocked. Besides simple math rules can also have constraints like applying only to a certain class of user (warrior vs wizard for example) or any other attribute. So this is not just limited to mathematical operations. If you're familiar with RPG systems like Dungeon and Dragons you'll know what I'm up to. My issue is now that I have no clue how to exactly build this the best possible way. I want people to be able to set up any kind of rule and later simply do an action like selecting a player and a monster and run an action (set of rules like an attack). I'm asking less for help with the database side of things but more about how to come up with a structure and a parser for it to keep my rules flexible. The language of choice for this is php by the way. **Edit I:** Let me refine my goal: I want to create a user friendly interface (that does not require somebody to learn a programming language) to build more or less complex game rules. The simple reason: Personal use to not need to remember all the rules all the time, we simply do not play that often and it's a stopper to look them up each time. Also: Looks like a fun task to do and learn something. :) **What I've tried so far:** Just thinking about a concept instead of wasting time building a wrong architecture. So far I have the idea to allow a user to create as many attributes as they want and then assign as many attributes as they want to any kind of entity. An entity can be a player, a monster, an item, anything. Now when calculating something the data is made available to the rule parser so that the rule parser should be able to do things like if Player.base_attack + dice(1x6) > Monster.armor_check then Monster.health - 1; The question here is about how to create that parser. **Edit II:** Here is an example of pretty basic value but to calculate it properly there are lots of different things and variables to take into account: > Base Attack Bonus (Term) Your base attack bonus (commonly referred to as BAB > by the d20 community) is an attack roll bonus derived from character class > and level. Base attack bonuses increase at different rates for different > character classes. A character gains a second attack per round when his base > attack bonus reaches +6, a third with a base attack bonus of +11 or higher, > and a fourth with a base attack bonus of +16 or higher. Base attack bonuses > gained from different classes, such as for a multiclass character, stack. A > character’s base attack bonus does not grant any more attacks after reaching > +16, cannot be less than +0, and does not increase due to class levels after > character level reaches 20th. A minimum base attack bonus is required for > certain feats. You can read it here http://www.dandwiki.com/wiki/Base_Attack_Bonus_(Term) including the links to classes and feats which have again their own rules to calculate the values that are required for the base attack. I began to think that keeping it as generic as possible will also make it pretty hard to get a good rule parser done.


how to patent software

I am interested in patenting a piece of software that I have created with a group of people. I live in europe. I have no idea how to go about it, but I have multiple users tell me that I should have it patented for safety. So I was wondering where do I start? There are so many links online giving me a whole load of information. I was just hoping for a more straight forward answer. If more info needed, please let me know, happy to share.


How are operators organized in memory

How are operators organized/saved in the memory in context of a programming language. Are they procedures/functions saved somewhere and compilers just manipulate things to call these procs whenever the operators are used in the program?


How Byte loading/storing is implemented By the CPU?

I know that in 32bit machine, cpu read from memory 32bits at a time. since the registers in this case is 32bit in size too, I can understand how this works. What I don't understand is how the cpu implement load instructions of 1 byte. does it load the whole word where the single byte is located to the register, then perform some kind of "byte shifting", or does the cpu can load a single byte, in this case when does the byte masking happen, is it until the byte got loaded in the register, or it happen when byte is send through the data bus ? P.S. The cpu Im using is MIPS, the instructions Im talking about are: lb or lbu


Would form keys reduce the amount of spam we receive?

I work for a company that has an online store, and we constantly have to deal with a lot of spam product reviews, and bogus customer accounts. These are all created by automated systems and are more of a nuisance than anything. What I am thinking of (in lieu of captcha, which can be broken) is adding a sort of form key solution to all relevant forms. I know for certain some of the spammers are using XRumer, and I know they seldom request a page before sending us the form data (Is this the definition of CSRF?) so I would think that tying a key to each requested form would at least stem the tide. I also know the spammers are lazy and don't check their work, or they would see that we have never posted a spam review, and they have never gained any revenue from our site. Would this succeed in significantly reducing the volume of spam product reviews and customer account creations we are seeing? EDIT: To clarify what I mean by "Form Keys": I am referring to creating a unique identifier (or "key") that will be used as an invisible, static form field. This key will also be stored either in the database (relative to the user session) or in a cookie variable. When the form's target gets a request, the key must be validated for the form's data to be processed. Those pesky bots won't have the key because they don't load the javascript that generates the form (they just send a blind request to the target) and even if they did load the javascript once, they'd only have one valid key, and I'm not sure they even use cookies.


Is it better to pass the whole object or use a setter?

Here is my initial code that I would like to modify by using strategy design pattern.               class Bar     {       int a;       int b;       ...     }          Class Foo     {       Bar *bar;            bool action1(){          // this function does a lot of work that only uses "bar.a"       }       bool action2(){          // this function does also a lot of work that only uses "bar.a"       }       void command(){         ...         Bar bar2 = new Bar();          bar = bar2; // this function modifies the attribute bar.         ...       }            ...     }      I am trying to separate the code of both action1 and action2 from the class Foo by creating a strategy object that will implement those actions. I don't know which of those implementations is better. First Solution:               class ActionStrategy {       Bar *bar;            bool action1();       bool action2();     }          Class Foo     {       Bar *bar;       ActionStrategy strategy            bool action1(){          strategy.action1();       }       bool action2(){          strategy.action2();       }       void command(){         ...         Bar bar2 = new Bar();          bar = bar2; // this function modifies the attribute bar.         ...       }            ...     }      Second Solution:               class ActionStrategy {       int a;            bool action1();       bool action2();     }          Class Foo     {       Bar *bar;       ActionStrategy strategy            bool action1(){          strategy.action1();       }       bool action2(){          strategy.action2();       }       void command(){         ...         Bar bar2 = new Bar();          setBar(bar2); // this function modifies the attribute bar.         ...       }            void setBar(Bar* target) {         bar = target;         strategy.a = target->a;       }            ...     }


UML class diagram: how to annotate observer-subject relationship?

How can I annotate in a UML class diagram that an instance of ClassA is registered as an observer of an instance of ClassB? (Both implement the appropriate interfaces). This doesn't really belong in a class diagram, because they are static, but if this is something that is important to the design - how can you annotate it in this type of diagram? Edit: To clarify: I know how to annotate the Observer pattern in UML. My question is more specific. ClassA being registered as an observer to ClassB is important for the design, however I'm not sure if an association relationship between the two classes is appropriate, since **ClassA and ClassB don't know about each other. They're totally decoupled, and only connected through the Observer pattern**.


Which are the fundamental stack manipulation operations?

I'm creating a stack oriented virtual machine, and so I started learning Forth for a general understanding about how it would work. Then I shortlisted the essential stack manipulation operations I would need to implement in my virtual machine:               drop ( a -- )     dup  ( a -- a a )     swap ( a b -- b a )     rot  ( a b c -- b c a )      I believe that the following four stack manipulation operations can be used to simulate any other stack manipulation operation. For example:               nip  ( a b -- b )       swap drop     -rot ( a b c -- c a b ) rot rot     tuck ( a b -- b a b )   dup -rot     over ( a b -- a b a )   swap tuck      That being said however I wanted to know whether I have listed all the fundamental stack manipulation operations necessary to manipulate the stack in any possible way. Are there any more fundamental stack manipulation operations I would need to implement, without which my virtual machine wouldn't be Turing complete?


Is chartership important for software engineers?

I'm based in the UK and have been developing software for over 10 years so think I am a reasonable way through my career. On and off in various jobs I have had I have been members of various institutions, the BCS and the IEE being the main ones. At the moment I am not a member of either. I have tended to work in areas where most people are system engineers rather than software engineers but there has generally been a push to try and get everyone chartered at a level or other. However I actually do not know what use chartership has for me. Many senior people I have worked with say hat they have never bothered. It has never been part of any interview I have been one and it seems to make no difference to pay/training/conditions etc. So, can anyone tell me if looking at chartership for software roles is useful or important and if so, should I be looking at BCS or IEE?


How to get initial API right using TDD?

This might be a rather silly question as I am at my first attempts at TDD. I loved the sense of confidence it brings and generally better structure of my code but when I started to apply it on something bigger than one-class toy examples, I ran into difficulties. Suppose, you are writing a library of sorts. You know what it has to do, you know a general way of how it is supposed to be implemented (architecture wise), but you keep "discovering" that you need to make changes to your public API as you code. Perhaps you need to transform this private method into strategy pattern (and now need to pass a mocked strategy in your tests), perhaps you misplaced a responsibility here and there and split an existing class. When you are improving upon existing code, TDD seems a really good fit, but when you are writing everything from scratch, the API you write tests for is a bit "blurry" unless you do a big design up front. What do you do when you already have 30 tests on the method that had its signature (and for that part, behavior) changed? That is a lot of tests to change once they add up.


JSF problems due to shared server-side state

On it's latest technology radar, the guys at ThoughtWorks recommended avoiding JSF because it's attempt to create statefulness over HTTP ends up "causing a whole host of problems involving shared server-side state". I've been using JSF 2.x for almost a couple years now, I like it and I can't say I've encountered any problems like that. But I don't have that much experience with it and much less with alternatives, so I would like to understand what are those "whole host of problems"? Questions about JSF usually raise some heated discussions, so I think it pays to be clear: this is about JSF 2.x, but not about it being better or worse than X or Y, whether it's architecturally right to put state in HTTP, or anything like that. I'd just like to know what are those problems since the radar doesn't go on specifics.


How can you filter out irritable programmers in interviews?

So I've had a few situations now where programmers have passed the interview teams with flying colors, only to find when they arrive on scene, they demonstrate an extreme touchiness any time any criticism is leveled their way. I'm not talking about off-day irritability, but a 24/7 bruised ego thing. For certain employees this pertains to code review feedback, but others it can even include debugging suggestions (even if they're right). How do you filter out touchy candidates during the interview process in a manner that won't get you in trouble with HR? (I'm thinking something far short of Blade Runner here). Additionally, how can you help those types of programmers better deal with both real and perceived criticisms?


What are some techniques I can use to refactor Object Oriented code into Functional code?

I've spent about 20-40 hours developing part of a game using JavaScript and HTML5 canvas. When I started I had no idea what I was doing. So it started as a proof of concept and is coming along nicely now, but it has no automated tests. The game is starting to become complex enough that it could benefit from some automated testing, but it seems tough to do because the code depends on mutating global state. I'd like to refactor the whole thing using Underscore.js, a functional programming library for JavaScript. Part of me thinks I should just start from scratch using a Functional Programming style and testing. But, I think refactoring the imperative code into declarative code might be a better learning experience and a safer way to get to my current state of functionality. Problem is, I know what I want my code to look like in the end, but I don't know how to turn my current code into it. I'm hoping some people here could give me some tips a la the Refactoring book and Working Effectively With Legacy Code. * * * For example, as a first step I'm thinking about "banning" global state. Take every function that uses a global variable and pass it in as a parameter instead. Next step may be to "ban" mutation, and to always return a new object. Any advice would be appreciated. I've never taken OO code and refactored it into Functional code before.


Design Patterns - Service Layer

I currently reading a lot about Design Patterns and I have been watching various Pluralsight videos from their library. Now so far I have learnt the following:   1. Repository Pattern   2. Unit of Work Pattern   3. Abstract Factory Pattern   4. Reading the awesome "DI in .NET" book Now I read lot about **Services** and **Service Layers** and wanted some advice about the best place to read up and learn about these. I presume this fits into Domain Driven Design and I should start there? The term "Service" just seem to be used widely within IT and it can be confusing the exact meaning. So my questions is:   1. What is the **Service Layer**   2. Where is the best place to learn about them. I know there are probably tonnes of interweb/books/blogs on the subject, but some good areas to start from would be nice. If I'm being too vague, let me know.


Inheritance, commands and event sourcing

In order not to redo things several times I wanted to factorize common stuff. For Instance, let's say we have a cow and a horse. The cow produces milk, the horse runs fast, but both eat grass.               public class Herbivorous     {        protected int Quantity;             public void EatGrass(int quantity)        {           var evt= Build.GrassEaten                         .WithQuantity(quantity);           RaiseEvent(evt);        }             public void Apply(GrassEaten evt)        {            _quantity= evt.Quantity;        }     }          public class Horse : Herbivorous     {        private bool _HasFastRun;             public void RunFast()        {           var evt= Build.FastRun;           RaiseEvent(evt);        }             public void Apply(FastRunevt)        {            _HasFastRun= true;        }     }          public class Cow: Herbivorous     {        private bool _IsMilkProduced;             public void ProduceMilk()        {           var evt= Build.MilkProduced;           RaiseEvent(evt);        }             public void Apply(MilkProduced evt)        {            _IsMilkProduced= true;        }     }      To eat Grass, my application receives a command in Json or xml, or whatever that deserialise into this class:               namespace Herbivorous     {        public class EatGrass : CommandBase        {           public Guid IdHerbivorous {get; set;}           public Guid CommitId {get; set;}           public long Version {get; set;}           public int Quantity {get; set;}        }     }      The command handler should be :               public class EatGrassHandler : CommandHandler<EatGrass>     {        public override CommandValidation Execute(EatGrass cmd)        {           Contract.Requires<ArgumentNullException>(cmd != null);           Herbivorous herbivorous= EventRepository.GetById<Herbivorous>(cmd.Id);           if (herbivorous.IsNull())              throw new AggregateRootInstanceNotFoundException();           herbivorous.EatGrass(cmd.Quantity);           EventRepository.Save(herbivorous, cmd.CommitId);        }     }      so far so good. I get a Herbivorous object , I have access to its EatGrass function, whether it is a horse or a cow doesn't matter really. The only problem is here :               EventRepository.GetById<Herbivorous>(cmd.Id)      Indeed, let's imagine we have a cow that has produced milk during the morning and now wants to eat grass. The EventRepository contains an event MilkProduced, and then come the command EatGrass. With the CommandHandler, we are no longer in the presence of a cow and the herbivorious doesn't know anything about producing milk . what should it do? Should I have explicit contextual command like :               namespace Herbivorous.Cow         {            public class EatGrass : CommandBase            {               public Guid IdHerbivorous {get; set;}               public Guid CommitId {get; set;}               public long Version {get; set;}               public int Quantity {get; set;}            }            public class ProduceMilk : CommandBase            {               public Guid IdHerbivorous {get; set;}               public Guid CommitId {get; set;}               public long Version {get; set;}            }         }      This would mean that the external component that asks my herbivorous to eat grass should know that in this bounded context we talk about a cow. in the former command, we were talking about a general Herbivorous behavior, so the context of my call was not important. We knew that we needed herbivorous to eat grass that was all. This is my main problem possible leakage of domain specific from one bounded context to another. Actually It might mean too that I cannot support abstraction when working on interfaces between several applications. I wonder... Or I could just accept any event when rebuilding my herbivorous. It means that if it does not find a method to apply this event to, he will goes just fine trying to apply the next one of its stream. This is the real simple solution, but it does not put me at ease to know that events might not be applied ( and not producing errors) when rehydrating my object. (Actually the more I think about it the less I feel guilty..) Thanks for your help, I am just beginning with these kinds of problem, and I would be glad to have some news from someone more experienced.


Why large projects with big budgets are more likely to fail?

I have heard two reasons why information systems projects fail.   1. Large projects with big budgets are more likely to fail   2. When there are two isolates teams, one doing the software design and the other implementation. These two failure reasons are described as recipes for disaster, but I don't understand that. Can anyone explain why these are recipes for disaster?


LGPL and commerical application in PHP

I have rather specific question about licensing but first of all I would just like to state that I already read a lot of Q&A's here but I'm still not sure about the problem in that particular scope. As I've understand from other Q&A's, you are allowed to distribute your commercial application even with LGPL library as long as this library can be replaced by another version of it by user himself. That means that you pack it as .dll or whatever. The rest of the application remains proprietary licensed. This is clear at all for compiled software. But my question is: how this relate to software which is not compiled (which is distributed as source code but still proprietary) like all PHP applications? To be really clear I will show you exact example. I'm building a CMS applications for various purposes. All of them are different but most of them share the same "basic element" - JavaScript WYSIWYG editor. I would like to use one which is GPL/LGPL/MPL licensed. So there are several questions:   * Can I use this LGPL editor at all so that rest of my application remains proprietary?   * What I have to do to be able to do that?   * Are there any special "ways of distributing" the library like separated ZIP archive or something like that? As for non-native English speaker it's really hard for me to read the licenses in their original form. I just don't want to get in any trouble.


Book recommendation and advice on Analysis Patterns: Reusable Object Models

I am a software developer, and have knowledge of oo design, e.g. SOLID, and looking for a good book on object-oriented modeling. Is the book below still good to read? Analysis Patterns: Reusable Object Models Martin Fowler Publication Date: October 19, 1996


Does anyone prefer proportional fonts?

I was reading the wikipedia article on programming style and noticed something in an argument against vertically aligned code: > Reliance on mono-spaced font; tabular formatting assumes that the editor > uses a fixed-width font. Most modern code editors support proportional > fonts, and the **programmer may prefer to use a proportional font for > readability**. To be honest, I don't think I've ever met a programmer who preferred a proportional font. Nor can I think of any really good reasons for using them. Why would someone prefer a proportional font?


Are bugs part of technical debt?

Our Scrum Master keeps referring to bugs as technical debt. Is he right, are bugs considered to be technical debt in the world of Agile?


Use of mind-mapping software in project/task management

I've recently "discovered" mind mapping and even found some people here recommending it. It seems like a real handy tool, but I'm not really sure how to apply it to my work and/or hobby projects. I _really_ want to organize my time and work, because I feel like my projects are stagnating lately, and that doesn't really feel nice. So I'm interested in any tips you have if you're using mind maps, how do you organize your projects, TODOs, ideas..? For example: do you keep separate mind maps for projects, tasks, ideas, or do you have separate mind maps for each project? How do you organize your project mind maps? Please share your thoughts and ideas. (Feel free to suggest alternative methods if you think mind maps suck, but state your reasons) _[Can we make this community wiki since there is no "right" answer?]_


Is PHP actually a web framework?

I was reading an article/interview ( _Language War: PHP vs. Ruby_ (by Jeffrey Way; Mar 2011)) by a developer for Envato using Ruby. He says, "PHP is a web framework disguised as a language." He didn't expound on that statement, so it got me wondering if that is true, and if so how. I did a bit of research but couldn't turn up any information on this topic. I'm wondering how this statement is true and what makes PHP not a programming language. And why do other languages like python or ruby not fit in that category?


Which is a better practice - helper methods as instance or static?

This question is subjective but I was just curious how most programmers approach this. The sample below is in pseudo-C# but this should apply to Java, C++, and other OOP languages as well. Anyway, when writing helper methods in my classes, I tend to declare them as static and just pass the fields if the helper method needs them. For example, given the code below, I prefer to use **Method Call #2**.               class Foo     {       Bar _bar;            public void DoSomethingWithBar()       {         // Method Call #1.         DoSomethingWithBarImpl();              // Method Call #2.         DoSomethingWithBarImpl(_bar);       }            private void DoSomethingWithBarImpl()       {         _bar.DoSomething();       }            private static void DoSomethingWithBarImpl(Bar bar)       {         bar.DoSomething();       }     }      My reason for doing this is that it makes it clear (to my eyes at least) that the helper method has a possible side-effect on other objects - even without reading its implementation. I find that I can quickly grok methods that use this practice and thus help me in debugging things. Which do you _prefer_ to do in your own code and what are your reasons for doing so?


How can you become a real programming polyglot?

I work as a Java programmer, but C and C++ were always my favourite languages during studies. Unfortunatelly I don't have an opportunity to work with them as often as I would like to. As a result I sometimes get realized that I don't remember something quite important (today example: inherited protected members cannot be accessed in derived class constructors). The other example could be Python and Haskell which I enjoy using but don't use everyday. I got an idea to write my own wiki with easy to forget things (e.g. bash tricks & tips) but I find no sense in writing there everything I can forget about coolest programming languages. I know that the best way would be having a side projects (I want to start working on some C/C++ open source project after graduation), but currently I have to write my graduation thesis and work so I merely don't have time to do this. How do you stay sharp in languages that you don't use everyday?


DDD with entities with no relations

_Disclaimer: I'm not 100% sure I understand some of the practices and concepts in DDD, so this question may actually be answered by clarification of the ideas_ I'm working in a legacy system (written in PHP) in which the database tool provides no object relational mapping, and thus objects coming out of the database access layer tend to be, more or less, mirrors of the rows returned by the query. For newer modules, I'm trying to apply DDD. However, I'm struggling with how to build a rich domain model when my entities have no relations. Take for example the following requirement: `users can see the messages they have previously accepted`, where a message being accepted is, internally, recorded by a single new row in a database table. Were I using an ORM and did my entities have relations, I may write something akin to `$user->getAcceptedMessages()`, which would return a collection of message entities. However, since I don't have that, I'm torn between two approaches:   1. Populate the relations as part of the building of the entity in the repository. The queries could get big, unwieldy and hard to maintain as the number of relations grows and the schema changes.   2. Create services for actions such as this, which depend on the repository and a take a user, eg `UserMessageAcceptanceService`. However, I suspect this might lead to an anemic domain model. Is either approach sensible in this scenario? Or is some form of ORM a requirement for applying DDD effectively?


What would be a non-contrived reason to have an object with Private Copy Constructor as well as Assignment Operator?

Looking for non-conceptual/non-contrived reasons of when one would need to use an object with both a `private` copy constructor and a `private` assignment operator? _As in what problem does this technique/practice solve, that some other technique couldn't solve?_


GPL+FE license also applies to fonts used for the UI of a software?

The GPL font exception allows the font to be embedded within a digital "document" file without requiring the "document" itself to also be shared with GPL. Now I wonder, what is considered a "document"? If the GPL+FE font is embedded in a software to render a user interface, the software can be released with a non-GPL license?


Good architecture for passing data to multiple APIs

* I have a hypothetical scenario where I need to pass data to APIs from multiple different providers, depending on the 'vendor identity' provided by one of the pieces of data.   * If I have the data as objects within an enumerable parent object, what would be a good way to pass the objects to the appropriate API in a reasonably loosely coupled way?   * Even if the API definition was more tightly hardcoded somehow, what would be a good way to actually pass the objects through to the API?   * I'm writing the solution in C# although it's the general architecture that matters not the specific implementation


What steps can I take to ensure that I successfully integrate new functionality to an existing app?

I may potentially have some work to implement new features to a client's existing web application. (I didn't write the original app). I've never made an app that wasn't written from scratch, and I'm worried about integrating the new features without disrupting the service for too long (or at all). I don't think the client has an existing code repository set up. I was thinking that my development process should take the following path:   * Create an SVN repository and store all the current code in there, including (or making them if needed) SQL files that would be needed to create the current database structure.   * Get the client's app functioning as it is on a test server with mock-data in the test-server's database.   * Work as far as possible in cycles to write the code for one feature at a time and then migrate this across to the live app. _This is the bit that I'm most unsure about. There will be a short period of time when I'll be uploading some new files and users will most likely experience usability problems (crashes). Should I just display a "working on the server" page while I'm doing this? How would I do that?_   * Also, it seems to me that adding one feature at a time may cause problems, because some of them expect other features to be there to work properly. I suppose the answer to this is to only add a collection of features that can exsit as a stand alone module.   * Obviously I'd be testing the new code to the max before I migrated it across. I'd be grateful for any pointers or gotchas, or comments on what I've written above. I really want this to run smoothly for my client (and for me!) Cheers


Good, simple reasons for having multiple environments

Throughout my career I had worked at companies that had a collection of different environments for different purposes. We always had more or less our desktop environment, a test environment, a QA environment, a staging environment and a production environment. This went for both servers/applications and any data sources we were using. When I started at my current company I found that 90% of the apps were either developed on a desktop environment against production data sources or developed directly on the production server depending on the platform. This wasn't particularly surprising, as I was hired in part to make changes to improve the way the development team functioned, which was clear from my interview process. We slowly started to turn the philosophy and pretty soon, most of the apps could be run in either a desktop, test or production environment. Not too long after that staging came around as well. Now most of our developers see the benefit of this methodology and defend it vigilantly. However, we have a number of legacy apps that never got migrated. We also have a number of legacy programmers who think of this as a waste of time. Unfortunately, we got lip service but never full buy-in from management. We got what we thought was a commitment to invest substantially in this about a year ago, but nothing materialized despite the considerable planning that we put into it. Now we are finding that we need more and more environments. We need help from the server/network administration teams for setup and we need participation from the business stakeholders to support the release cycle. We are at a place now where a project can function what reasonable developers would consider "normally" only if you have the right people on the project and the time to set up the proper environments. I'd love to present a complete argument, but management really has no time and interest in hearing me out until there is a critical issue. I can't really articulate the benefits simply as it always just seemed second nature to me. I was wondering if there are any **good, simple, irrefutable reasons for the separation of environments that would get managers lacking development experience to support this idea**. Are there any good resources/literature on the topic?


What are the things necessary to become good technical architect

I was just curious to know about how to become a good technical architect Or what are the things makes a Developer good architect. Please share your insights and articles.


About protection for important actions on the server

We developing a web service. And need our important actions (i.e. money transfer) to be protected from accidental calling. In frontend we asking user to confirm such actions. Ok. But how to prevent accidental calling in case of developer mistake? Is it good idea, that action require some confirmation token from developer to proceed?


Design questions for a Node.JS based Dashboard

I checked with meta and apparently this is the best place to ask! The company I work at have many environments, and as such, many Nagios/Icinga etc boxes in each environment. We currently have a dashboard, but it was created quickly many moons ago and needs replacing. It currently scrapes the HTML of every box, builds a static HTML file and repeats. I put together a proof of concept using PHP/MySQL (as I'm good at it) which has a page which is dynamically generated from a MySQL DB, and then there's a background script which fetches data from Nagios/Icinga API's (or resorts to scraping where no API present). This works fine, but I've been itching to learn Node.JS and from what I've read it's good for dashboards - especially as I may want interaction in future. So, my question is where abouts in this does Node.JS site, and where abouts does it not sit? For example, should I be using Node.JS for the dashboard itself sat on something like MongoDB (never used it, but would like to try NoSQL for once) to show people the current problems etc and then I have a script in the background in PHP/Perl that does the fetching scraping? Or (option 2) does Node do the dashboard AND the fetching of data? Do I have two instances of Node? I'd also like to have a web-based config page (like an admin settings page) rather than flat file settings - again, is this something easily done in the same Node structure or is Node quite single purpose (just display a dashboard, just fetch, just do forms etc) I could accomplish all of the above with PHP/MySQL fairly easily and quickly, but Node.JS and MongoDB seem really popular nowadays and I feel like I'm missing out.


Documentation required for commissioned software (product)

The company I work for has commissioned a software company to produce a compliance software for several big companies. As part of our contract it is required of them to provide us with src code and documentation in case in the future we want to take over and further develop the project in house or have another company take over. What are the best practices for software documentation in this case? I.e. What shall I ask of them to provide us for if a 3rd company in the future were to take over? Right now they just provided us the src code and a auto-generated class document (not even class diagram, just a list of all classes, parameters etc). I hope someone can point me in the right direction so that I can produce a small document with what our requirements are.


Is it considered bad practice to make a DAO call in an object's constructor?

I am trying to figure out the best design for instantiating an object which requires two separate calls to the data layer through a DAO. The object is not usable until these calls have been made (because it requires the data retrieved from the database). I have come up with three possible solutions:   1. Create a method in the DAO itself that gets the necessary data from the database, and then pass the data to the object's constructor. The object is passed back as the return value.   2. Create a method in the class that is using the object. This method would make both calls to public methods in the DAO, then instantiate and return the object as in step 1.   3. Pass the DAO as a parameter to the constructor of the object. The constructor would then make both necessary calls to the DAO, setting its own member variables without the need for Setters. The DAO is not used other than in the constructor. Examples, if SomeObject is the object I want to create, and Foo is the class that will make use of it: 1 - DAO Contains the logic:               public SomeObject getSomeObject(){ // this DAO method called by Foo class          data1 = getData1();          data2 = getData2();          return new SomeObject(data1,data2);     }      2 - Class that uses object contains the logic:               public class Foo {         ...              public void useSomeObject() {                   SomeObject obj = createSomeObject();                   obj.doStuff();              }                   private SomeObject createSomeObject() {                   data1 = dao.getData1();                   data2 = dao.getData2();                   SomeObject someObject = new SomeObject(data1,data2);                   return someObject;              }      }      3 - SomeObject takes DAO as parameter and uses it in constructor:               public class SomeObject {     ...           public SomeObject(DAO dao) {                data1 = dao.getData1();                data2 = dao.getData2();           }     ...      }      Hopefully these examples are sufficient to convey my point. Are any of these solution considered better design than the others? If not, what solution is considered best practice? Thanks.


Is VB.Net deprecated by Microsoft?

I have come to this web page from Sony: http://www.sonycreativesoftware.com/scripting_in_vegas_pro_and_sound_forge > We suggest you use C# for your scripts, since although you can currently > write scripts in Jscript and Visual Basic.NET, those two languages have been > deprecated by Microsoft, meaning they may cease to be supported at some > point in the future. AFAIK VB.Net is pretty healthy, and I have been unable to find any other source for that claim. FWIW, the page seems to be pretty old (screenshots have a 2008 date in their names). Can anyone shed some light on this?


Agile retesting

I wrote some code about two years ago, which was deployed to the production environment. The code deletes information that is six years old from a system. When it was first deployed there were only 300 records deleted (because only 300 were six years old). Now there are now 10,000 - 10,000 records become six years old tomorrow. I want to retest the code but the project manager is against this (because it takes time - one day). The deletion routine is very complex (the six year rule is only one of the rules but is the main rule). The system has evolved over the last two years. Is it reasonable to set some time for retesting or should I assume that is it worked at the time then it will work now (as the project manager assumes)? Is there an Agile process that describes this sort of testing?


Strategy with using SVN to switch between test and production server. (with maintaining configuration files)

I would like to know your opinion about my setup right now, how I do things with SVN and if you could find some better solution for me. I'd appreciate it very much if someone could come up with some better solutions for my problems. I would like to do it the best way possible and the most efficiently. My situation is as follows: I'm maintaining a PHP website which is connected to mysql database. I have a subdomain on which I'm testing everything. There are also two databases: first for testing purposes, second for the production server. I have a project in Netbeans and I'm connected to ftp with it so every change I make is directly transferred to the website. Also I'm connected to SVN server and the testing part of the website is in trunk directory. Every time I want to upload the changes to the server I'm commiting my trunk and then I'm copying it to tags. After that I got another project in Netbeans prepared, already connected to the same SVN, but to the last tag copy. After I copy the trunk to tag directory, I switch to the second project and switch to the newest version in tags. Now I have in some another directory every configuration file prepared in proper directory structure - I copy it to my production project. After that I click "Run" in Netbeans and that opens a window which allows me to accept the transfers to the sftp, but this time to the production part of the website. My question is: is it the best way? Aren't there any more intuitive tools or options in SVN, so I don't have to copy the configuration files every time?


Is PGM (Pragmatic General Multicast) viable to achieve reliable message delivery with IP multicast?

I have a server application that distributes stock quotes to a number of clients on our internal network. As the number of clients has grown, unicast (TCP) connections between the server and the clients do not scale anymore. Hence, I have been looking into multicasts. Because of the inherent unreliability of IP multicast, I have been looking into reliable multicast and found Pragmatic General Multicast (PGM). Things like NAK suppression, forward error correction etc. sound like just the things I need and would have to implement myself when using raw UDP. Before I convert a mission critical application to this protocol, there are a couple of questions:   * **How widely used is PGM?** There aren’t many hits for it on Stack Overflow, Server Fault or the new Network Engineering Stack Exchange site. The RFC is from 2001 and a paper on the Microsoft Research site is from 2003. Why hasn’t this been adopted as a standard already?   * **How viable is the Microsoft implementation of PGM?** The documentation is extremely sparse and most projects using PGM (e.g. zeroMQ) seem to be built on top of OpenPGM. But using a socket API that comes with the operating system and that I am already familiar and that has good support in Delphi and C# (the languages I use) seems better than having to rely on additional libraries that need to be built separately and have their own dependencies. Are there any drawbacks of MS-PGM that I should be aware of?   * **What are the alternatives?** Are there other protocols that bring reliability to multicast programming, but e.g. allow for reordering of packets? That wouldn’t be a problem but actually a feature, because it would allow me to continue processing some instruments even when packets for others have been lost.


Reducing dependency cycles and reducing coupling

I'm trying to learn how to produce quality object-oriented code and have been studying concepts like SOLID. I'm currently working on an entity-component- process system for a small game engine. Currently, I have it implemented as such:   * There is a `ScreenStack` which contains a stack of `Screen`s   * Each `Screen` has an `EntityManager` and `ProcessManager`.   * The `ProcessManager` updates all `Process`es given entities from the `EntityManager`.    * A `Process` handles all game logic, so it needs to be able to use `ScreenStack` to possibly push and pop screens. It can also create, remove, and change entities, so it needs the `EntityManager` from `Screen`. Basically a `Process` needs to know everything about the game since it affects so much of it, but it feels wrong. How do I go about implementing this better? It seems like everything has a clear dependency hierarchy until you get to a process, where it gets thrown out the window. There also seems to be tight coupling when I would want to push a new screen. Say, for example, I have a process in a `MainMenu` screen that checks for menu choice. If "New Game" is clicked, I need to push a new screen, which gets created at that moment. I've read that I shouldn't randomly throw in `new` which this seems to be doing.


Will a MQ topic persist messages when one of the consumers is down

If I have a websphere MQ topic and 3 listeners have subscribed to the Topic. One listener is down when a message comes in the Topic. Other listeners consume the message. When the listener comes back up, will the message still be there? My gut feel is no, but i cannot say for sure.


How do you set and check a single bit in a programming language that does not support bitwise operations?

I'm using a programming language (more a scripting language) that does not support any bitwise operators like AND, OR, XOR, NOT (and shift as well). Common arithmetic and logical operations like + - * / % > >= < <= == !=, logical AND, OR, NOT and control flow (while, for, if,...) are supported however. It is like a "subset of C", but without these binary operators. My question does not target that particular language anyway. I was wondering if there is any (mathematical ?) way to set and check a bit at a specific position in a programming language that does not support bitwise operations :               a = 0;               //00000000b     a = togglebit(a, 5); //00100000b     a = togglebit(a, 2); //00100100b               a = 0xFE;            //11111110b     bool result = checkbit(a, 4); //true      For example, there is a way to perform a left or right binary shift using integer multiplication or division :               a = a * 2; //similar to left  shift : a = a << 1;     a = a / 2; //similar to right shift : a = a >> 1;      I'm looking for something similar but for setting or checking a flag.


What simple techniques do you use to improve performance?

I'm talking about the way we write simple routines in order to improve performance without making your code harder to read... for instance, this is the typical for we learned:               for(int i = 0; i < collection.length(); i++ ){        // stuff here     }      But, I usually do this when a `foreach` is not applicable:               for(int i = 0, j = collection.length(); i < j; i++ ){        // stuff here     }      I think this is a better approach since it will call the `length` method once only... my girlfriend says it's cryptic though. Is there any other simple trick you use on your own developments?


Global variable in a Linux shared library

Suppose we have the following setup under Linux, .so library named "libcnt.so" and 3 user space apps: "app1", "app2", "app3". This library does 1 simple thing, it says to the app (app dynamically links the library at runtime) by how many apps it is already linked. Apps should have access to link counter. My knowledge in C and Linux is somewhat limited in this aspect, but as I understand this information should be stored in a global variable inside the shared object. Something like: in libcnt.h extern int cnt_loads; in libcnt.c int cnt_loads = 0; // where each linking increments this counter or something... So, my question is how it should be declared and/or defined inside .so library to guaranty that multiple apps from user space get the same instance of that variable counter?


Licencing GNU GPlv3 - sofware provides a service - not distributed

I have a couple questions with regard to the GNU GPLv3 license. My application is closed-source and I do not intend to actually release it to the public. However, it does _generate_ commercial items. The use of dlls licensed under the above license are used and _linked_ to the software that generates these commercial products. I would just like clarification, that because the software is not actually being distributed - only what the software generates. Therefore, no release of source etc would be required. The licensed dlls are not modified in any way. Secondly, out of interest. When a GNU GPLv3 is used by commercial software (let's say this software is released). This time the licensed material is a EXE and not a .DLL and therefore not actually _linked_ to the code of the software. Rather the software is executing the licensed software directly and sending it command line style arguments and using what the exe returns. Would the source code have to be released? Thanks, I am new to the realms of these licenses and slightly confused.


Is Pure Fabrication (GRASP) only about 'behaviour' , is it the 'representational gap', or is it about actual 'reality'?

Does Pure Fabrication refer to the increased representational gap only in terms of behavioural responsibilities i.e. the software classes added to the domain model to handle ONLY behaviour, or does it include any software class which represent something which does not exist in the domain model? If it is the second option, does this mean that all Pure Fabrications together actually ARE the representational gap? Or does Pure fabrication refer to any class which represent something which does not exist in the real world? Which would mean that the separation of Pure Fabrications and other classes becomes a very scientific distinction. The trigger of this question was the text below in case some background information might help to understand my confusion. > Pure Fabrication: Problem: what object should have the responsibility, when > you do not want to violate High Cohesion and Low Coupling or other goals, > but solutions offered by Expert (for example) are not appropriate? There are > many situations in which assigning responsibilities only to domain layer > software classes leads to problems in terms of poor cohesion or coupling, or > low reuse potential. > > Solution: Assign a highly cohesive set of responsibilities to an artificial > or convenience class that does not represent a problem domain concept. > ...something made up, to support high cohesion, low coupling and reuse. Such > a class is fabrication of the imagination. E.g. a database handler. This > object will be a front-end façade on to a large number of back-end helper > objects. (persistentStorage is not a domain concept, but something made up > or fabricated for the convenience of the software developer.) > > The design of objects can be broadly divided into two groups: > >   1. Those chosen by representational decomposition. (supports the goal of > low representational gap) > >   2. Those chosen by behavioural decomposition (convenience class conceived > by the developer to group together some related behaviour or methods. > > > > (Applying UML and Patterns, Addison Wesley Professional, 2004)


Is it possible to write application-level logic in an XML or plain text format?

For example, a system where the developer does not need to write source code any more, instead they can using XML or some defined text to construct the application-level logic.


How do I encrypt the source code on the webserver?

I have a web application developed using Python, HTML, CSS & JavaScript. The customer installs it in any of their own Machine and uses it through their LAN. In short the customer sets up the webserver in any of their own machine. Since its a web application, all the source code is open for the customer in the document root directory of webserver. I want to encrypt the whole source code in the document root directory in such a way that it should not effect the working of the web application. Is there is any way to encrypt the Python, HTML, CSS & JavaScript for this purpose.


DevOps versus Software Engineers

I am aware that all the DevOps definitions are fairly vague, and this question is subjective, but it's still something I couldn't find an answer to. Is there any difference, prestige-wise, between DevOps and Software Engineers? Is the experience interchangeable? Are N years of DevOps experience interchangeable for N years of software engineering experience? Or do I even view the question in the wrong light?


Release Management versions control?

We recently experienced a deployment issue where it turned out that the version objects were not in sync in one of the environments. We have a large database group and different teams have different responsibilities and ownerships - I might code on schema X, Y, Z but I also will have dependancies on objects owned by other groups. This is the same no matter what technology - java libraries having different versions and what not. My aim is to have _something_ be in a webpage or a database table or something that I can see that for object A I have version X installed in Production, X + 1 in UAT and QA, and X + 2 installed in DEV. How do other folks handle this? How do you pick up version changes? Do you rely on SCM? Build numbers? Hash value of the source code? I'm interested in managing version consistency across technologies - java to db for instance.


How would you approach errors notification?

Recently we had a discussion with my colleagues caused by my intentional attempt to generate user friendly message about occurred error (business logic) at the server side. They insisted on putting all string localizable resources inside web client assembly and not server one. The argument is to let client decide how to generate and present messages to the user. I can't but agree with the requirement of such flexibility for public services, however we develop intranet back-office system and we develop client part as well (both thin and thick client). Frankly speaking the code I've seen so far does nothing more as generating the message (identical to the code I tried to put in BL). There is no particular controls highlighting, accurately positioned popups or something like that. But now the logic is duplicated: web client + win client. My point is that It's better to adhere to DRY and YAGNI principles. Copy paste is evil. The second argument is encapsulation. If error occurred inside Business Logic then it's BL who knows how to describe the error and what additional information should be collected and presented to the user without compromising security or revealing implementation details to the client part. For example, in case of concurrent changes we return `ConcurrenAccessError` from the server and client then converts this to "bla bla bla, object was changed by someone else, edit once again, please." Now, to add user name and timestamp of the changes I need to extend `ConcurrentAccessError` class with additional properties and change code of message generation in two places. I would ask whether client should even know about concurrency as a special error type if it does nothing about it besides user notification. System is not designed for conflict resolving via merge. I believe that high granularity of errors is important only when such structured information allows system somehow help user to make corrections. (Highlighted and focused email input field is better than just a message below the form) Well, eventually I did not manage to persuade my colleagues. I had to follow the conventions. Yet I need more pro and contra arguments to continue the discussion or agree with them. I'd like to know which strategies of error notification you usually use and why. Where do you put the logic of constructing the message?


Is your company thinking of transitioning from java to another technology?

As every Java developer knows, Oracle bought Sun and the future of java looks quite unclear, specially since Oracle wants to monetize the JVM. Java as a language has also been stale in the last few years, the non-inclusion of closures is one example (which might be included in java 1.8) At the same time, some new technologies such as Ruby, Scala and Groovy are being used to deliver complex sites. I'm wondering if there are companies or organizations which are talking, doing spikes or starting to use a different technology, with the idea to stop using java for green field projects, in the same way that 15 years ago companies migrated form C++, perl and other technologies to Java. I'm also interested to know what are the impressions of this happening, for example: planning to migrate to a different technology in 2 years. To be clear, I'm not asking which technology is better. I'm asking if your organization is thinking to leave Java for another technology.