title: Difference between functional test and integration test

text: I am deeply confused the difference. I've read so many definitions and they always explain functional test as testing the requirement is satisfied. Well, that's just rephrasing the name `functional test`. That doesn't clarify the difference. I am interested in some real code to demonstrate the difference. Suppose we have a function in a library performs hashing:               def custom_hasher(scheme, val):         # use many hashing libraries...               def hasher(inlist, scheme):         """ Take a list and outputs the hashed values of a list. """              output = list()         for val in inlist:             output.append(custom_hasher(scheme, val))         return output      Now for a functional test, I am guessing we want to test `['a', 'b']` is returned as something like `['jask34sdasdas', 'asasjdk234sjdk']` given some scheme. But that's just about what an integration test can do! I know exactly what type input I want (I want good execution so I pass in a list), or I want it to raise `Object has no append method` exception if I pass in a dictionary. I can do that in both. Where's the distinction? Another example is some web app:               @logged_in   # only logged in user can do this     @route("/invite", method=['POST'])     def send_invite(request):        recp_email = request.data['recp_email']             # now do a bunch of logics before and after sending an email      So in my integration test, I will definitely do this over a network (have the server running). Send some request to this url. Same for functional test. How to draw a line? For this case, I can write a functional test that tests to find an email is sent by looking at the send log in some table. But that's a different function than what I am testing (the view `send_invite`). So I don't see how to differentiate the two. They both assert something. Please help.


title: What is the connection between literate programming and the semantic web?

text: I was (casually) researching semantic / ontology based approaches to technical documentation, when I stumbled upon this gem: > Literate Programming and the Semantic Web are ideas from different times, > which do have a connection. The linked paper, Literate Programming in XML by Norman Walsh, discusses XML technologies that are central to semantic web, however I fail to see the conceptual connection between literate programming and the semantic web _or_ ontology based documentation. Help?


title: Pseudocode for Brodal queue

text: I'm trying to find more resources regarding Brodal heap. All I found is a haskell implementation of Brodal-Okasaki heap, but I _think_ that they are skew heaps, is this correct? Furthermore, I'm illiterate in Haskell so that does not help much. Does anyone have (or know of) an Brodal queue implementation in pseudocode, C, C++, Python? Also please correct if my assumptions above are wrong.


title: Is my first employer expecting too much?

text: This is my first job as a programmer. I am working using the following technologies:   * ASP.NET   * C#   * HTML   * CSS   * Javascript   * JQuery I work for a firm which develops software for small banking firms. Currently they have their software running in 100 firms. Their software is developed in Visual Fox Pro. I was hired to develop an online version of this software. I am the only developer. My boss is another developer, the only other developer in the firm. Therefore, my employer has a total of two developers. My boss does not have any experience with .NET development. I have been working on this project for 8 months. The progress is there, but has been very slow. I try my best to do what my boss asks. But the project just seems too ambitious for me. The company has not done have any planning for the project. They just ask me to develop what their older software provides. So I have to deal with front end, back end, review code, design architecture, and more. I have decided to give my best. I try a lot. But the project sometimes just seems to be overwhelming. **Question:** Is it normal for a beginner programmer to be in this place?   * Are my employers just expecting too much of a new programmer?    * As a programmer, am I lacking skills one needs to deal with this? I always feel the need to work in at least a small team, if not big one. I am just not able judge my condition. Also I am paid very low salary. I do work on Saturday as well. Please, help to clarify my judgment. Any suggestions are welcome.


title: Aggregation vs Composition

text: I understand what composition is in OOP, but I am not able to get a clear idea of what Aggregation is. Can someone explain?


title: What is the industry definition of an interpreter (as opposed to a compiler)?

text: In my compiler design courses, I have learned about and worked with a clear academic definition of an interpreter and a compiler, with an interpreter being > a program Pi from a language M capable of taking a program i from a language > I and an input and executing i with the given input and the correct > semantics for I on a machine capable of running programs from M and a compiler being > a program Pc that, when given a valid program i from a language I as an > input, produces a semantically equivalent program o in a language O This definition would clearly put the usual execution of Java bytecode by a JVM in the domain of interpretation, no matter how much JIT compilation is done. (Of course, Java is also compiled before, from Java code to Java bytecode.) I have encountered opinions in discussions on this site that clearly and vehemently state the opposite, i.e. that Java Bytecode execution thingies are compilers. Since I am about to make the leap from academics to industry, I am a little bit confused here: Is the above definition of interpreters false from the viewpoint of industry people in general? Or is it just false for Java people? Is the view of Java as a fully compiled language an alternate, but minority view? Or just a few loonies? (PS: Please do not move this to cstheory. I have deliberately put this question here since I would really like to get the view of the professional industrial, not the academic community.)


title: What is the preferred way to protect ownership of one's code (e.g. copyright, licenses, etc)

text: I posted some open source code on soureforge, and someone got in contact with me stating they intended to use my algorithms for a commercial product. I don't want this to happen, what should I do? According to us copyright.gov site: "Your work is under copyright protection the moment it is created and fixed in a tangible form that it is perceptible either directly or with the aid of a machine or device." Which seems to grant some legal protection by doing nothing. I looked at getting an official copyright from them, and its more than I'd like to spend ($135). Is that what I need to get for my work? Or are licenses a cheaper and safe/legal alternative? Or something else? Or nothing at all?


title: You're hired to fix a small bug for a security-intensive site. Looking at the code, it's filled with security holes. What do you do?

text: I've been hired by someone to do some small work on a site. It's a site for a large company. It contains very sensitive data, so security is very important. Upon analyzing the code, I've noticed it's filled with security holes - read, lots of PHP files throwing user get/post input directly into mysql requests and system commands. The problem is, the person who made the site for him is a programmer with family and children who depend on that job. I can't just say: "your site is a script kiddie amusement park. Let me redo it for you and you'll be fine." What would you do in this situation? ## Update: I followed some good advice here and politely reported to the developer that I've found some possible security flaws on the site. I pointed out the line and said there could be a possible vulnerability for SQL injection attacks there, and asked if he knew about it. He replied: _"sure, but I think that to exploit it the attacker should have information on the structure of the database; I have to understand better"_. ## Update 2: I said that's not always the case and suggested he follows this Stack Overflow question link in order to deal with it properly: How to prevent SQL injection in PHP? He said he would study it and thanked me for telling him before. I guess my part is done, thanks guys.


title: Tender vs. Requirements vs. Solution Design

