How to Avoid a Busy Loop Inside a Function That Returns the Object That's Being Waited For

I have a function which has the same interface as Python's `input` builtin, but it works in a client-server environment. When it's called, the function, which runs in the server, sends a message to the client, asking it to get some input from the user. The user enters some stuff, or dismisses the prompt, and the result is passed back to the server, which passes it to the function. The function then returns the result. The function must work like Python's `input` [that's the spec], so it must block until it has the result. This is all working, but it uses a busy loop, which, in practice, could easily be spinning for many minutes. Currently, the function tells the client to get the input, passing an id. The client returns the result with the id. The server puts the result in a dictionary, with the id as the key. The function basically waits for that key to exist.               def input():              '''simplified example'''              key = unique_key()         tell_client_to_get_input(key)         while key not in dictionary: pass         return dictionary.pop(pin)      Using a callback would be the normal way to go, but the `input` function must block until the result is available, so I can't see how that could work. The spec can't change, as Python will be using the new `input` function for stuff like `help` and `pdb`, which provide their own little REPLs. I have a lot of flexibility in terms of how everything works overall, but just can't budge on the function acting exactly like Python's. Is there any way to return the result as soon as it's available, without the busy loop?


How PHP manages memory in this case?

I have a **very** basic question, so sorry if this is not the place for it. If I have a file "config.php" with some configurations in some variables and in some page I include this file, each time the variables will be loaded again in the memory of the server? I think the answer is yes, but I'm not sure, I don't know to much of the PHP lifecycle. I don't know if I made myself clear, so here is an example. Suppose, I have the config.php file as:               <?php          $databaseConfig = array();          /* Sets the configurations inside the array */     ?>      Then my index.php page includes the file config.php. Each time the index is loaded the $databaseConfig array will be loaded into memory or just the first time and so when the page is requested again it doens't need to load it again? I really think that since PHP is stateless it will load again each time. Thanks very much in advance!


How to match responses from a server with their corresponding requests?

There is a server that responds to requests on a socket. The client has functions to emit requests and functions to handle responses from the server. The problem is that the request sending function and the response handling function are two unrelated functions. Given a server response X, how can I know whether it's a response to request X or some other request Y? I would like to make a construct that would ensure that response X is definitely the answer to request X and also to make a function requestX() that returns response X and not some other response Y. This question is mostly about the general programming approach and not about any specific language construct. Preferably, though, the answer would involve Ruby, TCP sockets, and PHP. My code so far:               require 'socket'          class TheConnection         def initialize(config)             @config = config         end         def send(s)             toConsole("--> #{s}")             @conn.send "#{s}\n", 0          end         def connect()             # Connect to the server             begin                 @conn = TCPSocket.open(@config['server'], @config['port'])             rescue Interrupt             rescue Exception => detail                 toConsole('Exception: ' + detail.message())                 print detail.backtrace.join('\n')                 retry             end         end         def getSpecificAnswer(input)             send "GET #{input}"         end         def handle_server_input(s)             case s.strip                 when /^Hello. (.*)$/i                     toConsole "[ Server says hello ]"                     send "Hello to you too! #{$1}"                               else                     toConsole(s)             end         end         def main_loop()             while true                 ready = select([@conn, $stdin], nil, nil, nil)                 next if !ready                 for s in ready[0]                     if s == $stdin then                         return if $stdin.eof                         s = $stdin.gets                         send s                     elsif s == @conn then                         return if @conn.eof                         s = @conn.gets                         handle_server_input(s)                     end                 end             end         end         def toConsole(msg)             t = Time.new             puts t.strftime("[%H:%M:%S]") + ' ' + msg         end     end     @config = Hash[         'server'=>'test.server.com',         'port'=>'2020'     ]     $conn = TheConnection.new(@config)     $conn.connect()     $conn.getSpecificAnswer('itemsX')          begin         $conn.main_loop()     rescue Interrupt     rescue Exception => detail         $conn.toConsole('Exception: ' + detail.message())         print detail.backtrace.join('\n')         retry     end


Relative Scoring system - How to solve this?

I am trying to assign scores to phone's specifications to calculate a final rating score for each phone. However, when I was scoring based on megapixels, I found that one of the phones 'A' has a 41MP camera. But all other phones have 8MP or less, which is pretty good for a phone. Right now, when I grade relatively wrt phone A (rating 5/5), all other phones get a score of 1 or 2 out of 5. I would like it to be a little more fair, as it was just one phone with a very high value. Could you suggest me the best way to go about solving this issue where the relative grading is more fair?


How to deal with huge changes to a data specification?

We have a C program which uses a .h header file to describe the custom-made data structure we use. The data structure must follow the design in the functional specification. There is some diagram to describe the member of the data structures and it would be described a ANS.1 abstract syntax, and then the asn file would be compiled to a .h header file. In order to enhance our system, a request to change the functional specification was approved and a new specification was made. ( We jump from 2.10 to 2.12 as we had skipped the upgrade of 2.11 ) Comparing 2.10 to 2.12, a lot of new stuff were added and some old stuff were removed. We need to use a new .asn to compile a new .h header file in order to follow the specification. The problem is that, something useful were removed. For example some member of a data structure were removed and we have been using the member for logic in the program. The program can't even compiled with the new header file. The program have been up and running and we would like to avoid any major down time due to this upgrade. P.S. The specification is not only for our company, it is a standard for the file structure of the files sending between companeis within the whole industry. Say, if one declare to use 2.12 spec, and other party will treat the file with 2.12 standard and discard any files which doesn't follow the standard. P.S. Of course there is no option. The decision is made. However I am facing a problem that the c program was written by some other people and have complex logic. The program would be hugely damaged by the change of the header file. And I may have no idea some to restore peace and functionality to it. Any suggestion of how to check with each difference is appreciated.


Is there value in having technical authors in a software team?

During my 5 years in IT as a software developer, I've noticed that developers have a strong distaste towards doing any documentation. The act of taking screenshots and creating documentation seems to be a painful and time consuming experience. In one company I worked for, we had a technical documentation team with two technical authors and they developed all the user guides for our customers. In other companies where I've suggested hiring a technical author, I've been told they are not worth the money, but I'm a little unsure if that rings true. Is it better to have developers stop coding and take half a day to do screenshots and create the various guides or is it worth hiring someone who handles such tasks?


Why does F# have an interactive mode but not C#?

F# comes out of the box with an interactive REPL. C# has nothing of the sort and is in fact kinda difficult to play around without setting up a full project (though LINQpad works and its also possible to do via powershell). Is there something fundamentally different about the languages that allows F# to have the interactive console but makes it difficult to implement it for C#? **Edit** Since many years later people are still coming to this question I should note that now there are many options. You can use powershell (pre- installed on every modern windows machine) to play with the .Net framework. Or you can use LINQpad to prototype arbitrary c# code. Or you can use ScriptCs or you can use an online jsfiddle-type environment like Complify.net or Jsil. Lots of options.


Recommendations for .NET components that handle and improve TIFF files

