title: Handling and organizing data from save file?

text: I'm working on a webapp (python/javascript) to modify a game's save file. The file has certain bytes representing player information, such as the gun, the equipment, etc. The idea is to show an interface representing the information in the file, allow the user to make changes, send the data back to the server, which modifies the file, and allows the user to download it. My problem is that I don't know which functions should be handled in javascript, and which in Python. I need python for reading the file, but does that mean I should use it to handle the data? If I read the information into relevant variables to send back with JSON, is it redundant because I'm not doing anything with the information in Python other than sending it back? I've currently been indecisive about two possible ways to go about it. One, and this is the way I currently have it set up, is to handle the file with Python; figure where certain things are, read them into dictionaries, turn it into json, send that to javascript, and then parse the json and update the gui. As I said before, this feels like the wrong way to do it. The other thing I was considering was to just read the entire file and send that back to javascript to work with. This also seems really incorrect. Javascript (at least as it's implemented in browsers) isn't meant to handle files, and packing/unpacking functions would have to be custom - one of the things I'm seeing as a red flag about this method. The files are only about 1-2kb, so that wouldn't be a reason not to send it back to the page. In fact, the json I'm sending back is larger than just the contents of the file would be. Still though, I don't much like the idea. So what do I do? I'm also having trouble organizing the actual code. I know it's bad practice to stick a lot of code into a single function, but dividing into many other functions has made it hard to keep track of things. Is there a good language-agnostic book that will help me with this?


title: Need a file location in Business logic layer from UI layer

text: Here's what I'm doing: I am reading a file in BLL, which is sitting in the UI layer. Currently the application is using `HttpContext.Current.Request.PhysicalApplicationPath` to find the absolute path written in BLL. I feel this is not a good design and I am thinking that I should pass this information in some kind of structure to BLL or I could use a helper method to get that. Please let me know which one is better and if there are any better solutions / suggestions. Please ask if you need more details.


title: Should I use chained functions in Java?

text: From time to time, I'll have a class in Java that takes a multitude of parameters, however, sometimes when I am creating an object of this class, I don't need to use all the parameters. As of now, I usually set the parameters to null or 0 depending on the type. However, would it be easier if I just created chained methods to set certain fields in the class? So, instead of: `MyClass someInstance = new MyClass(param0, null, null, 0, null, param5);` Have something like this: `MyClass someInstance = (new MyClass()).setParam0(param0).setParam5(param5);` Does this go against OOP or Java's usual paradigm?


title: Is @staticmethod proliferation a code smell?

text: Consider a Python class with a number of `@staticmethod` methods and few instance methods. The static methods don't accept an instance of the defining class as parameters.   * Do you think that all these static methods don't belong to the class and should be factored out?   * If yes, which approach would you take to clean up such code?


title: If you were to build an app like Craigslist, would use an off-the-shelf framework or write your own?

text: Title is the question. And why I am asking is because from what I read about most PHP frameworks (e.g. Code Igniter, Kohana, Cake, Zend) is that they're ether too complex, or are designed mostly for small applications (like blogs).


title: How should an embedded OS be combined with user code?

text: As a side-effect of an embedded project I've been working on, I've developed a small operating system for an ARM processor. While the OS and my user code are in separate directories and have clean boundaries between them, they're built into a single image using a single Makefile. I'd like to release the OS as open source. It consists of an exokernel and userland driver libraries. What I'm trying to decide is how a user of this OS should combine it with their own code at build time so they have a single image to flash. I can think of three possibilities: 1) Have the user include the OS source files as part of their project. They'd be recreating the setup I currently have, and it's how FreeRTOS, for example, appears to do it (although it only has three files). 2) Have the OS build itself into a .a file that the user code can link with. That would allow the user full control over memory placement using their own linker script (and allow the linker to tell them when a combined text, BSS or data section exceeds its space). 3) Have the OS build itself into a raw binary that expects to have the user code concatenated onto the end of it. The user code would begin with a small header (placed by the linker script) that had the address of the main function. The user code would also link with a .a file of just the userland drivers, not the kernel. (1) would make it easiest for me to develop the OS and my user code in parallel with git subtree. (2) seems to have the most useful link process. (3) gives the biggest separation. If you were using it, which would you prefer and why?


title: Applications of heapsort

text: Heapsort is a sorting algorithm that has a time complexity of O(nlogn), and performs sorting using O(1) space complexity. However, I know that because it's unstable, it doesn't find many applications (f.e. compared to other sorting algorithms). I know it's used for interval scheduling. **What are some practical applications of heapsort?** **EDIT:** As @AProgrammer pointed out, quick sort isn't stable either.


title: What is the difference between a non-functional requirement and a quality attribute?

text: I'm trying to understand the difference between non-functional requirements and quality attributes. Are they the same thing? You can find a set of quality attributes in the ISO9126 standard. I know that each system is defined by a set of functional requirements and every of this requirements has associated one or more quality attributes. For example, suppose that you have the requirement that describes the login functionality of a system. You can associate to that requirement the attributes of security and performance. If i say that the system can not take more than 1 second to respond, I'm talking about a constraint. So, where the concept of non-functional requirements kicks in? Are they defined by the users? How can I identify them?


title: Are you obliged to provide old employers with access to protected resources?

text: Firstly, a disclaimer. This question is not because I'm a disgruntled employee planning to hide some malicious code which I can later blackmail my employer with. I actually quite like the people I work with - just simply curious. So if an old employer needed a password for some resource that only I had. Would I be obliged to give it to them or could I (probably unwisely) stick it to them and either refuse or charge an outrageous "consulting" fee for providing that password? Or what if I designed some component for them like some sort of underlying encrypted security layer that required some a hash key that only I had, would I be obliged to give it to them? These two scenarios are generally the fault of the employer, but what if in the third scenario, I built this component in stealth, without them actually knowing? I don't necessarily mean the component was built with the sole intention of locking the employer out in the future, it may have actually served a good purpose - it just never got documented how it functioned because company had poor documentation processes or developers were too busy etc. In that scenario, when they finally need this hash key, would I be obliged to provide it?


title: terminologies and design/process clarification

text: I work at a BPO, actually a call center. My bosses saw the html tool I made to help me document customer concerns and steps I made to help them faster and more easy. With that, they made me the reporting guy. Then they asked me to create a executable file (.exe) which generates the stats or metrics of agents. I used c#, and ms access for the database for it. It took me 6 months to finish it, on my own. But I feel that's kind of a long period for a project like that. And when I look at my codes, I'm not satisfied myself. I really want to pursue programming/software development. Its just that I don't have proper training or education for it. I took computer engineering in college but my school isn't that good (I want to share the reason why but it'll just make this post longer). I've been doing research, reading ebooks about programming but I still can't grasp the essence of it. It's like, I can easily learn a language, IDE, technology etc., but I can't put them together. Can you, experts, tell me how I could see the bigger picture? Can you help me understand the following:   1. How are companies that makes/provides software solutions/programs start a project? Or how do they make them, in terms of process?   2. I've been seeing terms like software tester, unit testing, automation test etc. What are those and why are they being used or incorporated in the process? I have so much questions to ask, but when I try to post them, I tend to forget them, like at the tip of tounge. I hope you experts, can shed some light on those questions. I'm not trying to solicit points, but I really want to use the chat feature here so that when I have a quick question and learn more about programming/software development, I could easily chat with experts.


title: A testing environment for JavaScript other than browser?

text: When I want to test something in JavaScript, I open up a new browser window (mostly Firefox) and start writing code in the provided console (mostly Firebug). However, this tends to be really tedious and slow. Is there an environment, like an IDE with self-execution capability for example, in which we can test JavaScript? Guide: I'm looking for something like jsfiddle, but not in the browser, and not online. I'd like to have an execution environment which is both off-line, and is not a browser. All I'm asking is to have something like the Firebug Console as a separate applications (preferably Windows application) which can be opened by double- clicking, and in which, you can write JavaScript code and hit execute. That's all. In simpler terms, all I want is Firebug's console, without Firefox. Do we have such a thing on the market?


title: How do you call a "Proxy" that delegates to *several* implementations?