text: Conventionally, which of the above documents is deemed to hold the most weight when it comes to system acceptance? I recently had a conversation along these lines: It was argued that the initial requirements / tender documentation should be used to determine system acceptance. It was said that the solution design only serves to describe the way in which the system will solve the problem, not the problem it will solve. Furthermore, it was argued that if requirements are missed during solution design, the requirements should be referenced during system acceptance _and_ that if any requirements were missed then the original tender should be referenced. Conversely, I suggested that - while requirements may be based on the original tender - they supersede it once agreed with the stakeholders. Furthermore, during solution design, analysis is performed to address and refine these initial requirements, translating them into a system capable of meeting the actual requirements. Once signed off by the relevant users, this solution design should absolutely represent the requirements (by virtue of the fact that it's designed upon them) but actually supersedes them as the basis for system acceptance. Is one of the above arguments more valid than the other? _EDIT: Apologies for the ambiguous terms. In this situation, tender is the document the customer took to market when shopping for a provider - it includes details of all the high-level features they're looking for. Solution design is not a technical document, it's the functional specification._


title: Requirement refinement between two levels of specification

text: I am currently working on the definition of the documentation architecture of a system, from customers needs to software/hardware requirements. I encounter a big problem with the level of refinement of requirements. The classic architecture is : PTS --> SSS --> SSDD --> SRS/HRS with PTS : Purshaser Technical Specification SSS : Supplier System Specification SSDD : System Segment Design Description SRS / HRS : Software / Hardware Requirement Specification. Requirements from PTS are reworked in SSS, this document only expressed the needs (no design requirements are defined at this level). Then, the system design is described in SSDD : we allocate requirements from the SSS to functions from the design and functions are then allocated to component (Software or hardware) (we are still at the SSDD level). Finally, for each component, we write one SRS or one HRS. Requirements in SRS or HRS are refinement of requirements from SSS (and traceability matrix are made between these two levels). My problem is the following one : Our system is a complex one, and some of the requirements in the SSS needs to be refined twice to be at the right level in the SRS (means that software people can understand the requirement to make their coding). But, with this document architecture, I can only refine once the requirements from the SSS. The second problem is that only a part of the requirements from the SSS needs to be refined twice. The other part only need one refinement. On the picture below, the green boxes are requirements at the right level for SRS or HRS. And purple boxes are intermediate requirements which can not be included in SSS since they are design requirements. Where can I put these purple requirements ?? Is there someone who has already encountered this problem ? Should I write two documents at SRS level ? Should I include intermediate requirements in SSDD ? Should I includes the two refinement levels (purple and green) in the same SRS document (not sure that's possible since a SRS is only for one component) ??? Thanks for your help and expertise ;-) ![Requirement refinement](http://i.stack.imgur.com/3xHyM.png)


title: Why were annotations introduced in Spring and Hibernate?

text: I would like to know why were annotations introduced in Spring and Hibernate? For earlier versions of both the frameworks book authors were saying that if we keep configuration in xml files then it will be easier to maintain (due to decoupling) and just by changing the xml file we can re-configure the application. If we use annotations in our project and in future we want to re-configure application then again we have to compile and build the project. So why were these annotations introduced in these frameworks? From my point of view annotations make the apps dependent on certain framework. Isn't it true?


title: How much should I worry about modeling/analyzing a web application?

text: I'm developing kind of a modern web application - scalable, robust and fast. I need to develop it as fast as I can. How much should I worry about the analysis phase or writing UML diagrams or ER diagrams for it? And what should be the flow on that? What should I start drawing?


title: Should I bother to write unit test for UI/UX Components?

text: So I am building an application with Angular and have started to get into UI testing with DalekJS (http://dalekjs.com). As I have been writing these tests I have been thinking to myself, should I even bother with writing unit test that that are UI/UX components. Now my angular services generally don't have anything to do with the DOM or directly rendering stuff on the page so those I unit test and it make sense however angular directives are components that render things directly to the page and writing unit tests seems like 1. It is not an effective way to test UI/UX components and 2. It would overlap with UI/UX Tests. For point #1, unit test (at least ones I have seen) don't actually write anything to a browser and render it. For thing that require DOM, you generally mock the DOM in a variable and use that to test whatever you need to test. If you have an error with a test, you can't load it up in a browser and play around with it like you could with UI/UX tests (which in my experience runs against code that is the true application that renders and everything). For point #2, one of my directives has a property called contentVisible. Now I can write a unit test that make sure that property is the correct value at certain points but that really don't not test what I truly want to test because even if contentVisible is set to false, the content still might be rendering to the screen which UI/UX test would pick up. Is it still worth the effort to write unit test for UI/UX Components where UI tests would be able to pick up everything the unit test would plus also do a better job since it can test what is actually rendered? **Exception** The one exception case where I would need a unit test is for certain ajax requests. For example, making sure an ajax request is not made of that an ajax request that does not make and changes to the UI are things that can only be tested with unit tests.


title: Distributing cryptographic software on GitHub

text: I am developing a cryptographic program and i am planing on distributing it using GitHub, But there are some regulations on the export of cryptographic software, how do make myself not liable if someone takes it out of the county? what disclaimer should i include with my software when i distribute it?


title: What would be a good "umbrella" term for HTML, CSS, SQL, JavaScript and the like?

text: There appears to be a pretty clear consensus on the question about whether HTML and CSS are programming languages. They are not. HTML is a markup language and CSS is a stylesheet language. You could probably also argue that SQL isn't really a programming language either, and JavaScript is as the name implies more a scripting language than a programming language. However, what's a good "umbrella" term for these? Could i just say they are "technologies"?


title: How to factor out data layer in nopCommerce and replace MS SQL with RavenDB?

text: I am new to nopCommerce and ecommerce in general but I am involved in an ecommerce project. Now from my past experiences with RavenDB (which mostly were absolutely pleasant) and based on the needs of the business (fast changes with awkward business workflows) It seemed to be an appealing option to have RavenDB handling all sort of things related to the database. I do not understand design and architecture of nopCommerce fully so I did not reach to a conclusion on how to factor data parts, since it seems the services layer actually does not abstract data-layer concepts away; like bringing in EF working model to other layers. I have found another project which used NuDB as it's database as a nopCommerce fork. But it did not help because NuDB still has the feeling of a RDBMS and is not as different as RavenDB. Now first how can I learn about the internals of nopCommerce (other than investigating the code)? It's workflows? It's conventions? Second has anyone tried something similar before with a NoSQL database (say like MongoDB or RavenDB)? Is it possible to achieve this in a 1 (~2) month time frame? Thanks in advance;


title: What is the "Free Monad + Interpreter" pattern?

text: I've seen people talking about _Free Monad with Interpreter_ , particularly in the context of data-access. What is this pattern? When might I want to use it? How does it work, and how would I implement it? I understand (from posts such as this) that it's about separating model from data-access. How does it differ from the well-known Repository pattern? They appear to have the same motivation.


title: Mutual observer pattern in Java

text: I want to improve my multi-threading and design pattern skills. As such I'm designing an Instant Messaging server. I'm writing the Server first. My plan so far is to have Client "Proxy" Classes to handle the socket connection for each Client. I want to have an "Exchange" Class that takes a message from a Client Proxy and hands it to the recipient Client Proxy. I was thinking of having both the Client and Exchange observe each other in this situation via the Observer Pattern. Mutual observers as it were, with Client Proxy and Exchange being Observer and Subject. On further thinking, should I instead have just the Exchange be the Observer and the Client Proxies as multiple Subjects for the Exchange? \-- Further thoughts It seems people quite like the idea of mutual observation between Proxy and Exchange. I was planning on each Client Proxy running in a separate thread. Would the Exchange become the bottleneck if there's only one Object? It sounds to me like I might need a pool of exchange objects, but I'm unsure how that would then map to the Observer pattern, even if I had some kind of broker in front of my pool of workers.


title: Memory allocation of Classes that don't have any global data and locks

text: static void Main(string[] args)         {             var c2 = new Class2();             var c3 = new Class3();             var c1 = new Class1(c2, c3);             c1.Method1();         }              class Class1         {             readonly Class2 _class2;             readonly Class3 _class3;             public Class1(Class2 class2, Class3 class3)             {                 _class2 = class2;                 _class3 = class3;             }             public void Method1() {                 _class2.PerformM1();                 _class3.PerformM2();             }         }         class Class2         {             public void PerformM1()             {                 //do some operation             }         }         class Class3         {             public void PerformM2()             {                 //do some operation             }         }      **Question based on above code:**   1. How much memory does object of Class1 has when it is created?   2. Does any memory increases or decreases when I perform c1.Method1(); keeping in mind that none of the classes have any global fields that might acquire any space. * * * **Edit** Expanding with one more question:   1. If creating new objects of Class1 and calling methods of c1 object does not involve much memory usage, then is it correct to say that I don't need a lock in the above provided sample code.  I can simply create n number of objects and assign individual object to individual Task( or thread)?


title: Is choosing ASP.NET WebForms to design web applications now a bad practice?

text: I have no time to code in MVC and jQuery, I just want this job to "get done", and honestly I like WebForms after 3 years of MVC programming. So my question is, technically, is it bad practice to choose ASP.NET WebForms over MVC ?


title: External libraries licensing

text: The problem I have might seem trivial for some of you but in general I have a question about all those "free" software licenses (mainly for PHP libraries). Let's assume that I want to create project for end-user and I want to sell it to them and if possible encrypt my source code. For example for Zend Framework licence is New BSD License and for Laravel it's MIT license. On Zend framework there is such short info: > Redistributions of source code must retain the above copyright notice, this > list of conditions and the following disclaimer. > > Redistributions in binary form must reproduce the above copyright notice, > this list of conditions and the following disclaimer in the documentation > and/or other materials provided with the distribution. but it means nothing for me. What does it mean the first one? Should I simple download Zend Framework and put in directory and when I don't do anything with it I can forget about it or maybe I should tell my client that I used framework and my software may not working because > THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" > AND ANY EXPRESS OR IMPLIED WARRANTIES ... I really don't understand how those licenses work and what are differences between those licenses. Could you provide me some help or external resources where this issue is explained in a simple way?


title: Data structures for bioinformatics

text: what are some data structures that should be known by somebody involved in bioinformatics? I guess that anyone is supposed to know about lists, haseshes, balanced trees etc, but I expect that there are domain specific data structures. Is there any book devoted to this subject? Thanks, Lucian


title: Get a Programming Internship if you don't know programming? Learning instead?

text: Is it possible to get an internship to learn programming if you've say only had one classs in visual basic? For example, I want to learn any programming language, but I've only taken 1 class in visual basic and SQL....can I be at a company to learn on the job?


title: Format for getting clear directions on data paramters from users

text: As part of my job, I regularly get ad-hoc requests from users for snapshots of our very large database. However, there's no fixed format for delivering these and they usually come through in the form of bullet-pointed text, for example:   * All customers    * All active in last 0-24 months (including non-contactable customers)    * All committed In this instance, "committed" is a flag, and "active/non-contactable" is both a text-based status and a dynamic status based on their last purchase. So this request could be interpreted as:   * All customers who made a purchase in the last 24 months, regardless of status   * All customers who have a "active" or "non-contactable" status regardless of last purchase.   * One of the above and then "either" having a committed flag, or "and" having a committed flag. I won't labour the point - you see the problem. And it's worth adding that the possible range of parameters is quite large. Normally I have to talk to the requestor and go through a rigmarole of explaining the problem and trying to clarify the requirements. This situation can't be that uncommon. Is there a more effective way of capturing these details, with a checkbox-style grid or other visual aid? Does anyone have any examples of experience of useful solutions?


title: Is the "exposer (hack) pattern" a newly identified pattern or does it have another name?

text: **EDITED FOR CLARIFICATION** In the past, I have seen a whole manner of resolutions and fudges. Some really stand out. One particular resolution that I initially thought of as a fudge possibly deserves a category of its own. It could be considered a hack or a pattern, as a design pattern is just a piece of reusable code. So, it still conforms to the definition: http://en.wikipedia.org/wiki/Software_design_pattern It possibly already has a name but I have not seen it in the literature. I was wondering if anyone knows another name for what I labelled the "exposer (hack) pattern". I have included an example of it below. This code is used to expose data that is not available to a data source. Instead, the results are not generated until a data bind method is called. Unfortunately, these results are not stored anywhere in the data source after execution. This is due to an oversight (or bad design) in the third party API. So, the results are passed a repeater to store locally, before returning these out as a populated PageDataCollection:               public static PageDataCollection Search(this SearchDataSource searchDataSource)     {                 PageDataCollection results = new PageDataCollection();                      //This is a dummy repeater whose only purpose is to provide a way of                 //iterating over the search results                 Repeater dummy = new Repeater();                      dummy.ItemDataBound += delegate(Object sender, RepeaterItemEventArgs e)                 {                     if (e != null && e.Item != null && e.Item.DataItem != null)                     {                         PageData pageData = e.Item.DataItem as PageData;                              if (pageData != null)                         {                             results.Add(pageData);                         }                     }                 };                      dummy.DataSource = searchDataSource;                      dummy.DataBind();                      return results;             }


title: Taxonomy / Classification of real world objects. Development suggestions

text: I have to develop a taxonomy/classification program based on classification algorithms and i would like to have some suggestions. The aim is to help the one using the program to categorize an object (could be a plant, a coin, an animal,...) and to teach what to look for in every step. The program is likely to be coded in PHP. The algorithm also should be able to be module based (multiple types of classification can exist at a determinare level and types of classification should be interchangeable). Example: ![Example of classification](http://i.stack.imgur.com/N8rrC.jpg) Should the program/algo be object oriented? can it be imperative (if/else, case)?


title: Solution for multiple versions of one Software

text: I'm sorry if the title is a little hard to get. I've never built an entire big software my self, just some small apps in my free time, i was more familiar with the do-what-my-boss-told-me things. And our approach is a little amateur, obsolete also (Foxpro 8.0 and MS SQL 2000). Now i've started to work at another company and been assigned to build a software in C#.Net, but the problem is i'm not sure with the program's architecture My problem is, we're building a software. But we have variety of clients, and for example, we have a CalculateCostOfProduct funtion, and it might be different for each client. Says for party A, the function is :               function CalculateCostOfProduct()     return 5;       for party B :               function CalculateCostOfProduct()     return 10;       ... And there should be extra modules for specific needs also ! So there will be customized versions from the original standard. How should i manage this ? But we can't build different exe for different client! So please give me some ideas, or solutions that might solve this problem.


title: MVC: view/sidebar.php can load model?

text: I have a Route that activates a Controller which returns to me a page through a View. Let's call it **master page**. > route -> controller -> view [master page] The master page is divided into header, sidebar, body and footer. And as the sidebar can be loaded to other pages, and not only the master page, it has its own View file. However, the sidebar should receive the data from user, which would be obtained through a Model. And in theory, the Model could only be called by a Controller, who call the View, however, this View is the master page, not the sidebar. > [...] -> view [master page] -> view [sidebar] So I thought the possibilities were as follows, and the idea is to know whether it is right or wrong, or perhaps it is another way that I could not imagine.   1. **The Controller will load the data from the Model and apply the sidebar which, in turn, be applied to the master page.** The problem here is, in a "deeper" case, it would be extremely laborious and difficult to understand.   2. **The Controller run the Model, but send to the master page, which would be responsible for loading the View sidebar and pass the information of the Model to it.** In this case, the work would be passing on information between the layers, so far as was necessary to take the information.   3. **The Controller will only load the View master page, which will load the sidebar, which will be responsible for executing the Model (inside View).** The problem here is that a View theoretically should not run a Model, just print your information already processed in the Controller. What would be the most appropriate way to make this process run correctly?


title: Separate servers vs local machine for builds, issue tracking etc on solo project

text: For solo projects, do you keep your build / management tools on your local machine, or on a separate server? If the server is not guaranteed to be safer or more reliable than my own machine I struggle to see the point, but maybe I'm missing some things. Note that I'm not debating the value of continuous integration or having a staging environment etc.. just the question of whether it exists on separate hardware.


title: Class design for calling "the same method" on different classes from one place

text: Let me introduce my situation: I have Java EE application and in one package, I want to have classes which will act primarily as cache for some data from database, for example:   * class that will hold all articles for our website   * class that will hold all categories   * etc. Every class should have some `update()` method, which will update data for that class from database and also some other methods for data manipulation specific for that data type. Now, I would like to call `update()` method for all class instances (there will be exactly one class instance for every class) from one place. What is the best design?


title: Do employers hiring for software jobs care about the classes you took in a Computer Science Masters program?

text: I'm torn between two classes right now for next semester (Software Design and Advanced Computer Graphics). I would enjoy Advanced Computer Graphics more, but I feel the software design class would help me when approaching anything I ever build for the rest of my career. I feel though I could just buy the book (I already have both books actually) of the Software Design class and go through it, if I wanted. But think it would be a bit tougher to pick up the Advanced Computer Graphics class on my own. So do employers look at the graduate classes you've taken to decide if you would be a good fit or not? I think, more importantly, what I'm wanting to know is if I wanted to work for a high-end software company like Apple or Google would a company like that be more impressed by someone that took software engineering classes or hardcore CS classes?


title: Best place to write SQL queries

text: I've been working on this project for my company. Currently I am embedding my SQL statements inside the program itself as and when they are needed. I do have two seperate classes -   1. QueryBuilder Class (Contains all the queries)   2. DbConnection Class (Executes the queries against the database, takes care of connectivity and such) What this does, is whenever I need to make the smallest adjustment in the query, I have to rebuild the entire application. I'm hoping there are better ways to deal with this. Somewhere I can store these queries, get them, pass the parameters **as command parameters** , then execute them and if I have to, change them without having to rebuild my application. There are a couple of ideas in my head.   1. Resource files.   2. Seperate DLL/Class files - Disadvantage is that, I'll have to rebuild that class if I make a change to that code. But the seperation does have it's advantage.   3. Text files, May get unmanageable when queries increase. I'd like to know if there is a better way to deal with this issue and if others have any way of circumventing this.


title: ViewController in programming

text: ViewController is a term for classes that handle views in a framework. This is especially used in MVC frameworks. I go through various projects, written by various programmers, who implement MVC in different ways. Especially, i get confused, about the relation between the MainView ( parent view ) and some CustomView ( widget etc) in the framework. **I personally pass reference of the MainView into the ViewController to be instantiated. All the subviews of ViewController are added to that reference of MainView. Additionally, ViewController itself is added as a child of MainView.** Like this : ![main-view and view-controller relation](http://i.stack.imgur.com/VkkVz.jpg) Want to know, if this is the right way to relate each other ?


title: Where to place the R code for R+Sweave+LaTeX workflow

text: I spent the last week learning 3 new tools: R, Sweave, and LaTeX. One question that came to my mind when working through my first project: Where do I place the majority of the R code? The tutorials that I read online placed the majority of the R code in the LaTeX .Rnw file. However, I find having a bunch of R calculations in the LaTeX file distracting. What I do find extremely helpful (of course) is to call out to R code in the LaTeX file and embed the result. So the workflow I've been using is to place 99% of my R code in my .R file. I run that file first, save a bunch of calculations as objects, and output the .Rout file once finished (to save the work). Then when running Sweave, _I load up that .Rout file_ , so that I have the majority of my calculations already completed and in the Sweave R session. Then my LaTeX callouts to R are quite simple: Just give me the XTable stored in 'res.table', or give me the result of an already-computed calculation stored in the variable 'res'. So I push towards the minimal amount of R code in the LaTex file possible, to achieve the desired result (embedding stats results in the LaTeX writeup). Does anyone have any experience with this approach? I'm just worried I might run into trouble further down the line, when I start really trying to load up and leverage this workflow.


title: Why don't testers and programmers like each other?

text: During my career as a programmer I've seen various programmers and testers, and many of them didn't/don't like each other. I mean, programmers think that the job of a tester is not a "real" job, and testers think that programmers are too "proud". Is this the right decision made by me, why is it, and what can we do to avoid these kind problems?


title: How to model hashtags with nodejs and mongodb

text: Existing architecture: nodejs server with mongodb backend. I have strings coming in describing images that can have #hashtags in them. I wish to extract the hashtags from the strings, store the hashtags and associate the image with that hashtag. So e.g. an image is uploaded with 'having fun at #bandcamp #nyc' `#bandcamp` and `#nyc` are extracted.   * If they don't exist as hashtags already, they're created and the image is associated with them both.   * If they do exist, that's recognised and the image is associated with both. So it will be possible to build a mongo find query that gets all images for a hashtag or multiple hashtags. I'm new to nosql, I understand that in relational I'd have:   * table hashtags   * table images   * table imageshashtags with a many to many relationship. An image can have many hash tags, and a hashtag can have many images. What sort of approach is suitable with mongo? From reading q&a like this: http://stackoverflow.com/questions/8455685/how-to-implement-post-tags-in-mongo I see that I can implement a sub document in the image document with the tags. Is that efficient for searching and retrieving? I could then use http://cookbook.mongodb.org/patterns/count_tags/ \- map reduce? So end up with: images collection withwith tags subdocument tags collection   * images document with tags subdocument with tags extracted and added to it when the image is created, and new tag added to the collection if it's not already present (i.e. tags must be unique) also create the tag in the tags collection, and run map reduce. Is that sound? Am I understanding things correctly and is my approach sensible?


title: Teaching: How can you motivate students to comment?

text: I remember when I was taught, "comments are the most important part of code." Or rather, when I was _told_ that comments are the most important part of the code. I don't think I was convinced, and I still see common cases where programmers are not convinced of the necessity of good & thorough comments. I am certainly convinced myself at this point - trying to read, in particular, complex formulae that call functions that call other functions that I don't understand - but I don't know how to convey this to students.


title: How do I convince manager to move me from services/support team to development?

text: I joined a company a few months ago as a Java developer. I like doing coding and it makes me happy. After my Java training I was put into services/support project. There is no coding in this team. When I ask my manager to move me into development project or roll me off from this project he questioned my "Why do you want to do coding?" This is the point where I am speechless to objectify why I want to do coding. How can I convince him to move me to development project? I want to keep gaining knowledge in Java and experience in development.


title: Charging for chrome extension?

text: I have a chrome extension that I think is fairly useful. It's already been posted and is free. How can I start charging for it with the Chrome webstore? $.99 or some such.


title: Is it possible to find a four-digit Username / Password by chance?

text: Imagine you have a login-form and it has two field :   * Username (Maximum length : 4 - digits only)   * Password (Maximum length : 4 - digits only) Is it possible to write a program to find the username and password? As I know in the worst case, we will have 100,000,000 checks. and it's crazy because it takes a very long time. So, what is your solution?


title: Algorithm for recursive evaluation of postfix expressions

text: I'm reading Sedgewick's book on algorithms in C and I'm looking for an algorithm to evaluate postfix expressions (addition and multiplication only) without using a stack. I tried to implement one but I always get nowhere. I have a simple C implementation for **prefix** evaluation               int eval()     {       int x = 0;            while (a[i] == ' ')         i++;       if (a[i] == '+')         {           i++;           return eval() + eval();         }       if (a[i] == '*')         {           i++;           return eval() * eval();         }       while ( (a[i] >= '0') && (a[i] <= '9'))         x = 10*x + (a[i++]-'0');       return x;      }      and I was wondering if it's possible to do something as elegant as this but for postfix evaluation.


title: How to store the file names, start offset and length while avoiding the issue of self imposed limits (lookup table) or having to scan the entire file?

text: I am attempting to learn more about C and it's descendants(C++ mainly). I have decided that I would like to create a "file system" of sorts. Not a particularly advanced one mind you but something to play with. I have no intentions of making it mountable, securable or even recoverable. At the moment I am stuck in concept land with trying to decide how to implement the MFT/FAT. At first I thought that I would just use the first X number of bytes to store a lookup table, when I realized that there would then be a limitation to the number of files I could store I thought maybe use some type of metadata with each file but then I would have to scan the entire filesystem to locate a file. I have read through this and this although the z80 link seems like it is more up my alley. From a high level I want to be able to issue a command like:               ./myfs funnycat.jpg mystorage.mfs      Essentially appending binary data to the end of mystorage.mfs How can I store the information that would contain the file names, start offset and length while avoiding the issue of self imposed limits (lookup table length) or having to scan the entire file (metadata with binary data)? **Concise Explanation** I am looking for a way to label binary data stored in a single contiguous file so that I can pull data from a given offset range or by string.               ./myfs mystorage.mfs funnycat.jpg      Likely in order to accomplish this I will add some logic to myfs to check the first argument for signs that it is a blob containing other files or not.


title: Constructor parameter validation in C# - Best practices

text: What is the best practice for constructor parameter validation? Suppose a simple bit of C#:               public class MyClass     {         public MyClass(string text)         {             if (String.IsNullOrEmpty(text))                 throw new ArgumentException("Text cannot be empty");                  // continue with normal construction         }     }      Would it be acceptable to throw an exception? The alternative I encountered was pre-validation, before instantiating:               public class CallingClass     {         public MyClass MakeMyClass(string text)         {             if (String.IsNullOrEmpty(text))             {                 MessageBox.Show("Text cannot be empty");                 return null;             }             else             {                 return new MyClass(text);             }         }     }


title: How many hours can you be really productive per day? How?

text: I find that I'm having a great deal of trouble staying alert 8 hours per day. I've heard of people who've negotiated work contracts of just 4 hours/day, arguing that they won't be able to do much more in eight hours. I am often overwhelmed with drowsiness, boredom, distraction. Some days, I seem to blaze through eight hours in a furious explosion of productivity; other days, I hardly get anything done at all. Most days, it's somewhere in between, and I feel bad for wasting a lot of time because I can't muster the concentration to be my best throughout much of the day. I'd like to hear your experiences (tell me I'm not alone!), and, if found, your solutions to this dilemma. Are you productive 8 hours/day almost every day? How?


title: When is it preferred to combine Add/Edit functionality, and when to keep them separate?

text: I regularly come across situations where I need to Add or Edit an item, and sometimes I use separate methods for Add and Edit, and other times I combine them into a single method. Is one method preferred over the other? If so, why?               public void AddItem()     {         ShowEditingPopup(new Item(), "Add Item");     }          public void EditItem(Item item)     {         ShowEditingPopup(item, "Edit Item");     }      OR               public void EditItem(Item item)     {         ShowEditingPopup(             (item ?? new Item()),              string.format("{0} Item", (item == null ? "Add " : "Edit "))         );     }      where `ShowEditingPopup` is defined as               public void ShowEditingPopup(object popupDataContext, string popupTitle)     {         PopupDataContext = popupDataContext;         PopupTitle = popupTitle;         IsPopupVisible = true;     }      **Edit:** Just to clarify, I am not Saving the item, I am opening it for Editing. I almost always implement a generic Save method for saving to the database **Edit #2:** Edited code samples so they more accurately reflect the sort of situation I am referring to


title: Writing a method to 'transform' an immutable object: how should I approach this?

text: (While this question has to do with a concrete coding dilemma, it's mostly about what's the best way to design a function.) I'm writing a method that should take two Color objects, and gradually transform the first Color into the second one, creating an animation. The method will be in a utility class. My problem is that Color is an immutable object. That means that I can't do `color.setRGB` or `color.setBlue` inside a loop in the method. What I _can_ do, is instantiate a new Color and return it from the method. But then I won't be able to _gradually_ change the color. So I thought of three possible solutions: * * * 1- The client code includes the method call inside a loop. For example:               int duration = 1500; // duration of the animation in milliseconds     int steps = 20; // how many 'cycles' the animation will take     for(int i=0; i<steps; i++) color = transformColor(color, targetColor, duration, steps);      And the method would look like this:               Color transformColor(Color original, Color target, int duration, int steps){         int redDiff = target.getRed() - original.getRed();         int redAddition = redDiff / steps;         int newRed = original.getRed() + redAddition;              // same for green and blue ..              Thread.sleep(duration / STEPS); // exception handling omitted         return new Color(newRed, newGreen, newBlue);     }      The disadvantage of this approach is that the client code has to "do part of the method's job" and include a `for` loop. The method doesn't do it's work entirely on it's own, which I don't like. * * * 2- Make a mutable `Color` subclass with methods such as `setRed`, and pass objects of this class into `transformColor`. Then it could look something like this:               void transformColor(MutableColor original, Color target, int duration){         final int STEPS = 20;              int redDiff = target.getRed() - original.getRed();         int redAddition = redDiff / steps;         int newRed = original.getRed() + redAddition;              // same for green and blue ..              for(int i=0; i<STEPS; i++){             original.setRed(original.getRed() + redAddition);             // same for green and blue ..             Thread.sleep(duration / STEPS); // exception handling omitted         }     }      Then the calling code would usually look something like this:               // The method will usually transform colors of JComponents     JComponent someComponent = ... ;     // setting the Color in JComponent to be a MutableColor     Color mutableColor = new MutableColor(someComponent.getForeground());     someComponent.setForeground(mutableColor);     // later, transforming the Color in the JComponent     transformColor((MutableColor)someComponent.getForeground(), new Color(200,100,150), 2000);      The disadvantage is - the need to create a new class `MutableColor`, and also the need to do casting. * * * 3- Pass into the method the actual mutable object that holds the color. Then the method could do `object.setColor` or similar every iteration of the loop. Two disadvantages: A- Not so elegant. Passing in the object that holds the color just to transform the color feels unnatural. B- While most of the time this method will be used to transform colors inside `JComponent` objects, other kinds of objects may have colors too. So the method would need to be overloaded to receive other types, or receive `Object`s and have `instanceof` checks inside.. Not optimal. * * * Right now I think I like solution #2 the most, than solution #1 and solution #3 the least. However I'd like to hear your opinions and suggestions regarding this.


title: CI - How long is continous?

text: We currently are using CCNet as our continous integration server. Most projects check for changes every 30 seconds (the default) and if needed perform a build (unit tests, stylecop, fxcop, etc). We've gotten quite a few projects now, and the server spends most of its time near 100% cpu utilization. This has alarmed some of the development team, even though the server is responsive and builds are still about the same length of time they've always been. Its been suggested that we lower the check interval to about five minutes. To me that seems too long, and we risk people committing code and then going home for the weekend and now there's a broken build possibly holding up others. In response, the suggestion is that if someone needs to know the results they can force the build. But that seems to defeat the purpose of CI, as I thought it was supposed to be automated. My proposed solution is just to get another build server and split the builds amongst the servers. Am I thinking about this the wrong way, or is there a point where if integration isn't often enough you're not really doing CI anymore?


title: To Domain or not to Domain

text: The SQL92 and SQL99 standards define `CREATE DOMAIN` DDL constructs. Not all databases support this, or have a different name for it (SQL Server has User Defined Types, for example). These allow one to define a constrained data-type to be used in their database, to simplify and enforce rules pertaining to the allowed values. Such a data-type could be used in column declarations, in inputs and outputs to stored procedures and functions etc... I would like to know:   * Do people actually use domains in their database designs?   * If so to what extent?   * How useful are they?    * What pitfalls have you encountered? I am trying to asses the viability of using these in future database development.


title: Can I use Linux/Mono instead of Windows/Visual Studio without any problem?

text: I have more than 6 years of experience with .Net (C#/ASP.NET) and Visual Studio. But recently I'm tempted to switch to Linux/Mono. It comes up with some questions:   1. Can I run my old Visual Studio projects and source codes in Mono correctly?   2. My clients use IIS for ASP.NET and MS Windows for Winform and Console projects. Does my migration affect them? In other words does my Mono projects runs in Windows/IIS without any change or problem?   3. Does Mono is dependable considering recent changes of Mono, Novell, Xamarin and Attachme?   4. Can I continue using my favorite open source and none open source projects like NHibernate, Castle, Cuyahoga, log4net, Microsoft Enterprise Library and DNN?   5. Can I host Mono ASP.NET web projects in Apache without any problem?   6. Can I use my skills in ASP.NET webforms and MVC in Mono exactly?


title: Does W3C membership help future career?

text: Having international certificates from giant companies like Microsoft, Cisco, etc. can be a great help to your career. Also if you have a decent amount of experience, you're fine getting a job. How about free, but active membership of W3C? They don't give you certificates. You just become a member, think about recommendations and proposals, participate in decision-making process and that's all. Does W3C membership help future career?


title: What has been your experience with SQL CLR for complex business logic?

text: So I thought I had a perfect use-case for a CLR SQL Procedure. I've search the Net for perhaps a similar example where data is retrieved, records added and updated. I have not looked at a SQL CLR procedure for awhile, but since it was released in 2005 (some 6 years ago!) I would have hoped there were plenty of examples! I'm considering it because I have to look at some data, run it through a bunch of procedural logic, update, and then get it back to the client. My thinking here is to get as close to the DB metal as possible, and use that hardware to make it happen quickly. Is anybody using SQL CLR? If you have, what has been your experience with it? p.s. originally posted on stackoverflow and moved here based on a comment.


title: In Scrum, what to do when story points and task hours don't roughly correlate?

text: Our development team is pretty new to the scrum process, so I would like to help refine our methods to make better use of it. In particular, I noticed that the correlation between story points and task hours is not very good. That is, we often have stories of lesser points decomposed into a total task hours greater than stories of higher points. Now, I am aware that these are two separate estimation processes and that we should use the hours to estimate only the remaining work for a sprint while using the story points to compute a velocity and be able to predict the length of the release cycle or the amount of features we will be able to address. However, it seems to me that if sprint points and task hours don't correlate well, then we must be doing a bad job at estimating either one or both of these. Since we only adjust the remaining work hours as opposed to recording the time spent, I can't easily tell if the problem is the initial task hour break-down or the story point estimates. So, my question is whether we should deal with this and how? I can think of several ways to start dealing with this:   * Record time spent in a task and use this information as feedback to help refine our estimation process by retrospectively identifying user stories which we under/over estimated. **_But I am not convinced that we want to record this information and I anticipate resistance to it._**   * At the planning phase, identify outliers after the task hour break-down process and look at these further. This way we could try to identify whether we misjudged the complexity of the story or if the task breakdown is missing some efforts or over-estimating the length of simple tasks. **_However, I'm afraid this would couple the two estimation efforts, which doesn't seem as the right thing to do either... This also assumes we would have decomposed all stories in the planning phase, otherwise we won't be able do much about stories which were misjudged._**   * Another method to approach this would be to try to independently incorporate methods to enhance the estimation process and raise the team consciousness about the importance of estimation. Then just keep monitoring the correlation between story points and initial task hour break-down as an indicator of how we are doing and whether we need to keep working at it. **_I'm inclined to think that this is the best approach, but less pro-active._** What is the best way to approach this issue and/or what other suggestions are there for enhancing the estimation process in this context?


title: What are ways of drafting a workflow document that maps elements in the design close to their counterparts in code?

text: We're starting a medium sized PHP web app, written in MVC fashion, using CodeIgniter. Most of the functional specifications have been written, and there are a few features that will definitely be replaced with improved behaviour in later stages of the project. I'm tasked with writing a workflow document from a technical point of view and here's what I want to cover, ideally:   * The document should preferably be a diagram of some sort,   * A close mapping of elements in the document with with models/views/controllers/js functions/other important blocks in the code; let's call these modules That will suffice since I will be able to derive from that a way to test different modules independently and assign different modules to different programmers. The aspect of rewriting parts of the document when I discover that parts of the code need to be replaced isn't an issue, I'll make the rewrites to keep code and diagram in sync if/when I have to. My attempts so far with Petri nets and UML interaction diagrams have failed upon the realization that I have to expose too much of the decision making logic inside controllers. I'm looking for advice and I'm curious if anyone has done this before.


title: 7 drived classes with one common base class

text: i have written the following code,                  //main.cpp          #include<iostream>          #include<string>          #include"human.h"          #include"computer.h"          #include"referee.h"          #include"RandomComputer.h"          #include"Avalanche.h"          #include"Bureaucrat.h"          #include"Toolbox.h"          #include"Crescendo.h"          #include"PaperDoll.h"          #include"FistfullODollors.h"          using namespace std;          int main()          {          Avalanche pla1;     Avalanche pla2;          referee f;     pla1.disp();     for (int i=0;i<5;i++)     {                   cout<<pla2.mov[i];         }          return 0;          }      in this program all included classes except referee.h and human.h are drived from computer.h. each drived calls has a char array variable which is initialized when a member of a drived class is declared. the problem is that when i declare tow diffrent drived class memebers lets say Avalache and ToolBox. upon printing the char array for one of them using for loop it prints nothing. However if i declare only one of them in main.cpp the it works properly. and the file for computer.h is as such:                   #ifndef COMPUTER_H     #define COMPUTER_H     class computer     {         public:         int nump;         char mov[];         void disp();     };     #endif      ToolBox.h is like this:                   #ifndef TOOLBOX_H          #define TOOLBOX_H          #include"computer.h"          class Toolbox: public computer          {              public:              Toolbox();          };          #endif      finally Avalanche.h is as following:               #ifndef AVALANCHE_H          #define AVALANCHE_H          #include"computer.h"          class Avalanche: public computer          {              public:              Avalanche();          };          #endif


title: Is hashing of just "username + password" as safe as salted hashing

text: I want to hash "user + password". [EDIT: prehashing "user" would be an improvement, so my question is also for hashing "hash(user) + password". If cross-site same user is a problem then the hashing changed to hashing `"hash(serviceName + user) + password"`] From what I read about salted hash, using "user + password" as input to hash function will help us avoid problem with reverse hash table hacking. The same thing can be said about rainbow table. Any reason why this is not as good as salted hashing?


title: How do you remember where in your code you want to continue next time?

text: When you interrupt the work on some code (be it because you have to work on something else or go on vacation or simply because it is the end of the day), once you close that Visual Studio project, what is your preferred way to remember what you want to do next when you start working on that code again. Do you set a Visual Studio bookmark or do write down something like `// TODO: continue here next time`? Maybe you have a special tag like `// NEXT:`? Do you put a sticky note on your monitor? Do you use a cool tool or Visual Studio plugin I should know? Do you have any personal trick that helps you find the place in your code where you left off the last time you worked on your code?


title: What is the difference between a great programmer and a financially successful programmer?

text: What is the difference between people like Zukerberg, Page and Brin who are programmers and also extraordinarily successful financially, and the other wise great programmer who are not very much financially successful (like most of the employees at facebook and google).


title: Is there a language out there in which parameters are placed inside method name?

text: in JavaScript:               function getTopCustomersOfTheYear(howManyCustomers, whichYear) {        // Some code here.     }     getTopCustomersOfTheYear(50, 2010);      in C#:               public List<Customer> GetTopCustomersOfTheYear(int howManyCustomers,       int whichYear)     {        // Some code here     }     List<Customer> customers = GetTopCustomersOfTheYear(50, 2010);      in PHP:               public function getTopCustomersOfTheYear($howManyCustomers, $whichYear)     {        // Some code here     }     $customers = getTopCustomersOfTheYear(50, 2010);      Is there any language out there which support this syntax:               function GetTop(x)CustomersOfTheYear(y)     {         // Some code here     }     returnValue = GetTop(50)CustomersOfTheYear(2010);      Isn't it more semantic, more readable form of writing a function? **Update:** The reason I'm asking this question is that, I'm writing an article about a new syntax for a new language. However, I thought that having such syntax for declaring methods could be nicer and more friendly to developers and would decrease learning-curve of the language, because of being more closer to natural language. I just wanted to know if this feature has already been contemplated upon or not.


title: Search for the (slowly moving) number with penalty for too high test value

text: You task is to design a search algorithm that will find my secret number, which is between 0 and 2^64. If your test value is too low you can test again in 1 second. If your test value is too high you are not allowed to test again the next 300 seconds. Every second I will add 1 to or subtract 1 from the number. I will not tell you what I have done, and while it may be random it also might not be random. How can you find the approximate number fast? The obvious answer is to use a binary search, but since the penalty is high for guessing too high, I would think it needs some adjustment. **Background** I need to find the speed of a system. The speed changes slowly. It takes 1 second to do a guess. If my guess is too low: no problem. If it is too high, then system reboots, causing a 5 minute delay. My goal is to get a decent estimate of the speed relatively fast.


title: Sprint Backlog Task Estimates - What Are the Hours Made Of?

text: For the sprint backlog, I read that the stories are broken into tasks, and estimated. Are these estimates typically development hours only, or development + QA? What are these hours typically consisting of? Thanks.


title: Should we avoid using design patterns in constantly changing projects?

text: A friend of mine is working for a small company on a project every developer would hate: he's pressured to release as quickly as possible, he's the only one who seem to care about technical debt, the customer has no technical background, etc. He told me a story which made me think about the appropriateness of design patterns in projects like this one. Here's the story. > We had to display products at different places on the website. For example, > content managers could view the products, but also the end users or the > partners through the API. > > Sometimes, information was missing from the products: for example, a bunch > of them didn't have any price when the product was just created, but the > price wasn't specified yet. Some didn't have a description (the description > being a complex object with modification histories, localized content, > etc.). Some were lacking shipment information. > > Inspired by my recent readings about design patterns, I thought this was an > excellent opportunity to use the magical Null Object pattern. So I did it, > and everything was smooth and clean. One just had to call > `product.Price.ToString("c")` to display the price, or > `product.Description.Current` to show the description; no conditional stuff > required. Until, one day, the stakeholder asked to display it differently in > the API, by having a `null` in JSON. And also differently for content > managers by showing "Price unspecified [Change]". And I had to murder my > beloved Null Object pattern, because there was no need for it any longer. > > In the same way, I had to remove a few abstract factories and a few > builders, I ended up replacing my beautiful Facade pattern by direct and > ugly calls, because the underlying interfaces changed twice per day for > three months, and even the Singleton left me when the requirements told that > the concerned object had to be different depending on the context. > > More than three weeks of work consisted of adding design patterns, then > tearing them apart one month later, and my code finally became spaghetti > enough to be impossible to maintain by anyone, including myself. Wouldn't it > be better to never use those patterns in the first place? Indeed, I had to work myself on those types of projects where the requirements are changing constantly, and are _dictated_ by persons who don't really have in mind the cohesion or the coherence of the product. In this context, it doesn't matter how agile you are, you'll come with an elegant solution to a problem, and when you finally implement it, you learn that the requirements changed so drastically, that your elegant solution doesn't fit any longer. What would be the solution in this case?   * Not using any design patterns, stop thinking, and write code directly? It would be interesting to do an experience where a team is writing code directly, while another one is thinking twice before typing, taking the risk of having to throw away the original design a few days later: who knows, maybe both teams would have the same technical debt. In the absence of such data, I would only assert that it doesn't _feel right_ to type code without prior thinking when working on a 20 man-month project.   * Keep the design pattern which doesn't make sense any longer, and try to add more patterns for the newly created situation? This doesn't seem right neither. Patterns are used to simplify the understanding of the code; put too much patterns, and the code will become a mess.   * Start thinking of a new design which encompasses the new requirements, then slowly refactor the old design into the new one? As a theoretician and the one who favors Agile, I'm totally into it. In practice, when you know that you'll have to get back to the whiteboard every week and _redo the large part of the previous design_ and that the customer just doesn't have enough funds to pay you for that, nor enough time to wait, this probably won't work. So, any suggestions?


title: Are Components ideal for packaging and reusing find() requests?

text: I find myself loading several models over and over again throughout my application. Instead of typing the code to load the model, run a find, would it be reasonable to put that code in a method and just call it from the controller. For example: **Instead of**               public function view() {         $this->loadModel('Foo');         $this->Foo->find('list');     }      **Could I use**               public function view() {         $this->ComponentName->fooLoad();     }


title: How do you deal with being behind on a task?

text: I have a question for you guys. Say, you're given a task as an item in a product backlog. Say, you have a deliverable that's due the following day. If you're behind on the task compared to when you made your estimates, what do you do about it? Does it make you anxious knowing your behind schedule? How do you deal with this? Do you tell the scrum master or the product owner?


title: Which Java based web ui framework to use?

text: * Wicket   * Click   * GWT   * Vaadin As I understand them, these frameworks all enable gui components to be created using java (with all its benefits) without having to do lots of html/javascript. As well as considering the technical factors, I am also interested to hear if any are gaining popularity fast. Is a particular framework is becoming the _leader of the pack_ , this will also effect the decision.


title: How do programming languages define functions?

text: How do programming languages define and save functions/methods? I am creating an interpreted programming language in Ruby, and I am trying to figure out how to implement function declaration. My first idea is to save the content of the declaration in a map. For example, if I did something like               def a() {         callSomething();         x += 5;     }      Then I would add an entry into my map:               {         'a' => 'callSomething(); x += 5;'     }      The problem with this is that it would become recursive, because I would have to call my `parse` method on the string, which would then call `parse` again when it encountered `doSomething`, and then I would run out of stack space eventually. So, how do interpreted languages handle this?


title: I recently read about unit of work and repository design patterns; working with EF wondering if this is a good design pattern

text: I found myself creating child records that require a master record to exist, first, so that they can reference it by the master record's primary key (if that's the right term). To accomplish this using EF 6 I tried to call `SaveChanges()` twice - once to create the master record so that its identity key gets generated and once after the children have been created. The problem I ran into was that EF doesn't like multiple calls to `SaveChanges()` so I had to use a transaction. I don't like using a transaction because it feels messy for some reason I can't articulate. It's a somewhat common problem for me to have to do this so instead of a `using`, `try/catch` and `commit/rollback` I figured it'd be easier to have this each time:               this._dbContextWrapper.CommitIfTrue(() =>     {         // Multiple calls to SaveChanges() here              return true;     });      While also having `BeginTransaction()` exposed on my `_dbContextWrapper` so that if passing a `Func<bool>` isn't desirable.               public interface IRepository     {         IQueryable<TModel> Query<TModel>()             where TModel : class;              TModel Find<TModel>(params object[] key)             where TModel : class;              void Add<TModel>(TModel model)             where TModel : class;              void Update<TModel>(TModel updated, params object[] key)              where TModel : class;              IDataResult SaveChanges();              void Delete<TModel>(params object[] key)             where TModel : class;              IRepositoryTransaction BeginTransaction();              IRepositoryTransaction BeginTransaction(IsolationLevel isolationLevel);              IDataResult CommitIfTrue(Func<bool> transaction);              IDataResult CommitIfTrue(Func<bool> transaction, IsolationLevel isolationLevel);     }          public interface IRepositoryTransaction : IDisposable     {           void Commit();              void Rollback();     }          public interface IDataResult     {         bool IsSuccess { get; }              string ErrorMessage { get; }     }      I realize that this "`IRepository`" only a thin wrapper around `DbContext` \- I'm doing it so that my classes can have a `Mock` implementation provided to them instead of having to mess with `Fakes` to get around the non-virtual aspect of `DbContext`'s methods. My question is: **Is my`CommitIfTrue` method reasonable? Is there a way to do something similar that's also more testable/involves no `Action`s or `Func`s?**


title: What's The Difference Between Imperative, Procedural and Structured Programming?

text: By researching around (books, Wikipedia, similar questions on SE, etc) I came to understand that Imperative programming is one of the major programming paradigms, where you describe a series of commands (or statements) for the computer to execute (so you pretty much order it to take specific actions, hence the name "imperative"). So far so good. Procedural programming, on the other hand, is a specific type (or subset) of Imperative programming, where you use procedures (i.e., functions) to describe the commands the computer should perform. **First question** : Is there an Imperative programming language which is not procedural? In other words, can you have Imperative programming without procedures? **Update** : This first question seems to be answered. A language CAN be imperative without being procedural or structured. An example is pure Assembly language. Then you also have Structured programming, which seems to be another type (or subset) of Imperative programming, which emerged to remove the reliance on the GOTO statement. **Second question** : What is the difference between procedural and structured programming? Can you have one without the other, and vice-versa? Can we say procedural programming is a subset of structured programming, as in the image? ![enter image description here](http://i.stack.imgur.com/Ip5eR.jpg)


title: Getting paid through Ltd or Umbrella company?

text: I am working for a company as a web dev consultant at the moment, and they asked me whether I want to get payed through the Umbrella company or through my Ltd. Which is better for me and why? The @David Thornley made a good point in comments. Don't forget that we are talking about web developing here. I am not sure how is it in UK, but in the country I am from, you get taxed differently for the stuff you do.


title: Lean/Kanban *Inside* Software (i.e. WIP-Limits, Reducing Queues and Pull as Programming Techniques)

text: Thinking about Kanban, I realized that the queuing-theory behind the SW- development-methodology obviously also applies to concurrent software. Now I'm looking for whether this kind of thinking is explicitly applied in some area. A simple example: We usually want to limit the number of threads to avoid cache-thrashing (WIP-Limits). In the paper about the disruptor pattern[1], one statement that I found interesting was that producer/consumers are rarely balanced so when using queues, either consumers wait (queues are empty), or producers produce more than is consumed, resulting in either a full capacity-constrained queue or an unconstrained one blowing up and eating away memory. Both, in lean-speak, is waste, and increases lead-time. Does anybody have examples of WIP-Limits, reducing/eliminating queues, pull or single piece flow being applied in programming? http://disruptor.googlecode.com/files/Disruptor-1.0.pdf


title: Performance overhead of standard containers and boost

text: Adap.TV has chosen C++ to develop their software. However, they've decided not to use the standard containers1 and boost for performance reasons, as they've blogged about it in the following article:   * Why we use C++ (without using STL or boost) It says (emphasis mine), > There are several rules that we are obeying **in order to keep the > performance high** ;   >  **Avoid malloc(), calloc() or new**   >  **No free() or delete** (and no need for tcmalloc)   >  **No STL, boost etc.**   >  Avoid locking as much as possible   >  # threads = # CPU cores (hyperthread is a trade-off between latency and > throughput) As we know, the standard containers use allocators which uses `new` and `delete` internally which are _expensive_ operations. So to avoid them, AdapTv has avoided using standard containers altogether. Instead of using `new` and `delete` (repeatedly), they _reuse_ memory (which implies they use a memory pool). I'm wondering what's stopping them from using custom allocators for the standard containers! The custom allocator could use a memory pool internally which means _memory reuse_. So I don't see how standard containers would hurt performance. Or am I missing something? Can't we avoid using `new` and `delete` with standard containers? Is there any other reason why would anyone avoid using standard containers? Or is it simply a lack of knowledge on their part which led to this decision? And how about boost? * * * 1) I suppose by _STL_ they meant _C++ standard containers_ , not SGI's STL.


title: Is it possible to integrate MS Project Server with SVN

text: We have been using Hosted SVN + Fogbugz for our source control and task/issue tracking. Our developers are very comfortable with SVN and we are hesitant to switch source control (e.g. TFS) providers at this point. However, Management extensively uses Microsoft Project for project management and are considering setting up MS Project Server. **EDIT** With SVN + Fogbugz (or several other task tracking tools), we can create a post-commit hook to update tasks (close/reopen/specify time) from commit messages. Does anyone know of a way to intergrate MS Project Server with SVN? Is it even possible? I searched online but could not find anything. Maybe I did not search correctly?


title: Possible to Comment on a storyboard?

text: I recently started working for a company that has me making mockups for an app they'd like to see converted to an iPhone app. I have not been informed as to how all the boards fit together, but I do have a general idea on what they should look like. I would like to write notes or comments on each individual board about how things should be done once I have more information. Is it possible to comment on a board or is there some place close to the boards where I can leave notes on what to do next?


title: How can I estimate the lifespan of a line of code?

text: I'm trying to figure out a way to analyze code longevity in open source projects: that is, how long a specific line of code is active and in use. My current thinking is that a line of code's lifespan begins when it is first committed, and ends when one of the following occurs:   * It's edited or deleted,    * Excluded from builds,   * No code within its build is maintained for some period of time (say, a year). NOTE: As clarification on why an "edit" is being counted as "death", edited lines would be counted as a "new" generation, or line of code. Also, unless there's an easy way to do this, there would be no accounting for the longevity of a lineage, or descent from an ancestor. What else would determine a line of code's lifespan?


title: How to use the clients webcam for recording through a website?

text: I am building a site and idealy I would like to record the users interaction via their webcam. How do I intergrate webcam recording into my site. I have seen It done with flash. But Im trying to avoid using this. My site is being built using c#, javascript and designed for IE 7 and older. * * * I want to record the videos for later. They are not going to be used for chat e.t.c.


title: Choosing between Single or multiple projects in a git repository?

text: In a **`git`** environment, where we have modularized most projects, we're facing the _one project per repository_ or _multiple projects per repository_ design issue. Let's consider a modularized project:               myProject/        +-- gui        +-- core        +-- api        +-- implA        +-- implB      Today we're having _one project per repository_. It gives freedom to   * `release` individual components   * `tag` individual components But it's also cumbersome to **`branch`** components as often branching `api` requires equivalent branches in `core`, and perhaps other components. Given we want to `release` individual components can we still get the similar flexibility by utilizing a _multiple projects per repository_ design. What experiences are there and how/why did you address these issues?


title: Best way to present a small application

text: I'm giving a presentation on a small Timeline Application I made over the past few weeks. How might I make this small application into a much larger speech, about 3 minutes long. **Should I focus on how it was made or should I just focus on why people should use it?**


title: Finding a way to simplify complex queries on legacy application

text: I am working with an existing application built on Rails 3.1/MySql with much of the work taking place in a JavaScript interface, although the actual platforms are not tremendously relevant here, except in that they give context. The application is powerful, handles a reasonable amount of data and works well. As the number of customers using it and the complexity of the projects they create increases, however, we are starting to run into a few performance problems. As far as I can tell, the source of these problems is that the data represents a tree and it is very hard for ActiveRecord to deterministically know what data it should be retrieving. My model has many relationships like this:               Project        has_many Nodes        has_many GlobalConditions          Node         has_one Parent        has_many Nodes        has_many WeightingFactors through NodeFactors        has_many Tags through NodeTags          GlobalCondition        has_many Nodes ( referenced by Id, rather than replicating tree )          WeightingFactor        has_many Nodes through NodeFactors          Tag        has_many Nodes through NodeTags      ![enter image description here](http://i.stack.imgur.com/4L3Rn.png) The whole system has something in the region of thirty types which optionally hang off one or many nodes in the tree. My question is: What can I do to retrieve and construct this data faster? Having worked a lot with .Net, if I was in a similar situation there, I would look at building up a Stored Procedure to pull everything out of the database in one go but I would prefer to keep my logic in the application and from what I can tell it would be hard to take the queried data and build ActiveRecord objects from it without losing their integrity, which would cause more problems than it solves. It has also occurred to me that I could bunch the data up and send some of it across asynchronously, which would not improve performance but would improve the user perception of performance. However if sections of the data appeared after page load that could also be quite confusing. I am wondering whether it would be a useful strategy to make everything aware of it's parent project, so that one could pull all the records for that project and then build up the relationships later, but given the ubiquity of complex trees in day to day programming life I wouldn't be surprised if there were some better design patterns or standard approaches to this type of situation that I am not well versed in.


title: Is there a Standard Visual Cue to Indicate the presence of a Tool Tip (Hover Text)?

text: A widely recognized cue that text is clickable is to underline it, set it in a different color, and change the cursor to a hand symbol when hovering over it. I have a situation where a column in a report may contain a tool tip -- hover- text that appears when the cursor is placed over it. I'm trying to come up with an obvious cue to the user for this. When I use a cue similar to a hyperlink, users instinctively click on it and wonder why nothing happens. Can you refer me to any real-world examples of an effective cue? Or, what cue have you successfully used in the past to accomplish this?


title: Why learn hexadecimal?

text: I've taken quite a few intro programming classes in my day, mostly just to get my feet wet in every different kind of programming I find. Not surprisingly, just about every class runs through the same format : intro to hardware, intro to software, and then you get into the actual programming. While understanding how the hardware and software works is very important, I've always been confused by one topic that has been in every single course. In the intro to software section I've found, without fail, they always put large emphasis on being literate in binary, hexadecimal, and sometimes even octal number systems. I understand that it's good to understand what these things are, and how a computer would interpret them, but I've never found myself actually needing to know how to read and write any of those number systems. Really, the only time I've seen something other than base 10 is for colors in CSS, which is even easier if you use something like www.colorpicker.com Have I just been ignorant of the wonderful uses of these non-base-10 number systems in the programming world, or is just an old tradition to include these sections in all programming textbooks? Does anyone have a good example of where the average programmer would actually use an octal number?


title: Cross browser client side storage

text: I am developing an angularjs app. The app has to run in current FF, IE, Chrome and on iOS/Android via Phonegap. I am looking for a solution to store data in the client. Phonegap offers a web sql api, that is also supported by Chrome. FF however does not support it, since it is abbandoned by w3c. Cookies and localStorage do not work reliable in iOS. How can i store data in all those browsers?


title: VB.NET: Two tiers for three layers or three tiers for three layers

text: I asked a question on StackOverflow in November about separating a very large application into layers and tiers: http://stackoverflow.com/questions/13342626/net-divorcing-layers. The previous developer included data logic and business logic in the business logic layer My question is about the tiers element. I researched on here and concluded that it is better to separate layers into tiers contained in separate DLLs i.e. the presentation layer, business logic layer and data access layer all have separate DLLs as described here: http://stackoverflow.com/questions/13342626/net-divorcing-layers. This seems to be consistent with what I lEarnt at university. However, since then all the examples I am finding online suggest having two tiers (One for the presentation layer and one tier for the BLL and DAL). Is there any specific criteria that developers use to decide whether or not to use three tiers? I am using ADO.NET and have a shared SQL Helper class in the data access layer. The SQLHelper class is similar to this but for VB.NET: http://www.sharpdeveloper.net/source/SqlHelper-Source-Code-cs.html


title: The Meaning of Unified in UML

text: UML and other related modelling languages are exists in most of the system engineering fields to represent the system, flow, relations in a structured way. UML also is one of the modelling language used in computer science like other industries to represent the systems in obeject oriented way by using different types of diagrams. Does 'Unified' UML has a special (or real) meaning here?


title: SmartHeap crashes in _shi_removeFromFreeList

text: We have a multithreaded application in C++ which uses SmartHeap-10 on Linux. new, new[], delete and delete [] are overloaded. there is _inconsistent_ occurrence of SIGSEGV, only in delete[]. the backtrace shows -               #0  0x08b068bc in _shi_removeFromFreeList ()     #1  0x08b070d7 in _shi_freeVar ()     #2  0x08b086a7 in MemFreePtr ()     #3  0x081e91ea in operator delete(void*) ()      where MemFreePtr () is library function by SmartHeap. Any pointers to think of ?


title: Explanation of Object-parameter-coupling as mentioned in Code Complete book

text: I have been reading up on the seminal and excellent book _Code Complete_. It discusses about the various kinds of couplings that can happen between modules(which may be classes as well as methods):   1. _Simple-data-parameter-coupling_   2. _Simple-object-coupling_   3. _Object-parameter-coupling_   4. _Semantic coupling_ The book has to say this about _object-parameter coupling_ : > Two modules are object -parameter coupled to each other if `Object1` > requires `Object2` to pass it an `Object3`. This kind of coupling is tighter > than `Object1` requiring `Object2` to pass it only primitive data types > because it requires `Object2` to know about `Object3`. What is the author trying to mean here?


title: How to count hits in an HTTP API without bogging down the DB

text: I'm building an API and want to count hits for each user. It's a HTTP API implemented in Python. I could keep the count in a database (using PostGreSQL) but it'll be a very busy API, so I don't want the overhead in the DB. I'm looking at Redis or just writing plain text logs. But is there a better approach? It's a map tile service, so bursts of hundreds of hits per sec. I want to report usage per month to the user--not keep total count of hits.


title: About Artificial Intelligence

text: I am interested in starting a career in artificial intelligence. Can anyone suggest how I could prepare for this? What languages should I study that would be best for this career choice?


title: Few big libraries or many small libraries?

text: Over the course of some months I've created a little framework for game development that I currently include in all of my projects. The framework depends on SFML, LUA, JSONcpp, and other libraries. It deals with audio, graphics, networking, threading; it has some useful file system utilities and LUA wrapping capabilities. Also, it has many useful "random" utility methods, such as string parsing helpers and math utils. Most of my projects use all of these features, but not all of them:   * I have an automatic updater that only makes use of the file system and networking features   * I have a game with no networking capabilities   * I have a project that doesn't need JSONcpp   * I have a project that only needs those string/math utils This means that I have to include the SFML/LUA/JSON shared libraries in every project, even if they aren't used. The projects (uncompressed) have a minimum of 10MB in size this way, most of which is unused. The alternative would be splitting the framework in many smaller libraries, which I think would be much more effective and elegant, but would also have the cost of having to maintain more DLL files and projects. I would have to split my framework in a lot of smaller libraries:   * Graphics   * Threading   * Networking   * File system   * Smaller utils   * JSONcpp utils   * LUA utils Is this the best solution?


title: Good design for delegates in a service oriented architecture

text: My problem is quite complex to explain and my English is not excellent, so I hope you can understand my question. In a service oriented architecture there are some modules that own data used by all the others applications end these modules expose the data via Remote Method Invocation and Web Services. We the developers of the module have seen that the code that invokes these modules is repeated in all the other modules, so we decided to put in common the code and created a new module named _Common Delegates_. The responsabilities of this new module are:   * keep informations about the hostname, port and JNDI and/or web service names;   * instantiate and use the service locator;   * instantiate and call the stubs to the remote modules. But the methods exposed by the _Common Delegates_ modules use the same Request and Response classes that are defined in the called modules. This means that this module does not act as a layer of decoupling. In some cases this module created problems of circular dependencies during maven builds. Is it a good thing to split the _Common Delegates_ module into many different Maven artifacts to avoid circular dependencies, one for the called module? For example if I need to call via RMI the module A, I will have to use the _Module A delegate_. Is it a good thing to make this delegates to be also a decoupling layer, meaning that they will expose their own Request and Response beans and transform them into the beans used by the called methods?


title: Static functions vs classes

text: Let's say that I want to build some utility functions to do some basic maths with de `BigDecimal`s, for example I want to have a function that computes the average of a `List<BigDecimal>`. What is the best approach? A static function or a utility class?               public static BigDecimal computeAverage(List<BigDecimal> numbers)      or               public class BigDecimalUtil          public computeAverage(List<BigDecimal> numbers)


title: Prerequisite math skill for Introduction to Algorithms (CLRS) book

text: I already have knowledge about basic algorithms. Now I plan to study more advance algorithms and I decide to go with Introduction to Algorithms. I'm not sure, do I need to refresh my math's skill before read this book or not? (I forget almost math that I learn in high school and college) If this book need strong math knowledge, please suggest subjects that benefit. **Update**   **P.S.** I want to learn about implementation, design and analysis of algorithms.


title: Does any well-known license require to make modifications available when only derived *output* is published?

text: Is there a way to make sure that modifications to free software are released even when no binaries of modified code are _conveyed_? Though it may sound odd and from what I understand, e.g., GPL requires to distribute source only if binary is _conveyed_ to other parties thus making it possible for unlimited private use as it does not fall into _propagation_. I would like to make sure that if someone publishes a final finding in a scientific literature derived with the aim of a modified code, then those modifications are made available. Does any well-known license have these provisions? If not, why would it be bad? From what I understand if I add those provisions explicitly, it would limit the freedom, e.g., rendering result non-GPLish. From one of the answers that disappeared, I guess I can add an _Additional Term_ but would not it be a _further restriction_ that can be simply ignored > If the Program as you received it, or any part of it, contains a notice > stating that it is governed by this License along with a term that is a > further restriction, you may remove that term. From what I understand it looks like it depends on how I state it. If I require to make private modification used to derived a result that was published to make available, then it would be okay, otherwise it would be a _further restriction_ if I prohibit from privately using and not making modified code available. **Example** _A_ implements a super duper algorithm but they is bad with BLAS and it takes a long time for the simulation. _B_ claims that they refined the code using CUDA or whatever and can easily get results within second. Based on their work they found this and that from simulations and got it published. And that is it. No GPL violation and no better code for community. **Another example** Imagine if some animation studio took Blender, implemented an improved version of Cycles that allows them to render things way faster and with less problems. So now they have an advantage as they can deliver animations to clients faster. No software conveyance, no GPL violation, no improvements sharing.


title: Labeling algorithm for points

text: I need an algorithm to place horizontal text labels for multiple series of points on the screen (basically I need to show timestamps and other information for a history of moving objects on a map; in general there are multiple data points per object). The text labels should appear close to their points--above, below, or on the right side--but should not overlap other points or text labels. Does anyone know an algorithm/heuristic for this?


title: Alternatives to time tracking methodologies

text: **Question first:** What are some feasible alternatives to time tracking for employees in a web/software development company, and why are they better options **Explanation:** I work at a company where we work like this. Everybody is paid salary. We have 3 types of work, Contract, Adhoc and Internal (Non billable). Adhoc is just small changes that take a few hours and we just bill the client at the end of the month. Contracts are signed and we have this big long process, the usual. We figure out how much to charge by getting an estimation of the time involved (From the design and the developers), multiplying it by our hourly rate and that's it. So say we estimate 50 hours for a website. We have time tracking software and have to record the time in 15 we spend on it (7:00 to 7:15 for example), the project name, and give it some comments. Now if we go over the 50 hours, we are both losing money and are inefficient. **Now** that I've explained how the system works, my question is how else can it be done if a better method exists (Which I'm sure one must). Nobody here likes the current system, we just can't find an alternative. I'd be more than willing to work after hours longer hours on a project to get it done in time, but I'm much inclined to do so with the current system. I'd love to be able to sum up (Or link) to this post for my manager to show them why we should use abc system instead of this system.


title: What does C++ do better than D?

text: I have recently been learning D and am starting to get some sort of familiarity with the language. I know what it offers, I don't yet know how to use everything, and I don't know much about D idioms and so on, but I am learning. I like D. It is a nice language, being, in some sort of ways, a _huge_ update to C, and done nicely. None of the features seem that "bolted on", but actually quite well thought-out and well-designed. You will often hear that D is what C++ _should_ have been (I leave the question whether or not that is true to each and everyone to decide themselves in order to avoid unnecessary flame wars). I have also heard from several C++ programmers that they enjoy D much more than C++. Myself, while I know C, I can not say that I know C++. I would like to hear from someone knowing both C++ and D if they think there is something that C++ does better than D _as a language_ (meaning not the usual "it has more third- party libraries" or "there are more resources" or "more jobs requiring C++ than D exists"). D was designed by some very skilled C++ programmers (Walter Bright and Andrei Alexandrescu, with the help of the D community) to fix many of the issues that C++ had, but was there something that actually didn't get better after all? Something he missed? Something you think wasn't a better solution? Also, note that I am talking about D 2.0, not D 1.0.


title: How can you prove an acyclic graph has n-1 edges?

text: I'm not so hot on the maths for this but for what I understand... A graph g exists with v vertices and edges. g = (V,E); The spanning graph for this is an acyclic copy of this where all the vertices are present, and all the edges are a subset of the graph with the condition that each connection is distinct. Apparently the MST should have n-1 nodes. How can this be proven ? **Sources:** http://youtu.be/zFbq8vOZ_0k?t=25m1s http://www.gtkesh.com/minimum-spanning-tree/