I am currently looking for a .NET component that fulfills the following requirements.   * TIFF files      * Extracting single pages as images     * Writing the images to new TIFFs   * Support for colored TIFFs/Images   * Improving the TIFF files (deskew is a must, despeckle etc optional)   * Royalty-free deployment on servers   * Fully architecture independent (only one assembly for x64/x86) I have found that Libtiff.Net is capable of handling the tiff files, but the API is still very complex and it cannot improve the files. For improvements, I am trying out AForge.NET(http://www.aforgenet.com/), but its filters require converting the images to specific pixel formats depending on the operation.


Speed difference between VM-based and compiled code

Not so long ago I was told by a senior academic that, these days, VM-based code could run nearly as fast as compiled code, but my own experience is that compiled code runs several orders of time faster. This is based on code attempting to do the same thing (processing a very large XML file) - in the case of the VM-based code (Groovy) I guess my code would complete in about two years (correct) whereas the C/C++ based alternative took about three hours. The algorithms were not quite the same - but that was because using C/C++ allowed me to manipulate the memory at a byte level using pointers. The Groovy code was easier to write as the language was much more expressive, but the price paid was slow execution. I don't claim to be the world's greatest coder so I would willingly accept that my code could have been improved: but what is the general view?


How do I explain to my boss what a 'Virtual Machine' means?

Most probably my boss didn't write a single word on a keyboard in his entire life. He saw computers and he has a cell phone. He is a smart man. **How can I explain to him what a 'virtual machine' is?** (VM as in VMWare + virtual Box, not the VM as in Java, LLVM, .NET) One of the reasons for asking this is that I want to tell him that having a Linux VM to connect to internet with a Windows host is safer than connecting directly to Windows.


Co-worker renamed all of my queries

I don't know if I should be very irritated or what. I single handedly built over 300 queries for a large database, and developed a naming convention so I could find them later. No one else in my office even knows how to build a query, but I came in yesterday to find that all of them had been renamed. I am now having a very hard time finding things, and I am trying to figure out what to do. I spoke with the person responsible, and she just downplayed the whole thing. She said she renamed them so she can find them more easily. Unfortunately, I am the only one who knows how to build, edit, and maintain them, and the only reason she needed to find them was to test the queries. The new naming convention doesn't make sense at all, and I feel like we have taken a backwards step in the development process. What I'm trying to figure out is: 1) Am I overreacting? 2) What is the best way to handle this? I hate to mention this to my boss, but after speaking with my co-worker yesterday, I can already tell she feels like she did nothing wrong.


Order of subject and modifiers in variable names

I'm looking for experiences regarding the ordering of the subject and modifiers in variable names. A simple object `Shape` would have just a subject for the variable name, such as `Area`. A slightly more complex case `Sphere` which has a wall will have an `inner volume` and an `outer volume`, which is where my question comes into play. What's preferred between _Modifier-Subject_ or _Subject-Modifier_? As an example set:               class Containers_Modifier_Subject     {       AreaAdjustmentFactor       WallThickness       Height       Length       Width       AdjustedArea       SurfaceAreaInner       SurfaceAreaOuter       LongWallArea       ShortWallArea       TopArea       InnerVolume       OuterVolume     }          class Containers_Subject_Modifier     {       AreaAdjustmentFactor       WallThickness       Height       Length       Width       AreaAdjusted       AreaInnerSurface       AreaOuterSurface       AreaLongWall       AreaShortWall       AreaTop       VolumeInner       VolumeOuter     }      The trigger for my question comes from an object that is similar to the examples. There were enough variables in the object that only a portion displays in the code ahead / lookup window from the IDE. I want to make sure that any future developer is quickly led to the correct variable that they'll be looking for without having to scroll up and down through the lookup window. In my case, I was looking for the total area, but the area factor and adjusted area values had popped up first. Consistency in naming as a code standard is a given. Which naming approach has been:   * most maintainable?    * more easily understood?    * semantically correct?       * i.e. how well does the variable name match the business object and how well does the variable name flow into conversations about the problem being solved?   * conducive to being used with code lookup functionality like Intellisense or the various Eclipse based constructs?


Should I represent special cases (like errors / exceptions) in UML diagrams?

Let's say you write a program that, when started, reads its configuration file to know which modules to start-up etc. If that configuration file is missing, an error will probably show up. This is an important situation that must always be handled. I read a statistic once which said that about 70 % of the code in a typical program is there to deal with corner cases (like check that file is not missing, catch an Exception, check that I don't divide by 0, check that a person's age is a positive number etc.). I don't believe this (i.e. the 70 % claim) to be very accurate, but then again, a lot of the code that I write contains a lot of `if`s that check for valid parameters and stuff like that. I doubt I'm the only one who does this. So that statistic does have some truth in it. If a big part of a program's code is represented by these checks, then shouldn't these cases be represented in UML diagrams ? (like sequence diagrams etc.). I can't remember if I ever saw such things. Should I include them in my diagrams ? Will that enlighten or disturb/confuse another programmer who looks at those diagrams ? Would the diagrams then become too big because of this ?


What do you need from a client to create a site

I am trying to figure out what a programmers needs from a client to create a website. This is a complicated database driven site. How should the information look? Should I layout the pages in something like photoshop with annotations? Should it all just be written out. Is there a standard way to do this? I need to clearly explain to a programmer what i want my site to do. Help!


Depending on fixed version of a library and ignore its updates

I was talking to a technical boss yesterday. Its about a project in C++ that depends on opencv and he wanted to include a specific opencv version into the svn and keep using this version ignoring any updates which I disagreed with.We had a heated discussion about that. His arguments:   1. Everything has to be delivered into one package and we can't ask the client to install external libraries.   2. We depend on a fixed version so that new updates of opencv won't screw our code.   3. We can't guarantee that within a version update, ex from 3.2.buildx to 3.2.buildy.   4. Buildy the function signatures won't change. My arguments:   1. True everything has to be delivered to the client as one package,but that's what build scripts are for. They download the external libraries and create a bundle.   2. Within updates of the same version 3.2.buildx to 3.2.buildy its impossible that a signature change, unless it is a really crappy framework, which isn't the case with opencv.   3. We deprive ourselves from new updates and features of that library.   4. If there's a bug in the version we took, and even if there's a bug fix later, we won't be able to get that fix.   5. Its simply ineffiecient and anti design to depend on a certain version/build of an external library as it makes our project difficult in the future to adopt to new changes. So I'd like to know what you guys think. Does it really make sense to include a specific version of external library in our svn and keep using it ignoring all updates?


WINAPI beginner guidance question

I'm learning to develop windows applications using WINAPI and plain C.   Now I got a bit confused with all those handles and would like to ask if you guys could teach me some good practices to structure and handle controls and windows. Here's where I get confused: Using the IDs declared in the resources for each object, we can get their handles using GetDlgItem(). Now what if we don't know their parent, which is needed by this function. One example: We have the main window created at launch. Then we register two new window classes and create a window for each new class and we create a message function for each too. Now if inside one of the children windows I create a button and inside the other child window I create a text label. Now when we click the button inside of child window A the label in child window B shall be modified to whatever. The WM_COMMAND for the button is interpreted inside the message loop for child window A. Now what would be the best and more elegant way to access the text label inside the child window B? I am in the process of learning the WINAPI and just want to learn it right from the start instead of producing Hacked code that someday becomes unreadable and to later have to adapt to a new way of programing. * * * Is there really no one able to give me some advice?


Testing controller logic that uses ISession directly

I have just read this blog post from Jimmy Bogard and was drawn to this comment. > Where this falls down is when a component doesn’t support a given > layering/architecture. But even with NHibernate, I just use the ISession > directly in the controller action these days. Why make things complicated? I then commented on the post and ask this question:- ![my question to jimmy](http://i.stack.imgur.com/BCr01.jpg) My question here is what options would you have testing the controller logic **IF** you do not mock out the NHibernate ISession. I am curious what options we have if we utilise the ISession directly on the controller?


Homework for strong C++ developers learning Java

I'm tasked with teaching an accelerated university special topics course in Java for programmers with many years of experience in C/C++. What sort of medium-length (1-2 hours max) assignments would you give, that would exercise the student's basic Java skills without seeming like an assignment one would give to someone learning Java as a first language? (The idea is to provoke thought about the difference between Java vs. C++ rather than insult the student with ridiculously simple programming in general.) To clarify, the entire course is not 1-2 hours -- it will be 4 hours on the first day and 7 hours on the second and third day, for two weeks, for a total number of contact hours of 36 hours. This is comparable to a standard college course's number of hours, just dramatically compressed.


Collaborative Programming Book Development?

> **Firstly:** If it works for open source projects why not books? **Collaborative writing** is not something new. What is rare however, is this in the field of programming. **The Important Aspects that need your valuable Inputs:**   * **Investment:** Would there be need for investment of any sort, other than _Time_ during the development stages?   * **Existing Platforms:** Are there any existing Platforms that best manage this? Such as online integrated version control, wiki, CMS?   * **Existing Projects:** Where can we find such projects to contribute to? (Assumes there many existing already)   * **Popularity:** Why don’t we see much or any such works? (Referring specifically to the aspect of online collaborative programming book development. It’s a given that in writing any book a lot of effort is involved with many indirect or credited contributors references editors etc.) ( I actually couldn’t find much .WEBOOK doesn’t do programming)   * **Programming Hurdles:** What are the hurdles when speaking about programming aspects that make this hard to achieve?   * **Extension to SE/SO:** Can something like this be added as an extension to SE/SO?The participants of the community already post their valuable answers to questions .Here they would be following more streamlined set of posts keeping with the style/vision.   * **Publicity:** Is it safe to assume SO/SE could best serve as a driving force bringing the correct light, interest of seasoned professionals who can contribute their wealth of knowledge?   * **Marketing:** Other than SO/SE what would be the best way to get publicity and talented people to contribute to this? Would GIT/source forge work as this is basically book writing? > **Lastly:** How do you think such a book would be received? * * * **Points of Interest**   1. **General Hurdles:** A great set of pitfalls, hurdles in general collaborative writing (Besides the technical ones mentioned in the wiki) Not wishing to discuss or mention those here I link directly to the answer.   2. **Trends:** Online Collaborative Writing: How Blogs and Wikis Are Changing the Academic Publishing Process   3. **Success steps:** Keys to a Successful Collaborative Writing Project   4. **Tips:** Useful Tips for Collaborative Writing with Google Docs and Google Sites * * * **My Interest on This:** Recently after my exposure to head first design patterns, I was hard pressed to find a head first type of book for Data structures and Algorithms and I had even looked up their forums (O’Riley) and not much light was given to this topic despite many people asking for this. My only Bad Guess is no one was man (programmer /knowledgeable) enough to write on this in their style (no offence to any one). Which lead me to find this idea of collaborative writing and to my surprise I had found or hadn’t found much in the area of programming. I believe such an Endeavour would only increase the value of a book published as great things can be achieved keeping in line with the imagery, speech, context, delivery method of the original book style from which this was inspired. I have read somewhere that _the true depth of a person’s knowledge lies in how he explains a complex concept in layman’s terms_.


C++ pigeonholing

I'm a EE major who has been working as a software engineer for the past 4 years. Nearly all of the programming that I do at work is in C++. Like a lot of other members here, I'm afraid of being pigeon-holed in a particular area in this industry. I'm thinking about changing jobs to a new area, such as web or mobile. But because I don't have a CS degree OR web/mobile experience, I'm concerned that prospective employers will have a problem with hiring me--especially since I would not be applying for an entry-level job. I read in another thread that C++ developers are seen as a cut above other devs. Is this true, and would it compensate for my lack of experience in the relevant technologies? What should someone in my position do to improve my chances?


Extreme Programming Projects Failures

I searched the web for examples of extreme programming failure but I couldn't find any. I found success stories, but I want to learn about the "other side of the coin". So my question is only about projects that fail using XP. Why do they fail? I just want to hear some opinions about XP failures.


What are some common examples of a Parallelizable problem?

I was just wondering if there were some "standard" examples that everyone uses as a basis for explaining the nature of parallel problems. What are some well- known problems out there that can see great benefits from scalability (and multi-threaded programming)? * **EDIT: also, a little background or explanation as to _why_ it's parallelizable in nature would be of help! Thanks**


Refactor working code for reuse or duplicate?

I have always avoided duplicating code regardless of the circumstance. For example, if I have a working piece of functionality that needs to be re-used by different entities, I always refactor to make this functionality available. Under no circumstance would I duplicate code. I am probably a little rigid when it comes to this but I really do not like duplicating code. I currently had a slight disagreement with our Team Lead who suggested that instead of refactoring, I should copy entire piece of functionality I require into a different class and then we can decide how best to refactor at a later date. This is even after confirming that my previous refactoring efforts did not break any of the unit tests. I further had this conversation today with my previous manager, and his mentor, who both sided with my Team Lead. Their argument is incurring technical debt is OK, and almost always preferable, especially if you are running into time constraints, which I understand. My counter argument was yes, we do not want to skip deadlines but one must always consider the cost of refactoring and this usually should be the first instinct, especially if we are simply moving functionality into a new location that renders it accessible to all. Proper unit test can also ensure that refactoring efforts do not break existing functionality. Also is it not always better to pay off the debt now rather than later? I can only imagine what this task will entail if all members of the team simply duplicated code. Suffices to say that we had to agree to disagree. In his book titled Clean Code, Robert Martins emphasis continuous refactor during development so I was surprised by the response of my previous manager. What are you opinions on this?


How does one read RFCs and similar documents?

RFC: > Request for Comments (RFC) is a memorandum published by the Internet > Engineering Task Force (IETF) describing methods, behaviors, research, or > innovations applicable to the working of the Internet and Internet-connected > systems. At the end of this Intro to REST video, RFC2616 and RFC3986 are mentioned as further reading. After watching the video, I googled those documents and, as the title suggests, I'm not sure how to use them. Do I read them in their entirety and make notes or do I use them more as a reference for when I don't understand something or have a problem?


Why does the regular expression metacharacter \w include underscores?

In most, if not all implementations of regular expressions, the \w metacharacter matches all alphanumeric characters plus the underscore. Historically speaking, why was the underscore character included in this character class? And why not include dashes too?


Instruction vs data cache usage

Say I've got a cache memory where instruction and data have different cache memories ("Harvard architecture"). Which cache, instruction or data, is used most often? I mean "most often" as in time, not amount of data since data memory might be used "more" in terms of amount of data while instruction cache might be used "more often" especially depending on the program. Are there different answers a) in general and b) for a specific program?


Why are background-colors not or rarely used for syntax highlighting?

I wonder why I rarely see any IDEs or other developers that use background colors for syntaxhighlighting. One of the first things when installing and configuring a new IDE is adjusting the colors so that for example comments have a decent light-grey background. This really helps me seeing where documentation is and where code is when scrolling down fast. The only time i saw something like that was in the Greenfoot Editor but that didn't look so well at least if you are doing some more complex work and there are more nested conditions and stuff. So why is it that background colors are rarely used; or does anyone have some good examples where they are used and how?


What's better in terms of user experience - providing an email address or a link to my projects github account?

What's better in terms of user experience? Provide the user an email account where he can report bugs, or a link to the projects github issues page (which requires a github account but may be easier to submit bugs to)? **EDIT** The application is a Bash script hosted on github. The GNU Coding Standards suggests using an email address, which may or may not an appropriate solution. Target audience is the CLI power user.


Where to put code documentation?

I am currently using two systems to write code documentation (am using C++):   * Documentation about methods and class members are added next to the code, using the Doxygen format. On a server Doxygen is run on the sources so the output can be seen in a web browser   * Overview pages (describing a set of classes, the structure of the application, example code, ...) is added to a Wiki I personally think that this approach is easy because the documentation about members and classes is really close to the code, while the overview pages are really easy to edit in the Wiki (and it's also easy to add images, tables, ...). A web browser allows you to see both documentations. My co-worker now suggests to put everything in Doxygen, because we can then create one big help file with everything in it (using either Microsoft's HTML WorkShop or Qt Assistant). My concern is that editing Doxygen-style documentation is much harder (compared to Wiki), especially when you want to add tables, images, ... (or is there a 'preview' tool for Doxygen that doesn't require you to generate the code before you can see the result?) What do big open-source (or closed source) projects use to write their code documentation? Do they also split this up between Doxygen-style and a Wiki? Or do they use another system? What is the most appropriate way to expose the documentation? Via a Web server/browser, or via a big (several 100MB) help file? Which approach do you take when writing code documentation?


Is there a phrase or word to describe an algorithim or program is complete in that given any value for its arguments there is a defined outcome?

Is there a phrase or word to describe an algorithim or programme is complete in that given any value for its arguments there is a defined outcome? i.e. all the ramifications have been considered whatever the context? A simple example would be the below function:               function returns string get_item_type(int type_no)     {       if(type_no < 10)         return "hockey stick"       else if (type_no < 20)         return "bulldozer"       else         return "unknown"     }      (excuse the dismal pseudo code) No matter what number is supplied all possibiblites are catered for. My question is: is there a word to fill the blank here:               "get_item_type() is ______ complete"      ? (The answer is not Turing Complete - that is something quite different - but I annoyingly always think of something as "Turing Complete" when I am thinking of the above).


null values vs "empty" singleton for optional fields

First of all I'm developing a parser for an XML-based format for 3D graphics called XGL. But this question can be applied to any situation when you have fields in your class that are optional i.e. the value of this field can be missing. As I was taking a Scala course on coursera there was an interesting pattern when you create an abstract class with all the methods you need and then create a normal fully functional subclass and an "empty" singleton subclass that always returns `false` for `isEmpty` method and throws exceptions for the other ones. So my question is: is it better to just assign `null` if the optional field's value is missing or make a hierarchy described above and assign it an empty singleton implementation?


What assumptions / disclaimers should be included with a software estimate?

I'm writing a lot of estimates lately and I'm finding that quite often, a client might argue scope, deliverables or (most often) cost. In an effort to ensure that the breadth of coverage (of client requirements and mutually understood scope) for the estimate is clear (and given most clients will view an estimate as a fixed quote from Moses himself), what common assumptions do you include with your estimates such that expectations are clearly set with clients and disagreements around what is being delivered or charged are minimised?


Agile and different facet of software development

It is said that the Kanban methodology is suited for software maintenance and support areas, whereas Scrum is more suited for new product development. No process or methods are complete. Using the right one will help you succeed, but they will not guarantee success. Which agile approach is best suited for a project which is basically a re- platforming from one technology to another (say from Java to .NET).


Modular Architecture for Processing Pipeline

I am trying to design the architecture of a system that I will be implementing in C++, and I was wondering if people could think of a good approach, or critique the approach that I have designed so far. First of all, the general problem is an image processing pipeline. It contains several stages, and the goal is to design a highly modular solution, so that any of the stages can be easily swapped out and replaced with a piece of custom code (so that the user can have a speed increase if s/he knows that a certain stage is constrained in a certain way in his or her problem). The current thinking is something like this:               struct output; /*Contains the output values from the pipeline.*/          class input_routines{         public:         virtual foo stage1(...){...}         virtual bar stage2(...){...}         virtual qux stage3(...){...}         ...     }          output pipeline(input_routines stages);      This would allow people to subclass input_routines and override whichever stage they wanted. That said, I've worked in systems like this before, and I find the subclassing and the default stuff tends to get messy, and can be difficult to use, so I'm not giddy about writing one myself. I was also thinking about a more STLish approach, where the different stages (there are 6 or 7) would be defaulted template parameters. Can anyone offer a critique of the pattern above, thoughts on the template approach, or any other architecture that comes to mind?


Symbian Test Questions

So, I was in charge of filtering down job applicants at our company. We wanted to develop symbian app. But, there are no one here that know how to develop it. Therefore, we create job ads. Several applicant coming in. The question is, how do I test this candidate? I'm thinking to give some sort of test app. Something trivial and simple but required to have fundamental understanding of symbian. This will **be build at home** question. If they are able to create it Any recommended test question / application?


Struggling with the Single Responsibility Principle

Consider this example: I have a website. It allows users to make posts (can be anything) and add tags that describe the post. In the code, I have two classes that represent the post and tags. Lets call these classes `Post` and `Tag`. `Post` takes care of creating posts, deleting posts, updating posts, etc. `Tag` takes care of creating tags, deleting tags, updating tags, etc. There is one operation that is missing. The linking of tags to posts. I am struggling with who should do this operation. It could fit equally well in either class. On one hand, the `Post` class could have a function that takes a `Tag` as a parameter, and then stores it in a list of tags. On the other hand, the `Tag` class could have a function that takes a `Post` as a parameter and links the `Tag` to the `Post`. The above is just an example of my problem. I am actually running into this with multiple classes that are all similar. It could fit equally well in both. Short of actually putting the functionality in both classes, what conventions or design styles exist to help me solve this problem. I am assuming there has to be something short of just picking one? Maybe putting it in both classes is the correct answer?


Is Linux a neccessity for learning network?

I'm a web developer interested in learning network. I work on Windows platform. Many of my friends and colleagures believe that to learn netwrok, I should become familiar with Linux platform. Should I? I mean, can't I learn network and it's concepts thoroughly on Windows Server platform?


How should I license code written for a startup without a contract?

I wrote a fair amount of code for a startup, but I haven't signed a contract before doing so. The only document that I signed with them does not mention the fact that I have to pass the rights on the code to them, and after a consulting with a lawyer it seems that I own the full rights. Now I want to preemptively correct this situation by giving them some sort of exclusive license. Is there an existing license for closed-source, exclusive use that is used in these cases or I simply write somewhere "I grant exclusive license to use and modify this piece of code to FooBar-inc at the followings conditions: bla bla bla signed me, them"?


When is an application too customizable?

Say you are developing a desktop application, and you want the user to be able to customize menus, buttons, keymapping, and other commands and components. How much customization should be allowed? I like my environments to be pretty much infinately customizable. I also want the environment to have a good set of defaults so I can just tweak the settings I need rather than having to set up the whole thing. Does anyone have any user experience to point to to support or contradict my preference?


Recently in an interview, one of the questions was 'Why do we use MVC?’ I just answered that it is much closer to how, many of the real world systems are! Explained the benefits it has when it comes to Maintainability, Scalability etc. But they were not convinced and finally told me that MVC is used mainly as it 'enables easy Unit Testing'. While I know theirs is a valid point, I still doubt if it is the major reason because (i) even if I decide not to write Unit Testcases, MVC is a probable choice (ii) Many GUI systems where Unit Testcases are there does not follow MVC. So the question is 'Is Unit Testing the primary objective of MVC Pattern?' **EDIT:** I assume that they might be mentioning ease of Test Driven Development/writing NUnit Testcases. This is because we canwrite testcases for the Model (Provided the View is exactly reflecting Model's state changes)-please correct me if I am wrong.


Infamous failure due to the lack of release process?

With my fellow engineers we are putting in place a release process in a team that formerly was made only of biologists. I am going to make a presentation to explain the process to them and explain what advantages it brings. I am looking for one example of a project that failed or got into real trouble due to the lack of release process. Are you aware of any ?


Minimizing Average Pairwise Squared Euclidean Norm

I'm pretty new to programming and computer science, but I was wondering if there was any good way to approach the following problem: For a set of 2n points (not necessarily unique) in R^k (assume each entry is positive), I want an algorithm which will partition the set into n pairs such that the average Euclidean distance squared is minimized. EDIT: Edited for clarity.


Proper Query Object Pattern - NHibernate

I was looking to an alternative to Repository Pattern and I've read about "Query object pattern" (http://lostechies.com/jimmybogard/2012/10/08/favor- query-objects-over-repositories/). However the implementation provided in the link above is not exactly what I was looking for - I look for something that can be easily injected, easily tested and easily extended/changed (only last point holds in the link-implementation). I thought a bit and I think "I have invented" solution. Suppose I have controller `BlogEntriesController` (i'm talking about `mvc asp` application with ORM) and I inject to constructor class:               public class BlogEntriesQueries     {         IRetrieveQuery<BlogEntryEntity> PageBlogEntries { get; set; }         IRetrieveQuery<BlogEntryEntity> ProposedBlogEntries { get; set; }         IAddQuery<BlogEntryEntity> CreateNewBlogEntry { get; set; }         ... etc..     }      where `IRetrieveQuery<T>` is smth like:               public interface IRetrieveQuery<TEntity> where TEntity : EntityBase          IQueryable<TEntity> CurrentQuery { get; }          IRetrieveQuery<TEntity> InvokeQuery(IRetrieveQuery<TEntity> subQuery);          IEnumerable<TEntity> GetQueryResults();     }      Then all the work I'd have to do is proper configuration of IoC container to inject queries into controller and proper calls in controller like: `_blogQueries.ProposedBlogEntries.GetQueryResults()` The question is - it is good solution - are there any drawbacks that I don't see? I think i'd get testability (don't even have to mock `ISession` in case of `NHibernate`) and it'd be easily extensible but I'm not an expert (especially at database applications) by any means.