text: In a traditional GoF Proxy, you have an Interface, an Implementation, that implements the Interface, and a Proxy that also implements the Interface, references an instance of Implementation, and delegates the calls on the Interface methods to the same methods in the Implementation instance. Say you would call the Interface/Implementation pair a "Fragment", and you would have several different such pairs. Now imagine you create a Whole Interface that implemented all those Fragment interfaces, and a single Whole Proxy that implemented the Whole Interface, and delegated to the appropriate Fragment Implementation instance. A code (Java) example:               // Fragment A:     interface FragmentA { ... }     class FragmentAImpl implements FragmentA { ... }     // Whole A. That is the interface that "clients use"     interfaces WholeA extends FragmentA { // EMPTY! }     // *automatically generated* Proxy:     class ProxyA implements WholeA {         private FragmentA implA;         // Implements FragmentA through delegation to implA     }          // Fragment B:     interface FragmentB { ... }     class FragmentBImpl implements FragmentB { ... }     // Whole B. That is the interface that "clients use"     interfaces WholeB extends WholeA, FragmentB { // EMPTY! }     // *automatically generated* Proxy:     class ProxyB extends ProxyA implements WholeB {         private FragmentB implB;         // Implements FragmentB through delegation to implB     }          // Fragment C: similar to Fragment B, but with different *added behavior*.      Is this pattern at all (since Patterns must be common solution to common problems)? And if so, as it got a name? Or could it be cleanly defined as a combination of patterns? Being able to clearly describe how this code works in terms of patterns would make it much easier to explain to others how create compatible code, and help to find a framework that already implements this pattern. A _Proxy_ normally delegates to _a single instance_. A _Facade_ normally offers _a different interface_ to that _multiple objects_ it hides. A _Bridge_ also offers _a different interface_ to that the _single instance_ it hides. A _Composite_ expects all components to _share the same base interface_. A _Decorator_ extends the interface of the wrapped object, like here, but normally _implements the additional functionality itself_ , instead of delegating to another objects. A Whole that implements a single Fragment is just a Proxy pattern, but a Whole that extends another Whole is closest to a Decorator pattern. There are several reasons to do it this way. Firstly, client code should see WholeB as extending WholeA, although the implementer of FragmentB cannot extend FragmentA (which was implemented by someone else). Secondly, references to WholeX (ProxyX) stay valid, even if implementation of FragmentX is replaced a runtime. Thirdly, both ProxyB and ProxyC can share _the same instance_ of FragmentAImpl.


title: Class Design for special business rules

text: I'm developing an application that allows people to place custom manufacturing orders. However, while most require similar paperwork, some of them have custom paperwork that only they require. My current class design has a Manufacturer class, of which of one of the member variables is an array of RequiredSubmission objects. However, there are two issues that I am somewhat concerned about. First, some manufacturers are willing to accept either a standard form or their own custom form. I'm thinking of storing this in the RequiredSubmission object, with an array of alternate forms that are a valid substitute. I'm not sure that this is ideal, however. The major issue, however, is that some manufacturers have deadline cycles. For example, forms A, B and C have to be delivered by January 1, while payment must be rendered by January 10. If you miss those, you'll have to wait until the next cycle. I'm not exactly sure how I can get this to work with my existing classes—how can I say "this set of dates all belong to the same cycle, with date A for form A, date B for form B, etc." I would greatly appreciate any insights on how to best design these classes.


title: How to convince my teammates that spawning numerous threads is a bad design?

text: I've stumbled upon this problem when tried to run our application in bad network conditions; it spawns hundreds of threads (which exist long time before termination), and with time the application crashes. However, other developers answered this is "not a bug" and "as designed".   I have a strong gut feeling that spawning so much threads instead of using async calls is defective design, in the first place. However, my teammates disagree.   Any ideas how I can convince them? UPD can I say that spawning threads for short running tasks is a bad design? What arguments I can use to support this statement?


title: Re-architecting a classic inheritance design