On restricting commercial use for Mathematica / Matlab projects while requiring attribution

I want to share the code of a research project, for academic purposes, in Bitbucket and Matlab's FileExchange. The code is in both Matlab and Mathematica, and I want to restrict its use for commercial purposes. I don't know if I can use Affero GPL for this, as both Matlab and Mathematica are commercial software. This is the most direct response from the terms of GPLv3 that I've found: > **If a programming language interpreter has a license that is incompatible > with the GPL, can I run GPL-covered programs on it?** (#InterpreterIncompat) > > When the interpreter just interprets a language, the answer is yes. The > interpreted program, to the interpreter, is just data; the GPL doesn't > restrict what tools you process the program with. > > However, when the interpreter is extended to provide “bindings” to other > facilities (often, but not necessarily, libraries), the interpreted program > is effectively linked to the facilities it uses through these bindings. The > JNI or Java Native Interface is an example of such a facility; libraries > that are accessed in this way are linked dynamically with the Java programs > that call them. > > So if these facilities are released under a GPL-incompatible license, the > situation is like linking in any other way with a GPL-incompatible library. > Which implies that: > >   1. If you are writing code and releasing it under the GPL, you can state > an explicit exception giving permission to link it with those GPL- > incompatible facilities. > >   2. If you wrote and released the program under the GPL, and you designed > it specifically to work with those facilities, people can take that as an > implicit exception permitting them to link it with those facilities. But if > that is what you intend, it is better to say so explicitly. > >   3. You can't take someone else's GPL-covered code and use it that way, or > add such exceptions to it. Only the copyright holders of that code can add > the exception... > > What license is compatible with these requirements in Matlab / Mathematica?   * Allowing academic usage    * Requiring attribution for academic usage   * Restricting commercial usage (the program's output -processed images- should not be sold)


Tournament bracket method to put distance between teammates

I am using a proper binary tree to simulate a tournament bracket. It's preferred any competitors in the bracket that are teammates don't meet each other until the later rounds. What is an efficient method in which I can ensure that teammates in the bracket have as much distance as possible from each other? Are there any other data structures besides a tree that would be better for this purpose? EDIT: There can be more than 2 teams represented in a bracket and there is no requirement to have an equal number of people from each team in a bracket. I intend to use this for individual sports where a person still has an affiliation with a team and we want to delay teammates facing each other until as late as possible.


Pulling results from postgresql with cursors

I'm writing an application in C++ using libpq as the interface to postgresql. I'm currently putting together a small library of helper functions to help deal with the conversion from C++ to C for an application to be used on either a PC or an ARM device (2GHz 2GB ram). With regards to pulling data from the database, I'm concerned as to whether I should pull all the results from the database at once, or use a cursor to read one or a few at a time. The returned result set could probably be in the hundreds and I'm assuming:   * if I pull all results, it'll be a memory hit for the application   * if I pull one tuple at a time via a cursor, it could be a heavy burden on the database server (currently localhost for development) I don't understand how I could obtain some suitable metrics to determine which would be best, so my questions are:   1. Is there a best practice when it comes to retrieving results from the database in the real world (all at once / a row at a time / a few rows at a time)   2. How would I determine some form of metrics to test efficiency? I'm guessing I'd have to take both application memory usage and database load into account along with response time.   3. If it is best to pull a few tuples at a time, how do I determine the optimal amount to pull at once?


Questions about linking libraries in C

I am learning C (still very much a beginner) on Linux using the GCC compiler. I have noticed that some libraries, such as the library used with the `math.h` header, need to be linked in manually when included. I have been linking in the libraries using various flags of the form `-l[library-name]`, such as `-lm` for the above-mentioned math library. However, after switching from the command line and/or `Geany` to `Code::Blocks`, I noticed that `Code::Blocks` uses `g++` to compile the programs instead of the `gcc` that I am used to (even though the project is definitely specified as C). Also, `Code::Blocks` does not require the libraries to be manually linked in when compiling - libraries such as the math library _just work_. I have two questions: Firstly, is it "bad" to compile C programs with the `g++` compiler? So far it seems to work, but after all, C++ is not C and I am quite sure that the `g++` compiler is meant for C++. Secondly, is it the `g++` compiler that is doing the automatic linking of the libraries in `Code::Blocks`?


Why would Square inheriting from Rectangle be problematic if we override the SetWidth and SetHeight methods?

If a Square is a type of Rectangle, than why can't a Square inherit from a Rectangle? Or why is it a bad design? I have heard people say: > If you made Square derive from Rectangle, then a Square should be usable > anywhere you expect a rectangle What is the problem here? And why would Square be usable anywhere you expect a rectangle? It would only be usable if we create the Square object, and if we override the SetWidth and SetHeight methods for Square than why would there be any issue? > If you had SetWidth and SetHeight methods on your Rectangle base class and > if your Rectangle reference pointed to a Square, then SetWidth and SetHeight > don't make sense because setting one would change the other to match it. In > this case Square fails the Liskov Substitution Test with Rectangle and the > abstraction of having Square inherit from Rectangle is a bad one. Can someone explain the above arguments? Again, if we over-ride SetWidth and SetHeight methods in Square, wouldn't it resolve this issue? I have also heard/read: > The real issue is that we are not modeling rectangles, but rather > "reshapable rectangles" i.e., rectangles whose width or height can be > modified after creation (and we still consider it to be the same object). If > we look at the rectangle class in this way, it is clear that a square is not > a "reshapable rectangle", because a square cannot be reshaped and still be a > square (in general). Mathematically, we don't see the problem because > mutability doesn't even make sense in a mathematical context Here I believe "re-sizeable" is the correct term. Rectangles are "re-sizeable" and so are squares. Am I missing something in the above argument? A square can be re-sized like any rectangle.


Database Handler and SQL injection prevention

I've written a `database` model class in PHP and have written a controller class that specifically validates the data before sending it to db. I'm getting criticism that I should handle the data in `database` model class rather than `controller` class. I wanted to write a generic db class which can be used anywhere for CRUD operations. Now can you guys please help me out in sorting this out? Whether I should validate the data in db model class or in db controller class?


Formatting PHP, what works more efficiently?

I was just wondering what makes PHP work faster. I have a few methods that I always go and do, but that only improves the way I can read it, but how about the interpreter? ### Should I include the curly braces when there is only one statement to run?               if(...){         echo "test";     }     # Or..     if(...)         echo "test";     === Which should be used?      ### I have also found http://beta.phpformatter.com/, and I find the following settings to be good, but are they? > ### Indentation: > > Indentation style: `{K&R (One true brace style)}`   >  Indent with: `{Tabs}`   >  Starting indentation: `[1]`   >  Indentation: `[1]` > > ### Common: > > `[x]` Remove all comments   >  `[x]` Remove empty lines   >  `[x]` Align assignments statements nicely   >  `[ ]` Put a comment with the condition after if, while, for, foreach, > declare and catch statements > > ### Improvement: > > `[x]` Remove lines with just a semicolon (;)   >  `[x]` Make normal comments (//) from perl comments (#)   >  `[x]` Make long opening tag (<?php) from short one (<?) > > ### Brackets: > > `[x]` Space inside brackets`- ( )`   >  `[x]` Space inside empty brackets`- ( )`   >  `[x]` Space inside block brackets`- [ ]`   >  `[x]` Space inside empty block brackets`- [ ]` ### Tiny var names: often I go through my code and change `$var1` to `$a`, `$var2` to $b and so on. I do include comments at the start of the file to show to me what each letter(s) mean.. ### Final note: So am I doing the right thing with the curly braces and the settings?   Are there any great tips that help it run faster?


Fitting it together, database, reporting, applications in C#

# Introduction ## Preamble I was hesitant to post this, since it's an application whose intricate details are defined elsewhere, and answers may not be helpful to others. Within the past few weeks (I was actually going to write a blog post about this after I finished) I've discovered that the barrier I'm encountering is one that's actually quite common for newer developers. This question is not so much about a specific thing as it is about piecing those things together. I've searched the internet far and wide, and found many tutorials on how to create applications that are _kind of_ similar to what I'm looking for. I've also looked at hiring another, more experienced, developer to help me along, but all I've gotten are unqualified candidates that don't have the experience necessary and won't take care of the client or project like I will. I'd rather have the project never transpire than to release a solution that is half- baked. I've asked professors at my school, but they've not turned up answers to my question. I'm an experienced developer, and I've written many applications that are -- very abstractly -- close to what I'm doing, but my experiences from those applications aren't giving me enough leverage to solve this particular problem. I just hope that posting this article isn't a mistake for me to write. ## Project Description I have a project I'm working on for a client that is a rewrite of an application, originally written in Foxpro 2.6 by someone before me, that performs some analysis (which, sadly, I'm not allowed to disclose as per of my employment contract) on financial data. One day, after a long talk between the client and I -- where he intimately described his frustrations with all the bugs I've been hacking out of this code for 6 months now -- he told me to just rewrite it and gave me a month to write a good 1/8 of this 65k LOC Foxpro monstrosity. this 65k line of code foxpro monstrosity. It'll take me a good 3 - 6 months to rewrite this software (I know things the original programmer did not, like inheritance) going as I am right now, but I'm quickly discovering that I'm going to need to use databases. Prior to this contract I didn't even know about foxpro, and so I've had to learn foxpro on the fly, write procedures and make modifications to the database. I've actually come to like it, and this project would be rewritten in Foxpro if it were still a supported language, because over the past few months, I've come to like the features of Foxpro that make it so easy to develop data-driven applications. I once perfomed an experiment, comparing C# to Foxpro. What took me 45 minutes in C# took me two in Foxpro, and I knew C# prior to Foxpro. I was hoping to leverage the power of C#, but it intimidates me that in foxpro, you can have one line of code and be using a database. Prior to this, I have never written any _serious_ database development _from scratch_. All the applications that I've written are in a different league. They are either completely data-naive or data-naive enough that I can get away with not using a database through serialization or by designing algorithms that work with the data in a manner that is stateless, so there is no need to worry about databases. I've come to realize, very quickly, that serialization and my efficacy with data structures has been my crutch all these years that's prevented me from adventuring into databases, and has consequently hindered my success in real- world programming. Sure, I've written some database stuff in Perl and Python, and I've done forms and worked with _relational_ databases and tables, I'm a wizard in Access and Excel (seriously) and can do just about anything, but it just feels unnatural writing SQL code in another language... I don't mind writing SQL, and I don't _It's that bridge between the database and the program code that drives me absolutely bonkers._ I hope I'm not the only one to think this, but it bothers me that I have to create statements like the following               string sSql =  "SELECT * from tablename"      When there's really no reason for that kind of unchecked language binding between two languages and two API's. Don't get my wrong, SQL is great, but I don't like the idea that, when executing commands on a SQL database, that one must intermix database and application software, and there's no database independence, which means that different versions of different databases can break code. This isn't very nice. The nicest thing about Foxpro is the cohesiveness between programming language and database. It's so easy, and Foxpro makes it easy, because the tool just fits the task. I can see why so many developers have created a career with this language, because it lowered the barrier of entry to data-driven applications that so many businesses need. It was wonderful. For my purposes today, with the demands and need for community support, extensibility, and language features, Foxpro isn't a solution that I feel would be the right tool for the job. I'm also worried about working too heavy with the database, because I've seen data-driven .NET applications have issues with database caches, running out of memory, and objects in the database not being collected. (Memory leaks) _And OH the queries._ * * * ## Which one, how, and why? There are a plethora of different ways that a database can be setup, I think I counted 5 or 6 different kinds of database applications alone that I can chose from. That is a great mountain for me to climb when I don't even know where to begin when it comes to writing data-driven applications. The problem isn't that I don't know SQL or that I don't know C#. I know both and have worked with both extensively. It's making them work together that's the problem, and it's something I've never done in C# before. ## Reports The client likes paper. The data needs to be printed out in a format that is extensible, layered, and easy to use. I have never done reporting before, and so this is a bit of a problem. From the data source comes crystal reports, and so there's a dependency on the database, from what I understand. ## Code reuse A large part of the design decision that I've gone through so far is to break the task of writing a piece of this software into routines and modular DLL's and so forth such that much of the code can be reused. For example, when I setup this database, I want to be able to reuse the same database code over and over again. I also want to make sure that when the day comes that another developer is here, that he/she will be able to pick up just where I left off. The quicker I develop these applications, the better off I am. ## Tasks & Goals In my project, I need to write routines that apply algorithms and look for predefined patterns in financial data. Additionally, I need to simulate trading based on predefined algorithms and data. Then I need to prepare reports on that data. Additionally, I need to have a way to change the code base for this application quickly and effectively, without hacking together some band-aid solution for a problem that really needs a trauma ward. ## Special Considerations The solution must be fast, run quickly on existing hardware, and not be too much of a pain to maintain and write. I understand that anything I write I'm married to -- I'm responsible for the things that I write because my reputation and livelihood is dependent on it. Do I really need a database? What about performance? Performance was such a big issue that I hand wrote a data structure that is capable of performing 2 billion operations, using a total of 4 gigs of memory in under 1/4 of a second using the standard core two duo processor. I could not find a similar, pre-written data structure in C# to perform this task. What setup do I use in terms of database? What about reporting? I'd prefer to have PDF's generated, but I'd like to be able to visually sketch those reports and then just have a ReportFactory of some sort, that when I pass some variables in, it just does that data. ## About Me I'm a lone developer for a small business in this area. This is the first time I've done this and I've never had the breadth and depth of my knowledge tested. I'm incredibly frustrated with this project because I feel incredibly overwhelmed with the task at hand. I'm looking for that entry level point where I can draw a line and say "this is what I need to do" ##  Conclusion I may have not been clear enough on my post. I'm still new to this whole thing, and I've been doing my best to contribute back to the community that I've leached so much knowledge from. I'd be glad to edit my post and add more information if possible. I'm looking for a big-picture solution or design process that helps me get off the ground in this world of data-driven applications, because I have a feeling that it's going to be concentric to my entire career as a programmer for some time. Specifically, if you didn't get it from the rest of the post (I may not have been clear enough) I really need some guidance as to where to go in terms of the design decisions for this project. Some things that'll be useful will be a pro/con list for the different kinds of database projects available in VS2010. I've tried, but generating that list has been as hard as solving the problem itself... **If you could walk a developer writing a data-driven application for the first time in C#, how would you do that? Where would you point them to?**


Microsoft Platform Ready Test Tool - Select Primary Executable when they are on a different server

I am using the Microsoft Platform Ready Test Tool 4.1 and am trying to run through the SQL Server 2012 Data Platform Test My SQL Server 2012 is running on a Windows 2012 server, and all the prerequisite tests are passing. But then I come to step 1: Select Primary Executable(s) of Your Application, and get the following error Message:               You must identify your application's primary executable(s) in the below list.      If no executable is displayed below, you must browse and add your applications's primary      executable that makes the connection to SQL Server. If your application is IIS/PHP/COM+      based solution, then you must add the corresponding framework executable(s) that makes the connection to SQL Server.          So, my Application is a .Net 4.5 web Application that is running on a different VM from the SQL Server. So my question is then: How can i add the files needed? And which files am I supposed to add anyway?


Is this the correct way to implement .NET MVC website structure?

I have recently seen a .NET MVC solution in which the markup in the `.aspx` views which appear to have a Controller as their model i.e the controller seems to be providing the data for the view, and the `.ascx` user controls they contain use a separate model. I'm new to MVC and I wanted to find out about a few things I'm not clear on. An example of how the code is implemented: `UserDetails.aspx` view has markup that shows it's using the `UserDetailsController.cs` as the model. It contains `RenderPartial("User_Details.ascx", UserDetailsModel)` and passes it the `UserDetailsModel`. Is this the standard/correct way of implementing MVC? Or just one way to implement it? I also noticed that the classes used as Models appear to be Service classes that have `[DataMember]` and `[DataContract]` attributes on the class name and properties - what is the advantage of this implementation?


Learning OO for a C Programmer

I've been programming professionally in C, and only C, for around 10 years in a variety of roles. As would be normal to expect, I understand the idioms of the language fairly well and beyond that also some of the design nuances - which APIs to make public, who calls what, who does what, what is supposed to reentrant and so on. I grew up reading 'Writing Solid Code', it's early C edition, not the one based on C++. However, I've never ever programmed in an OO language. Now, I want to migrate to writing applications for iPhone (maybe android), so want to learn to use Objective-C and use it with a degree of competence fitting a professional programmer. How do I wrap my head around the OO stuff? What would be your smallest reading list suggestion to me. Is there a book that carries some sort of relatively real world example OO design Objective-C? Besides, the reading what source code would you recommend me to go through. How to learn OO paradigm using Objective-C?


Salvaging remains of dead web-application project: What to look for?

I don't know if this question is more on-topic here or on SO, so if I've missed site, I apologize. Anyway I was talking with a relative recently. She is working in a company which needed a website. They contracted another company which does web-apps and graphical design to make them a website, give source code and do maintenance. The site is supposed to give general economic propaganda about the company, to have a news section and to have a portal for associates where they will be able to get statistical information like amount of sales of their products and similar stuff. The last part was supposed to read data from the database used by the All-in-One program used by my relative's company. The project was supposed to last three to six months and use LAMP (or WAMP) AJAX and Python. Unfortunately six months passed almost four times since the start of the project and the only results are couple of mock-up images. Furthermore they seem to be in a mess. They are avoiding contact and are always complaining how developers keep quitting after just couple of months of work and that they can't make a stable project team (on a side-note, they did websites for several other companies on time, so they were capable of producing the result at one time). By now it is clear that the project will not be done any time soon and my relative's company is considering firing the contractors and taking whatever they did make and finding someone else to finish the work. Unfortunately, their IT guy didn't do any programming since PDP-11 era, so he won't be very helpful and it looks like it will be up to me to inspect whatever contractors did. I did some programming, but only a little bit of web programming, so my question is: What should I expect to find in the code-base and resources? The thing is that they I have reasons to suspect that they share code across different projects and may attempt to weasel out parts of it. I know that there will probably be a part with resources used by the site like images and so on and that there will probably be a database and some scripts. Also, if you think that this should be turned into community-wiki or general "Failed Project: How to recover anything useful from it?" discussion, please comment. Also, court is not a solution, because they are so efficient in my country that its decision would probably come in early 2020s.


How can I simplify the following Access Control system design?

I couldn't find a better title for this... I am trying to create an Access Control for my application and I am having serious trouble with building not an insane system, mainly for performance as this system will reside in an SQL database and will be used excessively throughout the app (every query will be using it for fetching data) So here is my scenario and my current design: My system has 3 modules and each has the general CRUD actions - list, view, update, create, delete; and sometimes has more specific actions like - user.view.creator, user.update.photo, user.update.metadata, storage.upload, storage.download etc. I want my system to have "tasks" or "operations" and they will be hierarchical, for example storage.view will have a child storage.download. This is for the operations. This part I have no problem implementing and designing. My biggest problem is designing the connection between a user and the tasks. Both RBAC and ACL doesn't fit my needs in this case, so I am trying to build my own. I cannot implement RBAC because in RBAC the roles are static but in my case the roles themselves are dependent of the resource and the group that this resource belongs to. For example, Group A's role photographer can only upload a photo from the storage, while the Group B's photographer can also delete the photo from the storage. Therefore, to keep things somewhat simple, I decided to add a new resource GROUP and every all the files, roles etc must BELONG to some group. On the other hand, the user just gets mapped to a group; they never BELONG to a group, they just access resources in groups. This makes perfect sense and works seamlessly and is not very complex - the queries are simpler, so I have space to cluster the databases etc. However, now here comes the problem that just doesn't fit in my current design. I have another resource, CLIENT. The problem is, in the one organization, a user can have different access to different clients. So for example, lets say I have Group A, that has Clients 1 to 25. A specific user that belongs to that group, can have something like:               Client 1 - Manager     Client 2 - Assistant     Client 3 - SomeOtherRole      And when he fetches a list of clients, the user will only see 3 clients. I really don't know what I should do to achieve this in the most performant way possible. My question is, how should I proceed with designing this part of my system? And a better question, how can I simplify this system?


What should every programmer know about programming?

Please, **stay on technical issues** , avoid behavior, cultural, career or political issues.


Is it possible to build releases based on tags with a Continuous Integration system (such as Travis CI / Jenkins)

After reading and asking about how to deal with git, Github, branching, versioning and tagging, it looks like the best way to denote a new version of software, is by marking the last commit of a specific version with a specific tag. A structure like this can be assumed:   * Commit 1   * Commit 2: Tag 1.0.0   * Commit 3   * Commit 4   * Commit 5: Tag 1.1.0   * Commit 6: Tag 1.1.0 Where once version 2.0.0 is released, most likely a 1.1.x branch is created to maintain the 1.1 release for hotfixes, etc. Now I am wondering how it is possible to integrate this with a CI, like Travis for example. What I do know is that:   * A Continuous Integration system, like Travis CI, gets triggered on every _commit_ to any branch, and it is possible to enable/disable this per branch. I am struggling to figure out if it possible at all to start a build once you have _tagged_ a certain commit, can anyone explain me how this can work?


Analyzing Memory Usage: Java vs C++ Negligible?

How does the memory usage of an integer object written in Java compare\contrast with the memory usage of a integer object written in C++? Is the difference negligible? No difference? A big difference? I'm guessing it's the same because an int is an int regardless of the language (?) The reason why I asked this is because I was reading about the importance of knowing when a program's memory requirements will prevent the programmer from solving a given problem. What fascinated me is the amount of memory required for creating a single Java object. Take for example, an integer object. Correct me if I'm wrong but a Java integer object requires 24 bytes of memory:   * 4 bytes for its int instance variable   * 16 bytes of overhead (reference to the object's class, garbage collection info & synchronization info)   * 4 bytes of padding As another example, a Java array (which is implemented as an object) requires 48+bytes:   * 24 bytes of header info   * 16 bytes of object overhead   * 4 bytes for length   * 4 bytes for padding   * plus the memory needed to store the values  How do these memory usages compare with the same code written in C++? I used to be oblivious about the memory usage of the C++ and Java programs I wrote, but now that I'm beginning to learn about algorithms, I'm having a greater appreciation for the computer's resources.


Concept behind SHA-1 Checksum

What's the basis behind SHA-1 or SHA-2 or other Checksum algorithms? I read about it here http://en.wikipedia.org/wiki/SHA-1#Data_Integrity But I am still wondering about an answer in a layman's language. Can I understand it as a very, very compressed code that can be translated back into original data? Let's say, I have a letter written in notepad. Then the whole of my 1 A4 page size data can be converted into something like this "9b90417b6a186b6f314f0b679f439c89a3b0cdf5". So whenever I want my original data back, I can convert this back into original data? I am very sure that I am wrong here, because it is weird how data that itself contains combination of letters and numbers can be represented by smaller set of letters and numbers. Illogical! Then, what's the basic?


Does UX matter for enterprise software?

I've come to notice that a lot of software that companies use for managing things like time, expenses, setting up phone systems, etc is very non- intuitive from a user experience point of view. I know personally I waste a lot of time just trying to figure out how to navigate these systems, especially if I don't have a co-worker close by who I can bug to help me out. The help files are usually just as bad as the user interface itself. Are companies that complacent or are there just not any comparable enterprise products out there which do the job for these sorts of tasks? It seems that on the consumer side there is plenty of market opportunity for creating better user experiences, but how about for enterprise software? Obviously a certain level of slickness is not going to matter to a company, but when a better UX design translates to time saved, it's hard to argue against that. Edit: I'm not referring to in-house applications, but rather off the shelf systems from large software companies.


Chambers In A Castle Algorithm

**Problem Statement -** ![Problem Statement](http://i.stack.imgur.com/Weq4m.png) Given a NxM grid of 1s & 0s (1s mark walls, while 0s indicate empty chambers), the task is to identify the number of chambers & the size of the largest. And just to whet my curiosity, to find in which chamber, a cell belongs. It seems like an ad hoc problem, since the regular algorithms just don't fit in. I just can't get the logic for writing an algorithm for the problem. If you get it, pseudo-code would be of great help! Note - I have tried the regular grid search algorithms, but they don't suffice the problem requirements. Source - INOI Q Paper 2003


Can I implement the readers and writers algorithm in OpenMP by replacing counting semaphores with another feature?

After reading about OpenMP and not finding functions to support semaphores, I did an internet search for OpenMP and the readers and writers problem, but found no suitable matches. Is there a general method for replacing counting semaphores in OpenMP with something that it supports? Or is there just a gap in the environment where it does not permit things that are asymmetrical like the third readers and writers problem shown on the following page? http://en.wikipedia.org/wiki/Readers-writers_problem#The_third_readers- writers_problem


Designing an easily extensible XML driven OOP system

I've been working on a project that is very data-driven (a checkers board game with customizable rules; I'm using XML for the data storage). I need a design that is easy to extend as we add new features to the project via new XML tags. My XML schema looks like this for a win condition (checkers):               <game>        <winconditions>           <condition winner="Black">              <Pieces color="Red" number="0" />           </condition>           <condition winner="Red">              <Pieces color="Black" number="0" />           </condition>        </winconditions>     </game>      `<game>` is the root element. There are other major sections such as `<board>` which defines the size and shape of the board and placement of the pieces, and `<moves>` which defines how pieces move. The idea is to have several "options" that combine to form a "condition" - if all "options" are true, the "condition"'s evaluation returns a winner. Right now, the best strategy I have come up with is to create a package for the tag processing classes:               processors        pieces      And an interface to a win condition option:               public interface WinConditionOption {        void setParameters(HashMap<String, String> args);        boolean evaluate(GameState state);     }      The file processor, when it sees a tag inside the `<winconditions>` tag, uses reflection to look up the corresponding class and calls it using the interface. So the `Pieces` tag causes a `Pieces` object to be created and `setAttributes()` is called with the tag's attributes. When we check for a win, `evaluate()` is called with the current state of the game. `Pieces` would evaluate whether the number of pieces belonging to that player was a certain number, 0 in this case (no pieces left). Is this a good design? Is there a better way to do it and still be able to write minimal new code to add a new win option?


learn the programming language for computing functions about integers

I know something about Pascal, Mathematica and Matlab, but I dont have any idea about C,C++,C# languages. I want to learn one of the languages that they they are fast and exact to compute some arithmetic functions for large numbers(for example larger than $10^3000$). I asked somebody and he said he used C++ and he said I computed this sequence in less than 10 min. I want to know C, C++, C# and visual kind of theses programs and know which is better for my goal. Let $f$ be an arithmetic function and A={k1,k2,...,kn} are integers in increasing order. Now I want to start with k1 and compare f(ki) with f(k1). If f(ki)>f(k1), put ki as k1. Now start with ki, and compare f(kj) with f(ki), for j>i. If f(kj)>f(ki), put kj as ki, and repeat this procedure. At the end we will have a sub sequence B={L1,...,Lm} of A by this property: f(L(i+1))>f(L(i)), for any 1<=i<=m-1 I have written a code for this program with Mathematica, and it take some hours to compute f of ki's or the set B for large numbers. For example, let f is the divisor function of integers. Do you know how to write the code for my purpose in Mathematica or Matlab. Mathematica is preferable.


Are there Any Concerns with Importing Document Files From a Competing Product?

I have a new product that serves the same purpose as my competitor's long- standing product. One thing I have considered doing is allowing my program to import document files created by their product in order to provide an easy way for users to migrate towards mine. Naturally, this would be done without the competitor's permission, as it goes against their interests. I've seen this done before with office suite software (e.g. Open Office and Apple Pages can import MS Word documents), but I'm wondering if there are any concerns, legal or ethical, with me doing this. I fully expect any answers will most likely fall under the "I am not a lawyer" clause, but it would be helpful to have a starting point for anything I would need to be aware of, or if I shouldn't need to worry.


What is platform independence? Are cross-platform and 'platform independence' same?

What is the platform independence really mean? What are the criterion to call a language platform independent ? Are cross-platform and 'platform independence' same? (This may be a question for self study, but i would like to hear from experts from Stack overflow. There are lots of definitions and views regarding it on interenet and some of them are confusing)


Tree position terminology/naming

This is a naming things question. I am processing trees (XML documents), and there are often special rules applied to nodes based on structure. It's been very difficult coming up with concise naming conventions for some cases, namely for nodes in the first position among their siblings, along with some recursive relationship:   1. Given an arbitrary node, I want to describe its first child, and then that node's first child, and so on recursively.   2. Given another arbitrary node, I want to describe its parent if the parent is first among its siblings, and that parent's parent if it's first, and so on recursively. Is there existing terminology to describe these tree positions? How would you name a variable or function that captures one of these cases so that it's intuitive to an unfamiliar developer trying to understand an algorithm?


Why does java.util.ArrayList allow to add null?

I wonder why java.util.ArrayList allows to add null. Is there any case where I would want to add null to an ArrayList? I am asking this question because in a project we had a bug where some code was adding nulls to the List and it was hard to spot where the bug was. Obviously a NullPointerException was thrown but not until another code tried to access the element. The problem was how to locate the code that added the null object. It would have been easier if the ArrayList throwed an exception in the code where the elements was being added.


How can I better manage far-reaching changes in my code?

In my work (writing scientific software in C++), I often get asked by the people who use the software to get their work done to add some functionality or change the way things are done and organized right now. Most of the time this is just a matter of adding a new class or a function and applying some glue to do the job, but from time to time, a seemingly simple change turns out to have far-reaching consequences that require me to redesign a substantial amount of existing code, which takes a lot of time and effort, and is difficult to evaluate in terms of time required. I don't think it has as much to do with inter-dependence of modules, as with changing requirements (admittedly, on a smaller scale). To provide an example, I was thinking about the recently-added multi-user functionality in Android. I don't know whether they planned to introduce it from the very beginning, but assuming they didn't, it seems hard to predict all the areas that will be affected by the change (apps preferences, themes, need to store account info somehow, etc...?), even though the concept seems simple enough, and the code is well-organized. How do you deal with such situations? Do you just jump in to code and then sort out the cruft later like I do? Or do you do a detailed analysis beforehand of what will be affected, what needs to be updated and how, and what has to be rewritten? If so, what tools (if any) and approaches do you use?


Eventual consistency in Banking systems

I keep hearing people say Banking systems like ATM use Eventual consistency model for data synchronization, but I am wondering if it is true. Definitely the amount you withdraw might be delayed showing in your banking statement, but I assume they won't let the amount of your banking account inconsistent at any given time, right? Anyone working in the industry can confirm this?


Is pattern-matching against types idiomatic or poor design?

It seems like F# code often pattern matches against types. Certainly               match opt with      | Some val -> Something(val)      | None -> Different()      seems common. But from an OOP perspective, that looks an awful lot like control-flow based on a runtime type check, which would typically be frowned on. To spell it out, in OOP you'd probably prefer to use overloading:               type T =          abstract member Route : unit -> unit          type Foo() =          interface T with             member this.Route() = printfn "Go left"          type Bar() =          interface T with             member this.Route() = printfn "Go right"      This is certainly more code. OTOH, it seems to my OOP-y mind to have structural advantages:   * extension to a new form of `T` is easy;    * I don't have to worry about finding duplication of the route-choosing control flow; and   * route choice is immutable in the sense that once I have a `Foo` in hand, I need never worry about `Bar.Route()`'s implementation Are there advantages to pattern-matching against types that I'm not seeing? Is it considered idiomatic or is it a capability that is not commonly used?


Tools to help Agile team deliver value

My Agile team is following practices of XP like pair programming(J2EE), 45 work hours/week, TDD etc. Do you have any recommendations of open source tools (dev, test & build integration) and templates(user story, burndown charting) etc. for enabling my team to focus on business value delivery. I am the iteration manager and we have tried Hudson, Junit and Selenium.


Is it ethical to use personal code at work?

I am working on a side project at work where I find it beneficial to use some of my code that I have developed personally (outside of work) to speed my development. My side project is developing a C++ GUI application to let our power users run queries (built by me) against databases on several different platforms (DB2, Oracle, SQL Server and MySQL). In the past, I would usually just run these myself on request or build an Excel VBA application for them. Now that I have built several VBA applications for several different people, I find the need to build one central application that just reads in custom .sql files and executes against various databases. The application that I am building is in C++ and uses an LGPL cross-platform GUI toolkit. However, I have a lot of code that in my own libraries that I have built over the years on leisure, non-work related projects. Is it okay to use this code at work, thus saving me (and the company) time? If so, can I port any bug fixes and enhancements back to my personal library? There seems to be a line that I do not know when I am going to cross it. I just want to add that none of the personal code has anything to do with any business logic. They are just basic utility classes/wrappers.


Are there any best practices regarding the handover from architecture to development?

We are looking at improving the process for handing over tasks from architecture to development. At one end of the scale it there is no architecture guidance you risk getting chaos, with each developer doing things his way. At the other end of the scale where everything is specified, the specification takes longer than the development, and you risk having very boring development tasks. Has anyone found an optimal middle ground between these extremes? Which artifacts do you deliver to development? For example: modules, class structure, or sequence diagrams?


Domain Model and Querying

I am new to DDD, having worked only in Transaction-Script apps with an anemic model, or just Big Balls of Mud, so please forgive any terminology I abuse. I am trying to understand the proper separation between the domain model and the repository. What is the proper way to construct a domain object that is coming from a database, assuming the (incredibly simplified) need to query for objects by status (returns `enumerable`), or by ID.   * Should a factory be building the objects, exposing methods for `GetByStatus()` and `GetByID()`, using a DIed repository?   * Should a repository be called directly, knowing how to build a domain model from the DTO?   * Should the domain model have a constructor for get by ID, using a DIed repoistory to load the initial state, using some other (?) method for the list? I am not really sure what the best way would be, and this question has an answer advocating each one (these are certainly mutuallu exclusive).


Better php framework for shared hosting

I need to develop an app for booking appointments. This is going to be **hosted in a shared server**. So performance is the most important thing. I have used symfony2. I quite liked the framework. But seems to be heavy. Which framework would suit me considering my requirements? I have shortlisted three frameworks **yii, symfony2 and ZF2.** I am not asking which framework is better. **All the three are good frameworks**. I want to know which will suit my requirements. My first priority would be performance (I will be using AJAX wherever possible), second would be maintenance and development time and third community support. Or should I use my own handlers to separate views and logic and just use raw php?


Branding websites aimed for mobile devices

I'm currently working on a website which is also supposed to be mobile optimized. My client has provided me with a layout of how the mobile version of how the website should look like. Making their design wish come true is no biggie, but making the design fit the screen is my issue. Right now I'm facing some issues regarding the width on the `<body>` tag of the site, as the design is measured to a width of `640px`, but that leaves a big gap on the right side of the screen on e.g. iPhones and Android phones. The website is being developed in ASP.NET and C#. We're only using 1 masterpage, thus the optimizing can be tricky. The design I've been provided with is a `.psd` file which I'm supposed to just slize up and take images etc. directly out of. Problem is all the navigation images, content dividing images etc. are all in specified widths and heights, thus I've put the width of `640px` on the `<body>` tag. So my question really is, what's the best way of fitting a design to a handheld screen? Should I forget all about pixels, em and inches and go all the way with % for both width, font-size etc? Or can I just "copy/paste" the provided design and some how force the screen resolutions on the phones to fit their zoom to the width of the 640px body width without leaving gaps of space in either sides of the screen?


What is the difference between collation and character set?

I have a general question about databases. We usually use the term collation with databases. I would like to know how its different from character set. I guess collation is a subset of character set. If its true, what is the purpose multiple collation under a character set.


UML - Class Diagrams Order -> Products

I have a class diagram that is like this:               < Order > (1) CAN HAVE (M) < products >      But therefore `Order` has the following:               Order_Id     Customer_Id     Order_date_day     Order_date_month     Order_date_yeah      But I do not know how it would handle the Products? Because, I couldn't have `ProductID` because that would mean that each item in this class would have to have a separate instance for each product (E.g. someone ordered 100 products, but only placed 1 order). Could I have an `Product` object in class `Order`? If so, how do I represent that in UML?


Best 3 people development team organization?

A developer of my company was promoted to a new possition that practically manages us developers, and he assigned to 3 people in our team(including me) some big proyects done in Java/Delphi/.NET, the point of being a team was so that each of us could manage each other's code in case that someone goes on vacation or leaves the company for any reason. Suggestions start on monday but i really have not found any solid information on how language agnostic teams work, nor how to manage one, although my idea was to advice a eclipse/maven/jenkins enviroment with TDD approach for java projects, but i do not know what is best for us in the other languages. Would you migrate the Delphi .Net applications to Java as well? Or would you learn both languages as well and just leave it as it is. I am sort of a java fanboy but i wouldn't mind learning other languages, but what i do think is that having one language has advantages like everyone knowing the same tools and less tools to master. I still do not know what to suggest besides what i said above, any advice on this sort of problems is appreciated.


What's the best way to prepare your design & code for those "unknown unknown" bugs from day one?

I am just wondering, is there any practical method or technique or even tricks to get avoid those "unknown unknown" bugs especially those nasty and random ones which are often emerge at the last minutes or at least to keep these things at a minimum level. I ask this because when you work on a new platform or use certain new technology for the first time, how do you justify your design and code are robust enough? Or these things can only be learned by time and mistakes? (I use C++ for most of my working time) Thanks!


Last semester of college: while trying to get first web/mobile developer job

I am in the last year of my BS in Engineering - Information Technology degree. Some things I have noticed while looking for jobs is that larger older corporations want you to know java or c# for their existing enterprise level systems, while most high-tech, startup or mobile centric software companies want you to know the latest languages, technologies and have experience with open source stuff. The startup/mobile company appeals more to me. The companies usually seem to have more young people working for them and advertise how fun it is to work there. I was thinking about trying to get a developer position in either mobile or web development fields. My main problem is that I have no experience working just as a programmer. I have had an internship that dealt mainly with systems administration work, along with learning all of the corporate business side of things and helping the marketing team with their web page. Now in my last semester I am rushing to try to put together a portfolio. I have a wide variety of small projects in PHP, ROR, C#, along with hybrid type html/css/javascript mobile apps. None of these projects are what I consider to be completed and polished. I have a wide range of half done web apps. Would it be a bad idea to but unfinished projects in a portfolio on a resume? I am really tempted into getting more into iOS objective-c development but would it be to late at this point? I know that it is important to master something but I only have a few months until graduation, would it be better to just go back and finish a small php app or something similar? (that essentially isn't really anything but a personal project). I feel I have a good understanding of core principles but don't know how to best allocate my time. Any advice would be helpful, Thank You.


Is Perl still a useful, viable language?

I know it may have been asked before, but here goes nothing... Is Perl still something that would be considered useful? If someone was a new programmer (either completely new to programming or just a few month/years of experience) would Perl be something to be considered worthwhile to learn? Is Perl still used with frequency? Is it still popular? Or is Perl dying out compared to languages like Python, Ruby, PHP, ASP.NET, etc.? Basically it boils down to this:   * Is it still used/is it still used frequently? If yes, is it dying? If no, will it make a come back?   * Is it something that would be worth learning?   * How does it compare in demand to languages like Python in both popularity and usability/viability? Could languages like Python or Ruby be considered replacements for Perl? Also, will newer versions of Perl really bring a large improvement to the Perl community, and perhaps bring Perl back to centerstage compared to other languages? EDIT: Okay, I suppose here's a better, reworded question: Is Perl still growing, or is it "dying"? Is it still a language worth learning and using? What projects does it really "shine" in compared to other languages? What makes Perl a language to choose? Essentially: is Perl growing obsolete compared to other languages, and if so, do you expect that to change, or to continue? And thank you to everyone who has answered so far, the discussion has been really interesting!


How can I test parts of my application against the output of third party application?

I have a fairly new C# application, approximately 6 months old, that we are now trying to incorporate testing into. (Should have been done from the start but I can't change the past) Parts of this application involve pushing some documents out to a folder. A third party application then picks these up, does its own work on them, and drops output files in another folder. My application waits for this to be done, picks up the outputs, then continues its work. This poses a problem when testing as I can't really install another version of the third party just for testing, nor can I mock it without ending up fully rewriting the third party application. How can I test these parts of my application? (Preferably with NUnit) Specifically, I'm asking about how to unit test my code against the output of the 3rd party tool. So it's a little bit different than another similar question, which involves isolating how code interfaces with a third party.


Is there any issue if ternary operator is used in super() method

I am using a ternary operator in super () method of my code. While the code went for review, I got a reply that > Strictly don’t use ternary operators in the Super() calls. Is there any problem if we use ternary operators in the super() method?


Are There Metrics For Cohesion And Coupling?

Is there a metric analogous to the McCabe Complexity measure to measure how cohesive a routine is and also how loosely (or tightly) coupled the routine is to other code in the same code base?


Does Rhodes actually create a Native app or a Hybrid app

Rhodes claims to be able to build Native apps but I'm not sure or not if this means a native shell + embedded Web Browser like PhoneGap or does it create a true Native app like (I believe) Titanium does.


Distributed Transaction Framework across webservices

I am designing a new system that has one central web service and several site web services which are spread across the country and some overseas. It has some data that must be identical on all sites. So my plan is to maintain that data in the central web service and then "sync" the data to sites. This includes inserts, edits and deletes. I see a problem when deleting, if one site has used the record, then I need to undo the delete that has happened on the other servers. This lead me to idea that I need some sort of transaction system that can work across different web servers. Before I design one from scratch, I would like to know if anyone has come across this sort of problem and if there are any frame works or even design patterns that might aid me?