text: I have the opportunity to rewrite a core piece of a project (C#) that is inheritance-heavy and feels increasingly restrictive in how it is designed. The scenario is pretty simple, imagine an application that is built to handle various small tasks. Every task is unique in it's functionality so it implements an ITask interface with a few simple methods that get implemented by each task class (e.g. Init(), Start(), Stop(), etc). In addition to the ITask interface there is also an abstract BaseTask class that all tasks inherit from. This BaseTask class is sort of an 'everything but the kitchen sink' approach that contains useful pieces of functionality that the tasks often require. For example, all tasks record their status and progress the exact same way so this logic is defined in the BaseTask and available to all children through a protected method. Or to give another example, some tasks have to send email notifications out when certain conditions are met, so again, the BaseTask provides access to the core smtp functionality of the app for this purpose. There are many examples of these kind of 'helper' methods/properties The problem of course is that this base class has already grown unwieldy and cluttered with properties and methods that are not universal to all tasks and it's starting to introduce more problems than it is solving. For example, anytime a change is required to the base class you find yourself in a position where you might wind up breaking some (or all) of the tasks. It also just seems like its breaking encapsulation and the single responsibility principal. It's also quite clear how this happened in the first place (and a common occurrence too). Initially this was a very small, specialized application but it blew up in terms of scope and size very quickly and what was initially probably not a bad decision architecturally has proven inflexible and awkward. Where would you start with something like this? How would you approach the problem and what principals or design patters would you choose? Thank you very much


title: PHP email blasts using a cron job

text: My PHP application needs to send product expiry notifications to customers everyday. I am thinking of:   1. A one-time cron job for a php script that identifies the customers from a table of 10000 rows then send an email to each one using the SwiftMailer library. Each email will have unique content so I am not planning to do "batch send". * _Con: *_ Too slow and the server may kill it.   2. A recurring five-minute cron job that would send a definite number of emails (eg. 20) for every execution. * _Con: *_ All customers may not receive emails since the the queue may not finish within 24 hours. Please give alternatives and suggestions. TIA.


title: How to rewrite a TCP MMOG server designed to run in a single machine, in a distributed way?

text: I have a MMOG server running on C++, using winsockets. My server won't support more than 200 players. I had the idea of redesigning it so it will use multiple servers instead of one, so, maybe, for example, each server could take care of a number of players, and, if it was too laggy, it could transfer the responsability of that player to other server. I'm not sure of how to program a consistent game logic like that, though. Are there techniques for this?


title: How can you make a cluster run a task only once?

text: If you had a task that you wanted to run only once on a cluster of servers, at a regular interval what would be the best way of achieving this? _The definition of cluster in this case is 2 or more identical servers with distributed sessions sitting behind a load balancer._ **Use Case:** You have a task that is expensive to run that should only be run once per X hours. This job could for instance iterates over a bunch of records and updates their status.   * Worst case scenario is that having the job run twice invalidates your data.   * Best case scenario is that the job utilises resources on all your servers. **Requirements Summary:**   1. The job must still run even if one of the nodes are down.    2. The job must only be run once per schedule.   3. If multiple jobs are scheduled at the same time or at overlapping times that the number of running jobs is distributed equally between the servers.   4. The machines must have the same code base and be synchronised via NTP.   5. The configuration may differ between node and node, by environment variables.   6. The job has to start on time or within a given interval of the assigned time. (say 5 minutes for example) **Possible solutions**   * Set one node as the master node, this doesn't work as it violates 1 above.   * Make a request that the load balancer balances to kick off the job. Unfortunatly this has the side effect that if you have multiple jobs running at the same time they may all be run by the same machine. This would have to run in Java, in a servlet container. However it isn't coding the jobs I'm looking for. Surely this is a solved problem with known best solution. * * * **Related question.** Schedule job executes twice on cluster This isn't a duplicate as the solution is insufficient as per those 5 requirements given above. The most upvoted solution suffers from a race problem, and the second solution violates requirement 3


title: Help us with our git workflow

text: We have a web application that gets deployed to multiple regions around our state. An instance of the application for each region. We maintain a staging and production (master) branch in our repository, but we were wondering what is the best way of maintaining each instances codebase. It's similar at the core, but we have to give each region the ability to make specific requests that may not make it into the core of the application. Right now we have branches for each region, like region_one_staging, and region_one_production. At the rate we're growing we'll have hundreds of branches here in the next few years. Is there a better way to do this?


title: Should I open Source my iOS application?

text: I developed an iOS application as a student and I am currently distributing it for free in the app store. I have received a few enquires about adding features to the app including one person who would like the app to be open source so they can add features themselves. What concerns should I have if I open source my iOS application? Which open source license should I use?


title: DB Object passing between classes singleton, static or other?

text: So I'm designing a reporting system at work it's my first project written OOP and I'm stuck on the design choice for the DB class.   Obviously I only want to create one instance of the DB class per-session/user and then pass it to each of the classes that need it. What I don't know it what's best practice for implementing this. Currently I have code like the following:-               class db     {         private $user = 'USER';         private $pass = 'PASS';         private $tables = array( 'user','report', 'etc...');              function __construct(){             //SET UP CONNECTION AND TABLES         }     };          class report{     function __construct ($params = array(), $db, $user)      {                 //Error checking/handling trimed         //$db is the database object we created         $this->db = $db;              //$this->user is the user object for the logged in user         $this->user = $user;              $this->reportCreate();      }          public function setPermission($permissionId = 1)     {         //Note the $this->db is this the best practise solution?        $this->db->permission->find($permissionId)              //Note the $this->user is this the best practise solution?                 $this->user->checkPermission(1)              $data=array();         $this->db->reportpermission->insert($data)     }     };//end report      I've been reading about using static classes and have just come across Singletons (though these appear to be passé already?) so what's current best practice for doing this?


title: Outsourcing: question about code ownership and copyright

text: I want to ask a question from an employer point of view. I know that you are not really lawyers and stuff but I think you might help. I'm into negotiations with a freelancer (from India) to create a specific standalone application to do some file convertions. This is a program that I want to brand and resell. I got a good offer from them because they have already created such software in the past. But I'm having two issues: a) The program was previously made by them for another client of theirs, under unclear terms (or I haven't explicitly asked yet). From what they told me, they created the program for him for his private use. It seems that they still have copyright/ownership of the source code. b) They still want to keep the copyright/ownership of the code. I don't really mind, but in reality, I want to know how this can or can't affect me in the future. For example, what if the sales go well and suddenly they decide they want a piece of profit because the code is theirs? Something like that. Now another question: Is there a difference between the source code of a program and the compiled version of it? For example, I get the final product (as in an executable/installer) that I own and have the rights to, and they keep the rights for the underlying technology. Is this possible? And lastly, what do you think is the best to approach this? I think that I can allow them to keep the copyright of the code but sign a resell rights agreement to me for the final product. Is this valid at all? Can it be done?


title: Learning C# quickly (given I already know…)

text: Ok, I want to learn C# for a job interview (they want C# or Java, I know Java, but figure knowing both would be good). I already know Java, C++, C, F# and to some extent Python and Pascal. What are the big differences between C# and Java or C++? What are some good resources to look into, given I want to get a basic understanding in couple of hours? BTW: I told them that I didn't know C#, saying that I did however know these other languages, and that I could probably pick it up quite quickly.


title: Conversion of a number from Single precision floating point representation to a Half precision floating point

text: I have a code where I have to work on Half precision floating point representation numbers. To achieve that I have created my own C++ class fp16 with all operators(arithmetic logical, relational) related to this type overloaded with my custom functions, while using a Single precision floating point number with a Half precision floating point number. Half precision floating point = 1 Sign bit , 5 exponent bits , 10 significand bits = 16 bit Single precision floating point = 1 Sign bit, 8 exponent bits, 23 significand bits = 32 bits So what I do to convert from a Single precision floating point number to a Half precision floating point number:- For significand bits - I use truncation i.e. loose 13 bits from the 32 bits to get 10 bits significand for half precision float. What should I do to handle the exponent bits. How do I go from 8 exponent bits to 5 exponent bits? Any good reading material would help.


title: Software Methodologies

text: I'm very new in this area but I spend a long time to read about all this methodologies (SSADM, AGILE, RAD, SPIRAL, WATERFALL, INCREMENTAL, DSDM, XP, Iterative) in detail, how do they work, the advantageous and disadvantageous and ... Now the bad part part is: I understand them all separately but can't understand :   1. Is it like one of them let say **SSADM** ( WITH 5- 7 STAGES ) is what we try to achieve and we should use the rest (RAD, AGILE AND ..) to do so.   2. Or its like some of them are the main Categories like (SSADM, AGILE) and the rest becoming their subcategories?   3. Or no there are all separate things with no connections which in this case i can't understand stuff like this from Wikipedia: > SSADM is a waterfall method for the production of an Information System > design. SSADM can be thought to represent a pinnacle of the rigorous > document-led approach to system design, and contrasts with more contemporary > Rapid Application Development methods such as DSDM.


title: How can I explain this is an anti-pattern?

text: I recently started at a new job. The existing system works OK but is poorly designed and hard to maintain, and they are planning to rebuild it in MVC and I fear it will be much worse. (Not because of MVC) I want to discourage the lead dev from using an anti-pattern Existing issues include   * Hard coded strings in the business logic which are also tied to the interface (e.g. `if (x.CustomerType.Contains("Shipping Customer") foobar();` is _everywhere_   * Some classes map to dbTables directly (which is good). But because the software has to be "easy to add features to ", there is a Sharepoint-esque "DynamicData" table for storing new fields that the customer may require. a la `[FieldName] [FieldValue] [FieldType]`   * Refusal to use Linq but chains lamda queries for about 2 page widths.   * Exceptions not explicitly thrown or rethrown, but not handled properly (the client can see the call stack because it is just dumped into a popup dialog)   * Refusal to use `var` but loves the idea of `dynamic` everything.  What is the best way to go about convincing my lead dev to avoid these horrible methods and not put _everything_ in the generic key-value-pair table in version 2.0? (Considering I am new here and the team lead has been here for many years)


title: Left and Right most Derivation

text: So i understand the semantics of derivations as far as Backus Naur Form goes. One thing I cannot find in any text book or the various lecturers' notes that are on-line is this. When would a right most derivation be beneficial over a left most derivation? Would a compiler or generator always use either left, or right, or would it use both? So here's an example: Suppose we had the following language sentence: A = B + C * A Example Language Grammar Permitting the Above:               <assign>  <id> = <expr>      <id>  A | B | C     <expr>  <expr> + <term>             |<term>     <term> <term> * <factor>             |<factor>     <factor>  ( expr )             | <id>      Left Most Derivation:               <assign>   => <id> = <expr>                   => A = <expr> + <term>                   => A = <term> + <term>                     => A = <factor> + <term>                    => A = <id> + <term>                    => A = B + <term>                    => A = B + <term> * <factor>                   => A = B + <factor> * <factor>                   => A = B + <id> * <factor>                   => A = B + C * < term>                   => A = B + C * <factor>                   => A = B + C * <id>                   => A = B + C * A      Right Most Derivation:               <assign>  => <id> = <expr>           => <id> = <expr> + <term>           => <id> = <expr> + <term>   * <factor>           => <id> = <expr> + <term> * <id>           => <id> = <expr> + <term> * A           => <id> = <expr> + <factor> * A           => <id> = <expr> + <id> * A           => <id> = <expr> + C * A           => <id> = <term> + C * A           => <id> = <id> + C * A           => <id> = B + C * A           =>  A = B + C & C


title: Don't Repeat Yourself across integration-test code and production code?

text: I totally believe in not repeating yourself in production code. I've accepted the idea that you shouldn't repeat yourself within test code. But what happens when you have production services that would simplify test code? Let me pose an example. We have a service that accesses the Doohickey API. The Doohickey API is complex, by necessity, and we have a bunch of code to simplify it for our needs. Now I need to write some automated tests for our service. My tests need to set up data in the service and it would be really handy to reuse that facade. But then I get into an argument with myself, that goes roughly like this: "If you introduce a bug in the Facade, the test might not show it." "But, if you just take a copy, then when Dohickey Inc upgrade their API, you need to make the change in two places." "True, but maybe that's a good thing. We can upgrade production code first, manage test data using the old, known, still-supported API and test the new version thoroughly." And then I think maybe I'm overthinking the problem. Does anyone have experience with this kind of issue? If so, which way did you go, and did you regret it at all later? Edit: Early comments suggest a more specific example is required. Say I have a service that can create a product AND create an order. I have the following test to write ...               Given that product X exists     When customer Y orders product X     Then an order should exist for customer Y, including only product X      For the "When" part of this, I contact my service, which uses a facade around the Dohickey Purchasing API to create the order. The "Given" and "Then" steps should create a product and get an order, but they shouldn't go through the service to do so. Perhaps my service doesn't have that functionality, and if it does then I will test it elsewhere. BUT the facade that lives within the service would make the test code much simpler. So should I reference the production code and use it or copy / rewrite the facade?


title: Where is it permissible to add logging code in a MVC model?

text: Working on a C# WinForms program that is written in a MVC ( actually Model- View-Presenter) style and I want to add a few lines of code that is responsible for logging some events. Where should I write two or three lines of code that I need? Should I write it in the Presenter section? To get an idea, here is some lines of sample code that already exists in the **_Save()_** metohd in **_Company.MyApplication.Presenter.MyPresenter.cs class:_** he has written codes lie the following in this part of presenter:               private void Save(Helper.SaveStatusEnum status)     {         if (notification.CheckLocks(orderIdCollection))         {             using (new HourglassController())             {                 controller.FireActiveCellLeaving();                 ViewDocumentedValues();                      int result = saveController.Save(status);                      if (result == Helper.SAVE_SUCCESSFUL)                 {                     //  IS IT OK TO WRITE MY COUPLE LINES OF CODE IN HERE???????????                     model.Dirty = false;                          if ((model.CurrentStatus == Helper.OrderStatusEnum.Complete) || (model.CurrentStatus == Helper.OrderStatusEnum.Corrected))                     {                         controller.EnableDisableSheet(false);                     }                          CheckApplicationState();                     SheetHelper.ClearUnsavedDataRowImage(view.ActiveSheet);                 }                 else                 {                     MessageBox.Show("An unexpected error occuring trying to save.");                 }             }         }     }


title: Data structure for pattern matching

text: Let's say you have an input file with many entries like these:               date, ticker, open, high, low, close, <and some other values>      And you want to execute a pattern matching routine on the entries(rows) in that file, using a candlestick pattern, for example. (See, Doji) And that pattern can appear on any uniform time interval (let t = 1s, 5s, 10s, 1d, 7d, 2w, 2y, and so on...). Say a pattern matching routine can take an arbitrary number of rows to perform an analysis and contain an arbitrary number of subpatterns. In other words, some patterns may require 4 entries to operate on others may require more or less. Say also that the routine (may) later have to find and classify extrema (local and global maxima and minima as well as inflection points) for the ticker over a closed interval, for example, you could say that a cubic function (x^3) has the extrema on the interval [-1, 1]. (See link) Given that I don't know the size of the input file upon reading? What would be the most natural choice in terms of a data structure? What about an interface that conforms a `Ticker` object containing one row of data to a collection of `Ticker` so that an arbitrary pattern can be applied to the data. For example, let's say I have a pattern that requires `n` elements to form a match, I need to apply the pattern to those elements and then analyze each one of those chunks. What's the first thing that comes to mind? I chose a doubly-linked circular linked list that has the following methods:               push_front()     push_back()     pop_front()     pop_back()     [] //overloaded, can be used with negative parameters      But that data structure seems very clumsy, since so much pushing and popping is going on, I have to make a deep copy of the data structure before running an analysis on it. So, I don't know if I made my question very clear -- but the main points are:   1. What kind of data structures should be considered when analyzing sequential data points to conform to a pattern that does NOT require random access?   2. What kind of data structures should be considered when classifying extrema of a set of data points? * * * **Updated** Here's the main analyzer loop for my program (in some pseudocode that's a polyglot of a few languages)               data = new circular_linkedList()     // in my case, data is a circular linked list of elements.     foreach(element in dataFeed) {         data.push_front(element)     }          step_value = Pattern.numberRequiredElementsForMatch()     buffer = new circular_linkedList()     // at this point, you'll have a circular linked list     // where pop_back() will return the oldest entry and      // entry, and pop_front() will return the newest          // initialize the buffer     for(value in range(step_value()) {         buffer.push_back(data.pop_back())         // fill a buffer with the number of         // values required for a match.          // so now buffer will contain         // [elementk, ... , elementk+n]         // where buffer[0] < ... < buffer[n]     }     do {         last = buffer[len(buffer)]         ...         first = buffer[0]              Pattern.match(first, ... , last)         buffer.pop_front() // remove the first element         buffer.push_back(data.pop_back()) //add another element to the back               } while (!data.isEmpty())          ...      Anyway, that's a basic idea of what I have going on. The problem is that the way I'm doing it now, I have to reiterate through the loop to apply another pattern. (buffer sizes differ) It just seems inefficient to do that. Also, what happens when there's no more data in the buffer and it's not evenly divisible by the number of elements needed by a match?


title: Why do old programming languages continue to be revised?

text: This question _is not,_ "Why do people still use old programming languages?" I understand that quite well. In fact the two programming languages I know best are C and Scheme, both of which date back to the 70s. Recently I was reading about the changes in C99 and C11 versus C89 (which seems to still be the most-used version of C in practice and the version I learned from K&R). Looking around, it seems like every programming language in heavy use gets a new specification at least once per decade or so. Even Fortran is still getting new revisions, despite the fact that most people using it are still using FORTRAN 77. Contrast this with the approach of, say, the typesetting system TeX. In 1989, with the release of TeX 3.0, Donald Knuth declared that TeX was feature- complete and future releases would contain only bug fixes. Even beyond this, he has stated that upon his death, "all remaining bugs will become features" and absolutely no further updates will be made. Others are free to fork TeX and have done so, but the resulting systems are renamed to indicate that they are different from the official TeX. This is not because Knuth thinks TeX is perfect, but because he understands the value of a stable, predictable system that will do the same thing in fifty years that it does now. Why do most programming language designers not follow the same principle? Of course, when a language is relatively new, it makes sense that it will go through a period of rapid change before settling down. And no one can really object to minor changes that don't do much more than codify existing pseudo- standards or correct unintended readings. But when a language still seems to need improvement after ten or twenty years, why not just fork it or start over, rather than try to change what is already in use? If some people really want to do object-oriented programming in Fortran, why not create "Objective Fortran" for that purpose, and leave Fortran itself alone? I suppose one could say that, regardless of future revisions, C89 is already a standard and nothing stops people from continuing to use it. This is sort of true, but connotations do have consequences. GCC will, in pedantic mode, warn about syntax that is either deprecated or has a subtly different meaning in C99, which means C89 programmers can't just totally ignore the new standard. So there must be some benefit in C99 that is sufficient to impose this overhead on everyone who uses the language. This is a real question, not an invitation to argue. Obviously I do have an opinion on this, but at the moment I'm just trying to understand why this isn't just how things are done already. I suppose the question is: > What are the (real or perceived) advantages of updating a language standard, > as opposed to creating a new language based on the old?


title: Is doctrine 2 fast enough?

text: I need to build a social network that is expecting very high traffic, 10k - 50k + registrations in a day, not even including visitors, pageviews, image uploads, etc..., a lot of database activity. We have a solid quad core dedicated server right now with 8GB ddr3 and 2tb hdd sata. Will doctrine be to slow as far as queries and load time to handle such a high traffic website?


title: How can I apply Six Sigma in a software development environment?

text: I am a Java developer, but I was asked to learn about applying Six Sigma with the goal of increasing our organization's profits. I have read that Six Sigma can be applied in all environments, but I'm interested in the nuances of applying it to software development. Which concepts of Six Sigma can be applied to a software development environment and how can I effectively apply them? Are there any resources that discuss Six Sigma being applied specifically within a software development environment?


title: Practical Use of Depency Injection (IoC) Container

text: I am creating a MVC-ish framework in PHP. I am trying to implement a DI Container to allow the creation of controller objects (among others). My MVC framework is pretty typical. Each module (or component if you wish) has a controller responsible for executing requests. These module controllers typically extend a base `Controller` class. All controllers will accept `Request` and `Response` objects as arguments. The confusion occurs because some controllers may need different arguments in order to function. For example: Many controllers will need a `Database` object; Controllers which send mail may need a `Mailer` object; while a controller which logs data may need a `Log` object. The DI Container will contain the recipes for creating all these controllers. My front controller needs to be able create any of these controller objects, as specified by a request. Furthermore, each controller needs to be able to create any other controller. **How do I get my front controller and module controllers to access the DI Container in a way that doesn't result in a dependency on the DI Container by each controller?** I actually don't mind if the front controller is dependent on the container, I am more concerned about the module controllers. Thanks,


title: How can I hide confidential data in my open source project?

text: I have an open source project that uploads files to DropBox among several file hosts. Right now I am screen scraping for DropBox. To use their API, I have to hardcode a SECRET KEY provided by them to me for OAuth authentication. But I'm afraid that the key won't be secret if it is visible plainly for anyone to see. It is 'possible' for someone malicious to use my key to upload a virus to a user's account (who already allowed access to my app) that will spread to their pc (if they had desktop sync enabled) and to others' pc (if they had shared folders) and so on. :O I found this unanswered question that has the same problem as mine. But I would like to know generally how one would hide confidential data in an open source project. I have one idea.   * Have a placeholder in the source code like "<SECRET KEY HERE>" and fill it only when building binary for release? (yuck!) Any decent idea?


title: What is 'Asp.net Handler'?

text: I read in a book 'beginning asp.net 4.5 in c#' that when some one type the URL of the asp.net website, the browser send the request to the server and if the server find any ASP.NET markup or controls then it will leave this or map this to something called asp.net handler. So, what is it this handler? Is it the server itself or another thing in the server?


title: Extreme Programming Daily Commits

text: Isn't daily commits (committing all changes before going home) an XP practice? What are the benefits of following this? What are the risks of not following this?


title: The modern way to perform error handling...

text: I've been pondering this problem for a while now and find myself continually finding caveats and contradictions, so I'm hoping someone can produce a conclusion to the following: ### Favour exceptions over error codes As far as I'm aware, from working in the industry for four years, reading books and blogs, etc. the current best practice for handling errors is to throw exceptions, rather than returning error codes (not necessarily an error code, but a type representing an error). But - to me this seems to contradict... ### Coding to interfaces, not implementations We code to interfaces or abstractions to reduce coupling. We don't know, or want to know, the specific type and implementation of an interface. So how can we possibly know what exceptions we should be looking to catch? The implementation could throw 10 different exceptions, or it could throw none. When we catch an exception surely we're making assumptions about the implementation? Unless - the interface has... ### Exception specifications Some languages allow developers to state that certain methods throw certain exceptions (Java for example, uses the `throws` keyword.) From the calling code's point of view this seems fine - we know explicitly which exceptions we might need to catch. But - this seems to suggest a... ### Leaky abstraction Why should an interface specify which exceptions can be thrown? What if the implementation doesn't need to throw an exception, or needs to throw other exceptions? There's no way, at an interface level, to know which exceptions an implementation may want to throw. So... ### To conclude Why are exceptions preferred when they seem (in my eyes) to contradict software best practices? And, if error codes are so bad (and I don't need to be sold on the vices of error codes), is there another alternative? What is the current (or soon to be) state of the art for error handling that meets the requirements of best practices as outlined above, but doesn't rely on calling code checking the return value of error codes?


title: Cost of setInterval in Javascript

text: I've got some code that I want to run when certain HTML elements are added to the page.   To do this, I have a "runOnRender" function:               runOnRender: function (func, args, interval) {                 var that = this;                 var guid = hb.getGuid().substr(0,7);                      var checkFunc = function () {                     if (that.$el.height() > 0 && that.$el.width() > 0) {                         clearInterval(that[guid]);                         that[guid] = 0;                         func.call(that, args);                     }                 };                      this[guid] = setInterval(checkFunc, interval || 200);             }      Setting the interval to 200 is about as high as I can go before there is often a noticeable lag in the event firing. The last thing I want is my users wondering why a button just got clicked or seeing a label text change, etc. Here's the catch. It is entirely possible that this "runOnRender" will be set up.....but the User never causes the action that makes the HTML element in question hit the DOM....which means that this code would just keep infinitely running as long as the page is open. I'm on a nice, powerful, dev machine....so I'm wondering what the cost of this code is and whether there is a better way.


title: Programming Languages "Higher Level" Than Python

text: In general, I have been presented with these sorts of heirarchies for programming language abstraction: Assembly < C < C++ < Java < Python where C abstracts less than C++ and so on. You could also consider this on a compiled vs translated vs interpreted language basis (which is usually how this topic is considered, putting C and C++ together), but I'd like to think in terms of levels of abstraction for this question. Lisp dialects, my favourite language, seem to vary on implementation and fit in between these, along with languages like Haskell and Prolog, but languages like Ruby and Python are undoubtedly at the top. Are there languages that abstract even more significantly than Python or Ruby? Are these languages desirable to use? Having started with Lisp/C++, I was not expecting to so thoroughly enjoy Python and Ruby. I was also not expecting them to make my coding so much better, since you can use features like Scipy's Weave to use Python to do high level computation for most things and then low level computation for bottleneck code. So I'm wondering if there are even higher level languages available of which I'm unaware and that I should try out.


title: Would this violate any copyright issues?

text: I am currently publishing a paper on skin detection. However, I need to find the appropriate histogram bin size for each colorspace. I recently came upon a paper that published what it found to be the ideal bin size. The paper can be found at: http://www.inf.pucrs.br/~pinho/CG/Trabalhos/DetectaPele/Artigos/OPTIMUM%20COLOR%20SPACES%20FOR%20SKIN%20DETECTION.pdf. I am specifically talking about Table 1. If I cite the source, would it be okay for me to use data from the table? Note that I cannot contact the author of the paper.


title: What is the preferred Internet media type of a RESTful POST request?

text: Is there a preferred/recommended Internet Media Type for RESTful POST requests? For example, if I want to add a new user, should I send the data as a URL encoded string like:               name=Foo&otherData=Bar      or does REST recommend I send the data as whatever format the response is going to be sent as (e.g. JSON/XML)?               <user>       <name>Foo</name>       <other-data>Bar</other-data>     </user>


title: why create mobile applications for web oriented programms, if it's just possible to use websites?

text: There are a lot frameworks on the market who wrap actual websites into mobileapps. I found myself thinking about the question - why is it needed to create mobileapps if it's possible to just having mobile version of the site?


title: Is this considered an implementation of the Template Method design pattern?

text: Please consider a `StringBank` class. This class holds a list of Strings and can `return` them to the client. It's code (irrelevant stuff omitted):               abstract class StringBank{              List<String> strings;              public List<String> getStrings(){                  for(String string : strings){                 if(!stringValid(string)){                     strings.remove(string);                 }             }                  return strings;              }              public abstract boolean stringValid(String s);          }      As you can see, `stringValid` is an abstract method, meant to be implemented by the subclasses. This way subclasses serve as 'filters' of the string bank, filtering out invalid strings (e.g. a particular subclass may return `false` for strings that end with an 'a'). My question is: is this considered an implementation of the Template Method design pattern? The purpose of Template Method is to define steps of an algorithm in an abstract superclass, and have the subclasses define the implementation of some of these steps. Usually, the 'template method' - where the algorithm is defined, would look something like this:               void algorithm(){         step1(); // implemented in this class         step2(); // implemented in this class         step3(); // abstract method, implemented in subclasses.         step4(); // implemented in this class     }      However in `StringBank`, the algorithm is very simple, so it only involves one method call: `stringValid()`. The rest of the steps of the algorithm are defined in the method itself (looping through the strings, removing strings and returning them). **`getStrings()` doesn't really 'look like' a 'template method', so I'm not sure if this is considered a Template Method pattern implementation.** The algorithm could be described as:   1. For each string: 1.1. Check if valid. _(implemented by the subclasses)_. 1.2. If invalid, remove from list.   2. Return list of strings. Would you define the implementation I described as an implementation of the Template Method design pattern, even though `getStrings()` doesn't 'feel' like a classic template method?


title: Do you use unit tests at work? What benefits do you get from them?

text: I had planned to study and apply unit testing to my code, but after talking with my colleagues, some of them suggested to me that it's not necessary and it has a very little benefit. They also claim that only a few companies actually do unit testing with production software. I am curious how people have applied unit testing at work and what benefits they are getting from using them, e.g., better code quality, reduced development time in the long term, etc.


title: validating APIs

text: We have a series of hardware and we have decided on a common API to be given to the customer for use. The customer will use this API in order to program the hardware. The API includes functions for establishing a connection with the h/w like X_Open,X_Close,X_SetConfig, X_GetConfig, no of hardware connected, error handling with the corresponding structs to be filled by the API or the customer. The hardware will ofcourse be validated independently also. What strategies can I use to validate this API ? We want to test this API i.e it works as expected for instance we are actually able to setConfig in the h/w or get no of devices on the bus or if the API function X_Open is called , the function is able to establish a connection to the hardware as expected or say API function X_GetNoDevices returns no. of present devices on the bus. We want to validate that all API functions work as described to the customer


title: How to design an algorithm-heavy and object-light application

text: Other than vertices, edges, faces and meshes, my geometry processing project/application has only about half a dozen other entities such as curves on surfaces. However the majority of my code is dedicated to geometry processing. Being a naive programmer when I started this project, I implemented the various geometry processing algorithms as methods of the few classes that I had. As a result, some of my classes are now very large because they implement geometry processing algorithms (and therefore span up to 5 *.cpp files) -- very bad. In some cases I also implemented the algorithms as classes in their own rights. As such I now have classes that are not really entities. I now have a problem with this because I now believe that classes should be instantiable entities, and their methods the things that they do. Yet following this rule has led to large files. At the same time deviating from it has led to classes that do not make sense as instantiable entities e.g. a Geodesic class. Anyway I'm planning a redesign of this project and I'd appreciate advise on how to deign my classes. One of the options I've considered is to implement each algorithms as a collection of methods in a namespace. However as namespaces do not have instance variables, there will be lots of argument passing between the methods -- again not very nice.


title: Change my way of thinking in preparation for functional programming

text: When switching to a functional style of programming after coming from procedural and OOP, what things do I need to know upfront about "this new way of thinking"? How do you prepare yourself for diving in the FP world and get it first time around? What are the basics to learn and set straight first?


title: What's the best lesson you have learned in your career?

text: I think mine is "there's no such thing as a five minute job" - that programmers tend to be overly optimistic about development and that we should really think through a the implications before promising a quick solution to a problem and then diving in to code


title: Is it worth evaluating compiler optimization on trivial cases?

text: I'm currently testing Visual C++ 10 on some trivial pieces of code. For example, like this one (taken from here):               int main()     {         int i;         clrscr();         for(i=0,i++,i<=5;i++,i<=2;i=0,i<=5,i+=3){             printf("%d ",i);         }         return 0;     }      For the code above the compiler emits machine code that in effect does this:               clrscr();     printf("%d ",2);     return 0;      and this makes me happy. Sometimes the compiler emits really dumb code and then I file a Microsoft Connect feedback item. I have the following concern. Is testing a compiler on trivial code worth it? On one hand, we want real code to be compiled as good as possible, not some stupid sample snippets. On the other hand, compiler optimization is recursive in sense that if code B follows code A and the compiler can see that code B does nothing it can eliminate code B and eliminate whatever connected A and B logically and thus optimize (and maybe eliminate) code A better. And if the compiler fails to optimize away code B it will likely not be able to optimize code A either. So every improvement of generated code matters - better code at some point can mean better code elsewhere and this is beneficial. Is it worth testing compilers on trivial samples or are only tests on "real code" worthy?


title: Bogarting the Data Access Layer

text: Situation: The dba is an offsite contractor who keeps the entire DAL code checked out in TFS. It would be nice as the front end developer to be able to add columns, and tweak procs and whatnot, without having to rely on waiting for this dude to respond to your emails to do the work. Question: What would be a recommended solution/process that would allow for more rapid/agile development, while maintaining data integrity as well as peace love and happiness among the team?


title: Dynamic method creation in python

text: I have a class that will have a number of external methods that will all call the same smaller set of internal methods. So something like: obj.method_one(a, c) and obj.method_two(a, c) where obj.method_one calls obj._internal_method(a, c, y) and obj.method_two calls obj._internal_method(a, c, z). They're nearly identical but they have one argument at the end that differs on the internal call (which is a constant). I could just copy and paste a few times but I was wondering if theres any way to dynamically create these external methods.


title: I cant get myself to sit down and start coding

text: I spent the last 5 months working my regular job (qa) and developing an android application in the evenings. Now we were in two week vacation for Christmas and I spent the whole time developing my application and now I feel exhausted, I just cant get myself to sit down and start writing code again. It just feels like a huge mountain of weight that I have to lift, even thinking about it. Is this normal? Will this get worse with time? Im in the IT industry for 9 months now, 6 of them, like I said were very intensive. 25 year old. Also, I think its important to mention that I learn extremely fast and intensively and I get ahead of myself all the time. Am I going to burn my potential off? PS: Why would someone downvote my question? what wrong or bad have I done? Which rule have I not obeyed?


title: What is the best way to do offline failover of a desktop based client that uses a web service?

text: I have three incoming projects that share a common problem: > they need to have the logic on a web system and they need a local > application (e.g. point of sale) that communicates with such system through > a RESTful web service. ### My Solution The solution I managed to come up with is to implement in the desktop application message queuing to store operations while the service is offline, more precisely, asynchronous message queuing. However, that is the easy part (if such is the best solution). I'm also concerned with data syncing and conflict resolution. The main system needs to be web based since a web app is required for reports and monitoring by the stakeholders, and the web services would handle requests for several establishments. The desktop clients (preferably thin) will be implemented with Java (more specifically Netbeans) and the web system with Symfony2. Two of the projects require hardware integration for the client, so making the desktop application with web technology (e.g. Appcelerator Titanium) could be a major pain. ### My Question   1. What is a better solution that scales, meaning maximum efficiency with minimum effort (and preferably no additional costs, like buying a backup server for local operation) ?   2. Who else has dealt with this before? How did you solve your problem? What lessons can you share?   3. How did you deal with synchronization?  **Edit: Added a missing part to my question in point #3**


title: What is Mozilla's new release management strategy?

text: I saw today that FireFox released a new version (5). I tried reading about what was added and ran into this link: http://arstechnica.com/open- source/news/2011/06/firefox-5-released-arrives-only-three-months-after- firefox-4.ars It states that: > Mozilla has launched Firefox 5, a new version of the popular open source Web > browser. This is the first update that Mozilla has issued since adopting a > **new release management strategy** that has drastically shortened the > Firefox development cycle. I find this very intriguing - any idea what this new strategy is?


title: Application connecting to database server

text: I'm working on an application which requires user credentials and so on. So a database is required on the backend. What is the best practice to connect to a database without hardcoding your password into it? The program could be reverse engineered and one might get the password which is something we obviously don't want.


title: Data service API design

text: We're designing a data service that will store a large number of statistics about stocks, including historical data. The client will be a web application, which will need to pull various bits of data to show in different places on the site. Since the different places need to show different sets of statistics, it's not sensible for the service to simply offer one method which retrieves all the data that we have. Since there are so many different types of statistics, the service isn't aware of the type of each one and simply stores them by key. We previously tried to deal with this by having a number of methods which would return data objects with varying levels of detail, for example getBasicStockInfo, getStockInfo, getFeaturedStockInfo, getStockDetails. The trouble I found with this was that it became tedious to add new items of data to the objects (need to change server code), and each one would get bloated over time as fields are added for some specific locations on the front end. On the other hand, it would be impractical to have a method for each location on the front end that returns the specific data that's needed in that location. Does anyone have any ideas of how best to handle this situation? One thing I'm considering is that the client would have to send a list of data keys for the data it wanted, and would get back a map of the statistics. I'm not sure if this is the way to go though, as the weight of parameters would get pretty heavy with the same ones being passed repeatedly from each location in the web app.


title: What's the best practice to do SOA exception handling?

text: Here's some interesting debate going on between me and my colleague when coming to handle SOA exceptions: On one side, I support what Juval Lowy said in Programming WCF Services 3rd Edition: > As stated at the beginning of this chapter, it is a common illusion that > clients care about errors or have anything meaningful to do when they occur. > Any attempt to bake such capabilities into the client creates an inordinate > degree of coupling between the client and the object, raising serious design > questions. How could the client possibly know more about the error than the > service, unless it is tightly coupled to it? What if the error originated > several layers below the service—should the client be coupled to those > lowlevel layers? Should the client try the call again? How often and how > frequently? Should the client inform the user of the error? Is there a user? > By having all service exceptions be indistinguishable from one another, WCF > decouples the client from the service. The less the client knows about what > happened on the service side, the more decoupled the interaction will be. On the other side, here's what my colleague suggest: > I believe it’s simply incorrect, as it does not align with best practices in > building a service oriented architecture and it ignores the general idea > that there are problems that users are able to recover from, such as not > keying a value correctly. If we considered only systems exceptions, perhaps > this idea holds, but systems exceptions are only part of the exception > domain. User recoverable exceptions are the other part of the domain and are > likely to happen on a regular basis. I believe the correct way to build a > service oriented architecture is to map user recoverable situations to > checked exceptions, then to marshall each checked exception back to the > client as a unique exception that client application programmers are able to > handle appropriately. Marshall all runtime exceptions back to the client as > a system exception, along with the stack trace so that it is easy to > troubleshoot the root cause. I'd like to know what you think about this.


title: GPL and OpenJDK: Questions regarding source headers

text: I have some legal questions regarding OpenJDKs source header:               /*      * Copyright (c) 1997, 2008, Oracle and/or its affiliates. All rights reserved.      * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.      *      * This code is free software; you can redistribute it and/or modify it      * under the terms of the GNU General Public License version 2 only, as      * published by the Free Software Foundation.  Oracle designates this      * particular file as subject to the "Classpath" exception as provided      * by Oracle in the LICENSE file that accompanied this code.     (...)        * Is it GPL-conform to define a comment-part of a source-file (in this case the header) as "must not be modified"?    * Do other GPL-licensed open-source projects derived from this sources need to obey this "statement"?   * Does Oracle really have a Copyright on these GPL-sources?   * Is it GPL-conform to state that it's **_only_** allowed to `modify [the software] under the terms of the GNU General Public License version 2`?   * What does this mean for GPLv3 open-source projects which are using these (possibly modified) sources?   * Do I have to fear editing (and publishing) this file (and maybe adding something to the file header) in my own GPLv3 open-source project?


title: Use Objective-C protocols like Java interfaces

text: I'm a Java developer moving to Objective-C. So far in Objective-C I've seen protocols used extensively to implement the delegate pattern, but I haven't seen then to add a layer of abstraction in the way one would use Java interfaces. My gut instinct is to use protocols to define a contract and add a layer of abstraction, so that I may later substitute a different concrete class. Is this idiomatic in Objective-C, or do people tend to just use `@interface` to define the contract for a concrete class and use it directly?


title: Do I have the wrong idea about software engineering?

text: Hello folks I have a question which's been raised by my latest job (rather intern). Just to put things into context - I'm 21 and I've finished my 2nd year of university before that I've had around 2 years of experience doing sys admin/QA jobs and basically I can say that I've seen how different IT sectors operated. Flash forward to present times and here's me landing an interning job at one of the premier research institution in the UK. What I have to do is create some internal tools using a mix of technologies - mainly AWS/Java/Bash - you get the picture. Everything is OK, I'm doing my job BUT I'm not happy. Why is that - because I'm expected to work in an ad-hoc matter. That is create things quickly, without spending time on designing. My manager explicitly said that it was expected to "rush" through problems as they arise and we essentially. As a consequence it turned out that things had to be re-done and re-engineer and they are still not perfect. As far as testing is concerned - keep it to a minimum, as long as it looks working then it is OK. Am I at fault to disagree with this way of conducting work? Is it wrong to want to think over the system as a whole, then focus on different components and see how they might inter-operate, to zero in on different "key points" which might turn out to be problematic in the future? Is it a crime to want to do a good job and not a "quick job"? Is it a mistake or wrong attitude to want to research the data structures applicable to a problem so that you can choose the best depending on a particular problem set? To the best of my understanding the "Engineering" bit in "Software Engineering" has got to do exactly with this - research your problem domain and come up with a informed solution then refine as necessary? I've been to an interview at an Arm's office in the UK and they showed me their SCRUM room and it looked they had pretty good idea as to how to manage their project - they had a backlog, they had metrics as to how long each issue might take to resolve - the usual things for SCRUM - completely different than the way things are run "here" Have I built a wrong idea about the software industry in general? I'd like to hear your input on that. I mean I "entered" software development purely because I want to create things - plain and simple, but I want to create quality things. I want to see my software used in various scenarios, I want to see it bullet proof - isn't that the driving force for all software engineers? I think everyone can be a programmer/coder by just learning the syntax but for me where the real fun begins is when you actually have to come up with a design which is doable in real world. I used to do my university assignments by just looking at them and directly start coding and could easily get marks above 75% and never really appreciated the "software development lifecycle" module. But now when I saw in the real world how bad it is to work without any formal process and the frustration that is inherent in situation where you don't know if the requirements are going to change tomorrow (oh, did I say that we don't have clearly defined requirement analysis?) I really like to believe I just landed a position where some people just needed a code monkey to do their dirty work and this is not the case how the software world operates at large.


title: Class Naming Conundrum

text: I am working on a personal project that works with databases, and in this project I have a set of classes that are _similar_ , so they inherit from a common base class. The problem I am faced with is that I have this nagging feeling that the names of the classes that derive from the base class do not really reflect what they actually are. Caveat: Please ignore the fact that this looks like a reinvention of the wheel. That's the point of the project. The common base class is called Entity. Its purpose is to serve as the base for:   1. Classes that describe the data returned by a SQL query or stored procedure, or    2. Classes that describe a SQL query or stored procedure and their parameters. Both of these classes are created by consumers of the assembly to describe the stored procedures and queries in their database, and the data they will retrieve from it. For example, these are designed to work against the Northwind database:               public class Employee : DataEntity     {         public int EmployeeId { get; set; }         public string LastName { get; set; }         public string FirstName { get; set; }     }          [Sql(@"SELECT [EmployeeId], [LastName], [FirstName]             FROM [Employees]             ORDER BY [LastName], [FirstName]")     public class SelectEmployee : SqlEntity     {         public int EmployeeId { get; set; }     }      As it stands, I am currently calling the first of these Data Entities, and the second SQL Entities. However, I am not entirely sure that these are fitting terms. For instance, are they actually _models_? Is there a better term that I am not considering? The assembly only considers public properties that have both a getter and a setter. The developer can add anything else to it if he or she needs to. So a Data Entity can be extended to include additional functionality. Any advice would be greatly appreciated. **EDIT** It's worth noting that you can also model stored procedures with this stuff (again, using a Northwind database stored procedure):               [Sql()]     public class CustOrderHist     {         [Parameter("@CustomerId", SqlDbType = SqlDbType.NChar, MaxLength = 5)]         public string CustomerId { get; set; }     }      The assembly automatically binds classes to stored procedures, and properties to parameters.


title: Where can I get free public raw data?

text: _In web development, a mashup is a web page or application that uses and **combines data** , presentation or functionality from two or more sources to create new services._ There are many sources for getting data (raw information). Governments are good examples.   However many of those cost and have complicated licensing. For instance SMHI in Sweden sells temperature data meanwhile our neighbor country Norway gives it away for free. One would say what kind of application are you building and what data do you need? I would say give me some interesting data and I will do a good mashup of it. I could just plot it on Google maps for instance. So the question is: **Where can I get free data?** Note: I'm not interested in data mining using a webcrawler! Please share your sources with me.


title: What to look for in someone to provide short-term cover for a lone developer?

text: Our intranet is running an in house developed ASP.NET application. In our team I am the only technical person so this means my role is everything from development to server administration to "the printer isn't working". In a couple of months once a major rewrite is finished I am taking a couple of weeks holiday and we need to get someone in to cover for this period. I am at a loss of what skill set we should be looking for to cover over a short term. Being a major upgrade there will of course be bugs, though it will be up long enough to deal with any that are particularly worrisome and/or common. From this point of view I'm thinking that given the short timescales getting in a developer would be the wrong choice (small bugs can wait, big bad bugs that area left would likely be the sort that experience and time to learn the system would be needed to fix, I am of course insisting on a laptop and VPN to deal with this if it happens). Looking this way I'm thinking that someone with server administration skills would be the preferable route (able to keep the servers up if they go down, restart services if needed etc), though it still leaves a lot of leeway in the specifics to look for. Also despite the above opinion on getting a developer, being able to look through the code to pinpoint where a bug is interacting with the servers could of course be useful. Half the problem is of course that there's lots to cover with nothing in particular standing out as the big area to focus on. Here's a breakdown of what we have, any advice or ideas would be greatly appreciated.   * In house ASP MVC2 application, includes some custom JavaScript on the front end   * Legacy ASP Classic (some areas of the intranet that aren't yet upgraded, running in tandem with the MVC application)   * Mediawiki install running on Apache and MySql on Windows   * Servers are running Windows 2008 and SQL2008   * Powershell backup scripts   * Simple C# reverse proxy (the intranet uses Windows authentication, we allow an external organisation access to the intranet so this proxy acts as their gateway and authenticates as a known generic user)


title: Is argument or parameter considered more appropriate for a function/method argument/parameter?

text: Hopefully the topic is not too confusing, I am curious though as lately I have seen more and more use of the word parameter to denote a function's passed in values, whereas during my studies I feel as if argument was used almost exclusively. Is parameter more appropriate as argument is more specific to a programs arguments specific at runtime whereas when a function is called, the values passed to it are parameters to the function itself? From a curious programmer.


title: Methodology behind fetching large XML data sets in pieces

text: I am working on an HTTP Server in Delphi which simply sends back a custom XML dataset. I am not following any type of standard formatting, such as SOAP. I have the system working seamlessly, except one small flaw: When I have a very large dataset to send back to the client, it might take up to 2 minutes for all the data to be transferred. The HTTP Server I'm building is essentially an XML Data based API around a database, implementing the common business rule - therefore, the requests are specific to the data behind the system. When, for example, I fetch a large set of product data, I would like to break this down and send it back piece by piece. However, a single HTTP request calls for a single response. I can't necessarily keep feeding the client with multiple different XML packets unless the client explicitly requests it. I don't have any session management, but rather an API Key. I know if I had sessions, I could keep-alive a dataset temporarily for a client, and they could request bits and pieces of it. However, without session management, I would have to execute the SQL query multiple times (for each chunk of data), and in the mean-time, if that data changes, the "pages" might get messed up, therefore causing items to show on the wrong pages, after navigating to a different page. So how is this commonly handled? What's the methodology behind breaking down a large XML dataset into chunks to save the load?


title: Is thıs code efficient always for finding array[max]?

text: I am trying to find max value of an array, firstly i am shorting my array min to max after that i am using array[array.length-1] Is this logic efficient in large arrays?               public static int findMax(int[] array){              Arrays.sort(array);              int max = array[array.length-1];              return max;     }//end method


title: How should XML subtree manipulation be handled in a public API?

text: I'm working on an API whereby a specific call would replace a subtree of an XML document—rooted at some element—with another subtree. The two options I'm considering for a response to this call are:   * Return the DOM   * Return the modified subtree In the interests of developing a standardized, stable API, I'd like to get this right. Is there a best way to handle this type of scenario? What are the benefits and drawbacks of doing it one way over the other? Would it make sense to offer both these options to API consumers?


title: Sending Data to a Specific Android Device

text: I am planning an application that includes a membership card functionality, where the user can place an order, either in the application or by phoning the vendor. Once the order is placed, especially in the case of a phone in order, what would be the best approach to having the vendor side communicate relevant details to a specific device. I have looked Android's C2DM, that doesn't seem to be the best method. I don't want to send messages/data to all devices with the application installed, only the specific device that placed the order.


title: Backquoted symbols, good or bad?

text: I'm designing a programming language which has three kinds of quoted entities: strings and characters as in C, and symbols (interned strings intended for use as lookup keys and such) which I consider one of the most endearing features of Lisp. Currently I have the following syntax for these:               "*" // String     '*' // Character     `*` // Symbol      which I quite like, but has a couple of potential problems:   1. I'm told that on some keyboard layouts, backquote is a nuisance to type.   2. Backquote and ' are not the most visually distinct of characters, and I have a few times found myself typing ' when I meant backquote. On my setup this is not a problem because I have UltraEdit syntax highlighting set up to show backquoted symbols in green so the mistake is instantly apparent, but of course I can't provide syntax highlighting for most of the editors people use, so at least in the early days most users won't have the benefit of that kind of special coloring. So, given these potential problems, I'd like to get some feedback on which option people consider preferable:   1. Keep the syntax the way I have it now.   2. Swap backquote and ', so that ' is used for symbols and backquote is used for character constants.   3. Use ' for symbols, @"*" for character constants (in e.g. the Linux kernel code, character constants are something like thirty times rarer than string constants, so it's arguably okay to give them slightly more verbose syntax) and backquote for something else, perhaps raw (most escape codes not interpreted) strings.   4. Use ' for symbols, @"*" for character constants and forswear the use of backquote entirely.


title: Suggest a best practice to create Constants class

text: There is a debate in between my team members about declaration of Constants class. We are moving the constant variables into separate class as like below               public class Contants     {           public const string StateId = "ST";           public const string CountryId = "CI";     }      few of my team members are suggested to declare the class as sealed to avoid overriding option, and few are suggested to mark it as static to avoid instance creation of constant class.   However I preferred to have it as Sealed with static constructor, since it will help us to initialize the read-only variables in future need. Please advice this..


title: Name for a tree where nodes hold a reference to their parent as well as their children

text: I am creating a tree where some nodes have a reference to their parent as well as their children. It feels like a tree version of a doubly linked list. Is there a name for this?


title: Synonyms for operators

text: In the case of a newly designed functional language, consider e.g. the _not equals_ operator, spelled `/=` as is common among functional languages. Of course this operator is also known as `!=` in C family languages, and `<>` in SQL et al. It would be easy to make the parser accept these as synonyms, in the hope of cutting down on the number of things for someone not very familiar with the language to trip over. But on balance is this a useful thing to do, or would it just add more confusion than it's worth? Most mainstream languages don't provide synonyms, probably on the basis that they're designed for programmers who are familiar with the syntax. But what if you're designing a scripting language, for scenarios in which many users will not be very familiar with it, and may be specialists in something other than programming? Does that tip the balance in favor of providing synonyms to make things easier for newbies?


title: Hacking Python "Requests" library.. How to start as an intermediate pythonista?

text: My question is conceptual, yet extremely vital for me. I'm an intermediate Python developer. I know fair enough about it, and actually use it on a daily basis. Now, I would like to transform my capabilities from a library/API user to "designer" one. I found that "Python Requests" library by **Kenneth Reitz** is an extremely good place to explore Python patterns and idioms. I need to learn to split a big problem into its essential `Modules`, define required classes/functions, and use them to work together. I lack such a discipline, and I'm starving to gain this knowledge. How should I dive into this library? It is **big** , with many modules (with logical names, of course), classes, and methods. I started to read the code, but I don't know where I am and what this portion of code is designed for.


title: How to assure client that we will complete our project and won't run away with the money

text: I have decided to work as a freelancer. I have developed a software and have successfully given the presentation demo. The client liked it and has agreed to implement the project in his organisation. But the client has asked me make it sure that I wont run away with the money without completing the project. The cost of project is high and it is not possible to complete it without acquiring the advance from the client. What are the practice that is usually followed ? I myself somehow agree with the client query. I know I will be able to complete the project. I do not intend to cheat. But how to prove it to client? What to do in such situation?


title: Static variable - Usage and Implications on Threading

text: I have some confusion regarding the use of static variables/references in a class. It feels like I may not have entirely figured out the implications of keeping something static. When I say a variable is public static, is it one instance of the variable per class or one instance per assembly? For example, I have a user control (say, for a WPF app). This user control has a public static variable that coordinates various things within the control. If there is a form in a client application that uses this user control, with multiple instances of this control per form, how many instances of the public static variable are created? (My guess is only one, and it is modified by every control). Now, I actually need each instance of the control to have one such variable, not one variable across all the instances of the control in that single form. Does using a singleton pattern, with a "lock" keyword solve this issue i.e will it create one variable per instance of the user control? If not, what issue does the singleton pattern solve? What are the options in solving this design problem? (Note: I have resorted to creating an internal non static global variable and passing it around carefully, instead of going the static route and its working fine. I am looking to see if there is another option.) (Please bear with me if the question sounds very naive or unresearched, I did read a bit before posting, but seem stuck on finding an answer that explains it very clearly to me.)


title: CANopen and CAN Driver

text: **CAN Driver** means application program that interacts with CAN hardware and helps in initializing setup and communication. **CANopen Stack** provides various APIs to deal with CAN communication. Now this is confusing me so please let me know: **Is CANopen Stack and CAN driver one and the same?**


title: Is it OK to pass the concrete client to a method on the concrete strategy?

text: When using the strategy pattern, is it good practice to pass `this` to a method on `this.strategy`? I have a strategy interface with one call, `TakeAction`. The idea is that TakeAction decides which of the several possible actions the Client should perform and then calls the appropriate method on the client. So in a concrete strategy, the `TakeAction` method might look like:               void TakeAction(IAbstractClient client)     {         if (client.IsBlah()) client.UnBlah(this.BlahValue1, this.BlahValue2);         else if (client.CanFoo()) client.Foo(this.FooValue);         else if (this.ShouldTwiddle()) client.Twiddle();     }      And in the client, the call looks like:               this.strategy.TakeAction(this);      Is this good form? Or is there a better way to do this? (Passing back a class with an enum describing the action and the values to pass to it seemed overkill.)


title: The keyword const and the linker file

text: If I declare in a header file, for example, `extern unsigned long * Ptr;` and the value of this pointer Ptr in the linker file. Will this adrress be 'constant'? Can I change its value ?


title: Are sessions secure for captcha on failed login?

text: I don't like writing open-ended questions but I have a quick security question. I have a PHP login script that shows a CAPTCHA on the third failed login attempts. The way I'm counting failed logins is by using session data. Is this secure? Is there a better way to do this? Maybe store the IP in a database table? I'm not really sure how bots and programs that try to use word list actually work. Thanks


title: Is it OK to repeat code for unit tests?

text: I wrote some sorting algorithms for a class assignment and I also wrote a few tests to make sure the algorithms were implemented correctly. My tests are only like 10 lines long and there are 3 of them but only 1 line changes between the 3 so there is a lot of repeated code. Is it better to refactor this code into another method that is then called from each test? Wouldn't I then need to write another test to test the refactoring? Some of the variables can even be moved up to the class level. Should testing classes and methods follow the same rules as regular classes/methods? Here's an example:                   [TestMethod]         public void MergeSortAssertArrayIsSorted()         {             int[] a = new int[1000];             Random rand = new Random(DateTime.Now.Millisecond);             for(int i = 0; i < a.Length; i++)             {                 a[i] = rand.Next(Int16.MaxValue);             }             int[] b = new int[1000];             a.CopyTo(b, 0);             List<int> temp = b.ToList();             temp.Sort();             b = temp.ToArray();                  MergeSort merge = new MergeSort();             merge.mergeSort(a, 0, a.Length - 1);             CollectionAssert.AreEqual(a, b);         }         [TestMethod]         public void InsertionSortAssertArrayIsSorted()         {             int[] a = new int[1000];             Random rand = new Random(DateTime.Now.Millisecond);             for (int i = 0; i < a.Length; i++)             {                 a[i] = rand.Next(Int16.MaxValue);             }             int[] b = new int[1000];             a.CopyTo(b, 0);             List<int> temp = b.ToList();             temp.Sort();             b = temp.ToArray();                  InsertionSort merge = new InsertionSort();             merge.insertionSort(a);             CollectionAssert.AreEqual(a, b);          }


title: Can you give me an example of your Continuous Integration development process

text: we are thinking of doing Continuous Integration with Nightly builds here. Some of our sticking points is when to do Code Reviews. Is anyone out there doing Continuous Integration with nightly builds AND doing code reviews? If you can give a brief outline of your process that would be great. For example, here's what we are doing now:   1. Developers attempt to check in code daily or as often as possible. Code does not have to be "done", it merely has to compile. They rebase their code with everyone else's changes at this time. Doing this often prevents us from merging nightmares.   2. Builds come out nightly, but QA only looks at the builds but doesn't write up bugs yet, they merely inform us of what they are seeing.    3. Every few days, we have an official release. Code is Reviewed. We write up a description of what is ready for testing, what isn't.    4. QA writes up what they find in the stuff we say is ready for test. The process starts over. So, what are we doing wrong? One thing I dont like, is that Code is checked in that isn't reviewed. I heard before, that code should only be checked in that's been reviewed, however, I'm not sure how to do that and still have programmers checkin code daily. if you guys can give examples of what your process is, I'd really appreciate it. Thanks.


title: Can you call any php model class in an MVC from the controller?

text: I'm creating a **simple MVC** at the moment and am wondering if it's 'correct' to be able to call any model class directly from the controller to get the data to send to the view? I have the following folder structure:               .htaccess     index.php     /controller     /model     /templates      I also have the needed model classes within the `/model folder`, at the moment I've tried playing with a `/model/model.class.php` to try and build all parts of the site but it's already starting to become huge and I think it might be better to completely cut it out. I'm thinking the better approach is to use:               elseif($_GET['type'] == "Profile") {         $profile = new thread($userId);         $comments =  $profile->getComments();         require "templates/profile.php";     }      The above is a brief example but is that how a controller could/should/might look or was the first approach better or am I completely missing the point of the model and controller communication?


title: Google Docs Scripting

text: I have about 10 google docs spreadsheets. I would like to add / process rows from each of them and display the summation of this data in a new tab in each spreadsheet. So if somebody adds a row to one of the spreadsheets, the summation tab should be updated in all of them. 2 questions:   1. Is this possible using google docs scripting?   2. What is the best way to share the same script and run it against all the documents?


title: "Undoing" an integer wraparound

text: I ran into an interesting theoretical problem a number of years ago. I never found a solution, and it continues to haunt me when I sleep. Suppose you have a (C#) application that holds some number in an int, called x. (The value of x is not fixed). When the program is run, x is multiplied by 33 and then written to a file. Basic source code looks like this:               int x = getSomeInt();     x = x * 33;     file.WriteLine(x); // Writes x to the file in decimal format      Some years later, you discover that you need the original values of X back. Some calculations are simple: Just divide the number in the file by 33. However, in other cases, X is large enough that the multiplication caused an integer overflow. According to the docs, C# will truncate the high-order bits until the number is less than `int.MaxValue`. Is it possible, in this case, to either:   1. Recover X itself or   2. Recover a list of possible values for X? It seems to me (though my logic could certainly be flawed) that one or both should be possible, since the simpler case of addition works (Essentially if you add 10 to X and it wraps, you can subtract 10 and wind up with X again) and multiplication is simply repeated addition. Also helping (I believe) is the fact that X is multiplied by the same value in all cases - a constant 33. This has been dancing around my skull at odd moments for years. It'll occur to me, I'll spend some time trying to think through it, and then I'll forget about it for a few months. I'm tired of chasing this problem! Can anyone offer insight? (Side note: I really don't know how to tag this one. Suggestions welcome.) **Edit:** Let me clarify that if I can get a list of possible values for X, there are other tests I could do to help me narrow it down to the original value.


title: Is java a good start to learn OOP?

text: I have good teacher who understands OOP. However, the language which he is expert in is Java and I don't want to learn Java. My question is, do you think if I learn OOP using Java I will waste my time? And do you think it is good to start to learn OOP?


title: How to detect achievements in gaming?

text: I mistakenly posted this to stackoverflow and now posting here based on a suggestion in on that site ... This is a very high level conceptual question. Say in a software application I have 4 different actions, for example: Upload, Share, Comment, and like And I want to give achievement badges to users like:   * Rookie - Upload your first 5 files    * Upload Junkie - Upload 20 files in 1 day    * Night Crawler - Upload a file after midnight    * Share-a-holic - Share 10 different files    * Likes-everything - Like 20 different files you get the idea. What is he best way to check and see if a user has achieved a particular achievement without having to compile the logic for achievement into my code? And .. - Retain the ability to Add new achievements post compile (xml or db) - Achievements must track specific actions, number of times, and additional criteria (like time of day) - Detection should be near real-time so the user notified almost instantly when an achievement is completed My biggest questions is, how do I detect these achievements being achieved? Do I: 1) Check after every action to see if ... (Most real time) 2) Have another program check the DB at all times against a set of rules? (Easiest) Is there another paradigm that I'm missing? I feel there definitely is because in many games (like jetpack for iOS for example), I'm notified of the achievement I have unlocked in the instant in which I unlock it which I found pretty impressive. Thank you