Why binding is not a native feature in most of the languages?

IMHO binding a variable to another variable or an expression is a very common scenario in mathematics. In fact, in the beginning, many students think the assignment operator(=) is some kind of binding. But in most of the languages, binding is not supported as a native feature. In some languages like C#, binding is supported in some cases with some conditions fulfilled. But IMHO implementing this as a native feature was as simple as changing the following code-               int a,b,sum;     sum := a + b;     a = 10;     b = 20;     a++;      to this-               int a,b,sum;     a = 10;     sum = a + b;     b = 20;     sum = a + b;     a++;     sum = a + b;      Meaning placing the binding instruction as assignments after every instruction changing values of any of the variable contained in the expression at right side. After this, trimming redundant instructions (or optimization in assembly after compilation) will do. So, why it is not supported natively in most of the languages. Specially in the C-family of languages? Update: From different opinions, I think I should define this proposed "binding" more precisely-   * This is one way binding. Only sum is bound to a+b, not the vice versa.   * The scope of the binding is local.   * Once the binding is established, it cannot be changed. Meaning, once sum is bound to a+b, sum will always be a+b. Hope the idea is clearer now. Update 2: I just wanted this P# feature. Hope it will be there in future.


Developer "Foreign Exchange Program" Across Teams

Where I work, we currently have three teams all working on one product. We've had some talks and agreed that there could be a lot of benefits to doing an 'exchange' program where a member of one team would work with the members of another team, for a period of time (min: 1 day, max: 1 week). Considering we already pair program (almost) 100% of the time, the 'exchanged' programmer won't be completely lost and there wouldn't be a large drop in productivity. Goals of the program would be:   * Exposure to new tools/libraries   * Getting to know your coworkers   * Making all developers more versatile between teams Everyone is pretty excited about the idea, but we're having trouble with how to organize the logistics of such a program. Has anyone instituted something like this and if so what helped you organize it? _Edit_ Specifically looking for examples of:   * How often do you exchange   * Tips on keeping track of exchanges/scheduling   * If you've done such a program, how has it worked out for you? Would you have liked more 'process' or keep it ad hoc?


Can we create a GPL application that has a payware advertisement on it?

We've been thinking of using GPL components to make a GPL application, and freely give it away. We then want to use that as a loss-leader. In that free application, where even the source code is available, we plan to have an advertisement for some payware. The payware would be for functionality that is completely different than the free application. For instance, the freeware would be like a checkbook application, let's say, but the payware would be a virus remover utility that people try out and then can pay for, and is closed- source, binary. Does the GPL permit one to build an application that has a payware advertisement on it?


Online compilers and repls - not one big security hole?

There are plenty of compilers and REPL services on the web. For example: Fay ide. I find that implementing some similar technology would be very interesting. But it seems like a major security hole. Am I wrong in thinking that exposing a compiler would be risky? An interpreter seems even worse. **update:** I can be a bit more specific. The kind service I'm thinking about hosting myself (a thought experiment at this stage) would be kind of close to the case of the Fay ide above. You take input from the user, process it and return it, potentially as runable javascript to the same or other users. Let's look at that example in particular. The most obvious security concern that I see for this case, as I don't actually evaluate the code server side, would be for the users, as they would run code made by an 'unknown' author. The fact that they are allowed to read the code before running it should be a significant safeguard in this regard. Although I also wonder if and when translation of code constitute a threat to the server? What kind of exploit vectors could be thought of in this context? **Summary:**   1. Beyond what you can expect from any web server set up, and beyond the most obvious concerns (or perhaps some of those obvious concerns as well), how could one user compromise another? -. How can the server application be hardened to ensure not being compromised?   2. What important questions have I neglected? ;)   3. I would like to try some experiments, and I have nearlyfreespeech in mind as a host. I could imagine that such use might be prohibited by their terms of use? Or perhaps I can trust them to be sure enough that they have sandboxed my account well enough. What should be my "minimum" safeguards, for trying stuff out and what safeguards would be possible with such limited hosting environment? **update2:** I believe that compiling to javascript for client side evaluation or evaluating limited edsls would cover for most/all use cases I have in mind. I take it that this means that I really don't put the server side to a more prominent risk than _usual_. And I don't see how the user is being put into more risk than compared to going to a random link on jsFiddle.


How does one choose a suitable software/technology conference to attend?

I've been programming for a while now, and have been thinking that I really should go to a conference. I think I will be able to get a lot out of the networking opportunities, but also would love to see new ideas/technologies and other things that might fuel ideas for my work. Since conferences cost a lot, I really want to make sure I find one that can provide value to me personally and to my employer. I know there have been questions on identifying conference listing sites even ones to identify good conferences. But the crux of my question comes to what makes a particular conference "good"? How would you take the list of all available conferences and filter it down to those that would be a good fit for you personally? What factors do you consider about yourself and your personal situation and how does that drive what features do you look for in a conference? In the other direction as well, if you've stumbled across a conference that may be interesting, what do you look for to know if it would be a good fit? Conversely what red flags do you look out for to make sure you don't attend an unsuitable conference?


I was asked an interesting question: Should a database contains all data? Or heavy binary files should be stored in file system? Example of heavy binary files : videos or heavy pdf files (+200 MB) With an old aspx web app (1.1) I tried to open a 200MB pdf file stored as a blob in an Oracle 11g database, and it just run out of memory. However, same asp.net web application had no problem to open same pdf file stored in file system of a server. It could be that maybe there is some proper way to open heavy blobs fields with asp.net. For integrity reasons, I say that all data should be stored in database, but my described case showed me that maybe it's not the way. I read once that if your web application goes to cloud, then it would be very difficult to keep references of files stored in file system (file paths like: ../MyFolder001/MyFile.mpg), since you don't know where those files will be distributed. Should heavy binary files not be stored in database?


Policy and practice on code maintenance

I just came out of University and have been working at this company for roughly 8 months, while I was given the title of developer, most of the time I have spent on is fixing and debugging other people's codes. I always wonder why isn't the original developer's responsibility for fixing his/her code. I understand that if the original developer is no longer present, then the other developers have to take over the work, but what if the developer is still working as an employee in the company? One may argue that it is beneficial to the new developers as they see it as an opportunity to learn, and I agree with that, but what if the complexity of the problem/issue of the code is very steep? In my case, most of the codes they assigned me to fix are non trivial problems, and it always ends up myself asking the original developer questions regarding the code. Why can't the developers who created it fix the existing problem if they understand it so much better since they coded it? And the problem I am referring to is not some trivial problem where you can fix it in a day or two,but problem that requires a deep understanding of the code in order to come up with a solution. What is the reasoning behind this and is it common in the software industry?


How come project managers stand above even team leaders?

As I have started working for bigger companies, project managers started creeping into the organizational structure. I'm having a hard time understanding why these people are ranked higher even than the technical leads. What really annoys me is that the PMs have very little technical knowledge. The analyst usually, the tech lead, breaks down the whole project down to the smaller units of work. Even the scheduling of these items needs to be done by someone that truly understands dependencies. So, you may imagine my confusion to why these PMs, that are less technically capable people are ranked higher in org charts. I'm going on a stretch here but I feel like a PM being over a tech lead is like an accountant being over the COO, because the former does the book keeping. So, why is it that PMs are ranked higher than teach leads?


What is the minumum code/operations to have in a separate thread?

I understand that threading is needed to get the maximum performance out of today's multicore processors but starting a thread is rather costly so you can't put every single calculation that can be done in parallel in an own thread. For example               answer = new thread(plus(1,2)) + new thread(plus(3,4))      will run much slower than the simple single-threaded               answer = 1+2+3+4      but if plus was some really complicated calculation the threaded variant might be faster. Now to the questions   * Are there any convention or standards about what the minimum length of code, operations or execution time that are defendable to put in its own thread?   * Do I even have to worry about this or are the compiler/processor so smart that they do all the work for me?  The reason I ask this question is that I saw an implementation of quicksort that started a new thread for every recursive call ending up with (n²) threads and there many of this threads just returned some value.


How to do external API testing (blackbox)

Assume you are using APIs from a vendor, how to make sure their API is working as expected? My main concern is sometimes the vendor pushed the changes to their code and break the API, we want to have some sort of automatic software to test them continually. How to deal with this?


How can I determine how to charge for supporting SharePoint sites and SharePoint development?

I recently created a site in SharePoint and I need to setup a maintenance/support agreement for the site. In addition to the site, there are some custom modules that were developed that we monitor. What considerations should I be making when determining how much to charge for supporting the SharePoint site and any custom applications developed for the site?


What are your techniques for storing numpy structures in django database fields and how do you serialize them for http?

I want to publish a small web project that is supposed to contain some of my research results to present it to the scientific community. All my analysis I ran so far have been written in python already, thus I considered to use django web framework to provide the results. This is, because I plan to show some visualization on up-to-date data, so I can run my analysis on new data by a cron directly in django. there are actually two questions on my mind so far, how I am going to start developing:   1. How can I easily store `numpy arrays` in sqlite to keep the structure of the array and which type of django database field suits best?   2. What is the best way to `json.dump` the `numpy 2d-arrays` to be able handle them in d3.js? As you can see it is quite about putting numpy + django + d3.js together. My first hacking was to store the numpy results as strings, but I think this is not quite the best, since I need to parse them again after pulling them from database. Concerning the second question I already found `simplejson.dumps` but unfortunately it does not really work on `numpy arrays` and thus, sometimes I needed to hack something like this               return  HttpResponse('{"array1" : '+simplejson.dumps(list(array1))+'}')      which I actually don't really like. So to put it together again: **What are your techniques for storing`numpy` structures in django database fields and how do you serialize them for `http`?**


Which is the purpose of using a workspace in Aptana?

I almost always do web development with a simple editor like Geany or Notepad++. Recently I'm starting with Aptana, and I'm a bit confused about the purpose/benefits of the workspace, my point is that I don't get it. Honestly is something that I really want to understand, why is it useful?, how to use it?


How do you identify "edge" cases on algorithms?

Basically how do you find out which could be your worst or best case and any other "edge" cases you might have BEFORE having them and so, how do you prepare your code for them?


Advice needed - CMS vs. framework

I am going to make a website for a client that wants to be able to alter the site about every week (changing pictures and textual information mostly). It is for a restaurant and so the client wants to alter the menu and images on an almost weekly basis. I've always made my websites and web apps from a framework or from scratch and have never worked with a CMS, but would a situation like this warrant the use of a CMS? What are some other options? Edit: I would really like a CMS to be a last resort option, but if it is most likely the best option I will use it.


Optimization as a branch: is that a thing?

My company has highly optimized scientific application which has become so big and complicated that new versions are literally taking t = infinity to produce. (E.G. I have an email which pre-announces a late 2007 release for something that has not been released yet.) New feature requests from the scientific team to the development team leads to a lot of arguing. This got me to thinking.. The application should be clearly written with good design, clear names and lots of automated tests. New features are added to this application. Run and pass the tests. Then this application is branched for optimization a.k.a. a release or production version. Again, run and pass the tests. Am I missing something? Is this a 'thing'? I guess my question is, if I bludgeon the VP of Product Development with this, would I be right (about the idea, not the bludgeoning)?


Why aren't databases integrated as a language feature?

Are there any programming languages that have a built-in database as a first- class language feature rather than connecting to an external SQL (or other) database? What would be the drawbacks and benefits to such a feature? What would such a feature look like and how would it change the way we program?


How to program object-oriented with a DI framework?

> **Possible Duplicate:**   >  Does “Inversion of Control” promote “Anemic Domain Model”? My impression is that projects using a DI framework like Spring or Guice tend to lose their object orientation and degenerate to a purely procedural design:   1. DI not only centralizes the question of which implementation of an object to use but also manages the life-cycle of these objects. Many OO **design patterns** , however, rely on the ability of business logic to wire objects. I wouldn't know, for example, how to implement a Strategy Pattern in Spring because the decision which of the concrete strategies to use, is statically determined by the configuration of the application instead of a piece of code. Same goes for decorator, composite, observer, ...   2. The reason above leads to a design where functionality and data are separated. Because you don't want to let the DI container decide when data is created, you split any code off the data in order to have only this part managed by the DI container. This is contrary to the idea of OO where **code and data should reside together** in one unit. This breaks the **encapsulation of data** because all fields of the data "beans" are exposed by public getters and setters.   3. You can't use **polymorphism** anymore because code is not linked to its data anymore and the "virtual functions" can't work. This leads to those instanceof cascades that we all know we shouldn't use. Also, we lose all those designs that rely on polymorphism.   4. The DI container will inject managed beans only in objects which are also managed by it. So you can't **mix managed beans and normal objects** because there can't be any "non-managed gaps" in the reference chain of managed beans. So once you started with DI, you need to put all other code under the control of the DI container and you can't use normal objects anymore. I suppose that this is the reason why the separation of code and data is done so rigorously in DI projects. I see that there are reasons why to use DI but is it really worth giving up so much? Don't people care about OO? Apart from this **article** , I can't find any discussions on this topic. Or is it just me who doesn't understand how to do this properly? Any ideas how the four points above can be tackled with? **Appendix 1: Explanation of strategy pattern** I refer to the example here. Let's assume there's a DI version of it where all implementations of `Strategy` and the `Context` are injected to `StrategyExample`. Then `StrategyExample` doesn't decide anymore which `Strategy` to inject into `Context` but the configuration would have already decided which implementation to inject into `Context`. So yes, DI heavily applies the Strategy Pattern. But it always does so statically.


What is better for prototyping: a statically-typed language, or a dynamically-typed one?

When working out the design for a new system, is it better to start with a statically-typed language (like Haskell), or a dynamically-typed language (like Ruby)? Arguments I can think of:   * With a static language, you can quickly create a specification and scope for what the program will do. With a dynamic language, you can quickly create a working demo to present to the customer for review.   * With a dynamic language, you often avoid having to rearrange data structures and refactor code when you change your design. With a static language, you can define types before implementation, keeping the code to maintain very small.   * With a static language, you have to figure out in advance what your program will do. With a dynamic language, you can start writing code, and let the design grow organically. As Paul Graham says in Hackers and Painters: > A programming language is for thinking of programs, not for expressing > programs you've already thought of.   * With a static language, the compiler can help identify many types of bugs. With a dynamic language, you can begin testing and finding bugs sooner. Static and dynamic typing both have advantages and disadvantages as far as prototyping is concerned. However, they both seem to me like equally valid approaches. Based on your experiences, which one is ultimately better? * * * ## Notes ### Prototyping in natural language A third type of language to consider: natural language. Instead of prototyping in code, one can prototype in writing. The customer can then read your documentation and critique your design early on, but cannot toy around with a working demo. If well-written, the documentation can make implementation in any language straightforward. Caveats:   * The documentation may be tedious to read through, and difficult to digest without being able to see it. I speculate that a customer would rather experiment with something that works rather than read a wall of text (and images).   * Prototyping an application in English rather than in type definitions is more verbose and less concrete. ### Haskell types are descriptive Note that types are particularly descriptive in Haskell, more so than in many static languages like C++ and Java. For example, suppose I have a function with this type signature in Haskell:               foo :: forall a. [a] -> a      _A function that, for any type`a`, takes a list of items of type `a` and returns a value of type `a`._ Even without knowing the function's name, I know for a fact that:   * It does not perform input/output or modify any values (well, unless it uses unsafePerformIO incorrectly), because Haskell is purely functional.   * It cannot treat the items as, say, integers, because it has to support _any_ type.   * It _has_ to use the input list (that, or throw an exception or go into an infinite loop). Otherwise, where would it get a value of type `a` from? Therefore, the only thing this function could possibly do (other than fail) is extract an item out of the input list and return it. Although I still do not know which item it will use, `[a] -> a` tells me just about everything else.


Unit Testing Open Source projects that require keys for api calls

What's the recommended method for setting up tests on code that requires a private key to make calls to external web services? Full on mock objects or is there a way of distributing open source unit tests with a neat method to add in a tester's own private key at test time? I'm using python but any general best practice


Long parameter list versus long state variable list

In a C++ book, the author says we no longer need a function with a long parameter list because most of the parameters can be refactored into state variables in a class. On the other hand, a functional programming book says state variables are evil because it causes side-effects which cause bug-prone and hard to parallelize code. I'm getting puzzled. Should the code avoid relying on state variables as much as possible by moving its state variable into the function parameter list?


Why prefer a wildcard to a type discriminator in a Java API (Re: Effective Java)

In the generics section of Bloch's Effective Java (which handily is the "free" chapter available to all: http://java.sun.com/docs/books/effective/generics.pdf), he says: > If a type parameter appears only once in a method declaration, replace it > with a wildcard. (See page 31-33 of that pdf) The signature in question is:               public static void swap(List<?> list, int i, int j)      vs               public static void swap(List<E> list, int i, int j)      And then proceeds to use a static private "helper" function with an actual type parameter to perform the work. The helper function signature is _EXACTLY_ that of the second option. Why is the wildcard preferable, since you need to NOT use a wildcard to get the work done anyway? I understand that in this case since he's modifying the List and you can't add to a collection with an unbounded wildcard, so why use it at all?


Asp.Net MVC Windows authentication - vulnerabilities of http vs https?

I am developing an ASP.Net MVC 3 intranet site that will use Integrated Windows Authentication exclusively. What are the vulnerabilities of the challenge/response authentication traffic being sent in plain text? Will someone sniffing the network traffic be able to hijack an authenticated session?


Is the upgrade path from Win32 to .NET to WinRT feasible?

I support a VB6 application. It's currently being replaced, module by module, with .NET (including a lot of new features as we go). The GUI is in WPF, but with almost zero coupling to the business logic, so that's not as important. I'm hoping the migration will be done by mid-2012. I'm reading some of the news out of the MS build conference, and it looks like WinRT with Metro will be the API and GUI of choice for future development, especially if you want your application to run on mobile devices (which we will, certainly). What kind of speed bump are we looking at when we (eventually) migrate from .NET to WinRT and Metro? It looks like C# and Xaml will be around, but WinRT is not .NET. Are the API's compatible (just a matter of changing an option in the VS build menu)? If they're not, will there be a one-way conversion tool? Will it be possible to easily maintain one application that runs under .NET/WPF on Windows XP/7 systems and simultaneously builds to a WinRT/Metro target during the time when we have all those systems in-house?


A better way of doing Regex?

I really dislike regular expressions, each time I come back to it I seem to have to relearn it. It's also incredibly hard to maintain, modify and at a glance understand what it is doing. Has anyone ever tried writing another layer on top of it that turns more semantic 'sql like' statements into regex? I imagine it working along the lines of:               AnotherString = "coffee hello beep 15"          FindString.StartsWith string longer than 5     FindString.Contains "beep" after "hello"     FindString.EndsWidth int < 20     FindString.DoesntContain "no!!" and DoesntContain "what!"     Foreach FindString match in AnotherString         ...     Next      This is probably not the greatest example ever, but the idea is that the pattern is built with some sort of semantic meaningful language that can break down into traditional regular expressions. The above would be a lot easier for a developer to modify. I sort of invision it being like SQL/Linq to some degree. It would make regex a lot more semantic and maintainable. Has this been tried before, and is it a bad/good idea to try this? Could it work? **Edit** Perhaps this is a better example (I know URL's are notoriously difficult to parse and this is over simplified):               string UserInputtedURL = "http://www.google.com/page.html?ID=5"          Protocols = {"http", "https"};     Domains = {"com", "net", "org"}     Rule.CaseSensitive = false;     Rule starts with Protocols OR starts with "www";     Rule followedby string endson "."     Rule followedby Domains     Rule if stringend or endswidth " " end else continuewith Ruleset2          RuleSet2.startswith "/"     etc...          if(UserInputtedURL.Matches(Rule)){         // URL is valid!     }


How to tell if an employer has been banned from Apple's App Store?

I have a potential employer who desperately wants to produce an app, but for some reason they are refusing to get a $99 company dev account, saying the application process would be too difficult and tedious. And yet they want me to create a single-person account. I think they've been banned from the Apple's app store but how can I verify it? Thanks.


C++ and the suitable libraries to develop Autocad/Autodesk/CAD applications?

I saw a job opening where the requirement was for a developer to develop CAD tools using C++ and OpenGl libraries. I am a civil engineer and want to be part of such a projects so I thought to learn C++ and some libraries which could help me to move forward for such job opportunities. I know a bit of C++ but I am quite unfamiliar with these libraries(qt, openGL). Can somebody tell me/guide me which is the most suitable library and most required library to develop such applications?


How to make a table structure for products to be available for both wholesale and retail?

Ignoring the different column details like colors, shapes, and sizes, I already have an idea of dealing with that, I'm more interested in dealing with retail pricing, whole pricing (with or without a table), and possibly discount. If anything, I want to know what I should also take account for. Will it just be adding a quantity column, two pricing cols, and two discount columns, and a quantity limit? If I were to add a pricing table it would be inserted as a json file, would this be a bad idea? Please give any insight about this.


In choosing a service-oriented architecture framework that needs to work with .NET and with Java, what to look for?

I planning to write an application in which there will be a service (call it A) listening for particular commands. This service will then relay those commands to other services (call them B and C) which are written, respectively, in .NET and Java (service A chooses which of service B or C to which to relay depending on the contents of the request to service A). I am looking for a framework that will allow for interoperability with both .NET and with Java, for example WCF or JAX-WS, or writing a custom framework (e.g., JSON REST commands over HTTP, similar to http://code.google.com/p/selenium/wiki/JsonWireProtocol). What questions/aspects should I consider in deciding?


A Crash Course in ASP.NET

I'm a .NET developer who's eying up new jobs for a change of pace. My career so far has led me to become quite proficient with C#, WPF, WinForms, MSSQL, and all kinds of goodies in the .NET framework including Entities, Parallel Tasks, etc. However one thing that I'm obviously lacking is ASP skills. Nearly every job in my area (Minneapolis/St.Paul) requires strong, 3+ years experience with ASP.NET. I feel confident in my ability to pick up new technologies, especially in the .NET world, however with ASP I'm not sure where to start. As with most things in .NET, there's probably the hard, old way to do things, and the new, elegant way to things. Just firing up the templates in VS2008, there are several ASP templates that implement various technologies such as Entities. I have no idea where to start. So, alluding to the title of this post, I'm looking for a crash course in ASP. Given that it's a web technology, I'm having trouble thinking of a side project as an excuse to learn it as I would with otherwise. Can anyone give me a landmark as to what I should focus on learning? Is there a good amount of ASP stuff I can ignore? Related, is there a more recent starting point that I could begin with that would give me an edge over the tired ASP guys stuck doing things the old ways? :P Just looking for a little guidance. Thank you much!


What does it mean for an architectural style to be document-centric?

I heard it said that REST is "document-centric". Unclear what this meant, I began poking around and found the term **document-oriented** being used of databases, particularly NoSQL databases, and in contrast to a barebones key- value store. Thus it seems that documented-orientation of databases has to do with their internal representations being JSON or XML; I saw on the Wikipedia page that many document-oriented databases claim to support a RESTful API, but not having experience with any NoSQL databases and also being new to REST, I'm unsure what that means (the database itself is directly accessible through a service?); and anyway, as far as I know, REST does not constrain the underlying data model of an application, but only its service contract. So what does it mean to say that REST is document-centric/oriented? Does it mean that REST constrains a service to use JSON or XML in its contract? Does it mean that REST is more friendly towards NoSQL databases than conventional relational databases?


Who determines what is best practice?

I've often searched for answers relating to " **best practice** " when writing code. And I see many questions regarding what is best practice. However, I was thinking the other day. Who actually determines what this best practice is? Is it the owners or creators of the programming language. Is it the general developer community that is writing in the language and it's just a gut feeling consensus. Is it whoever seems to have the highest prestige in the developer world and shouts the loudest? Is best practice really just another term for personal opinion? I hope this is a constructive question. If I could word it better to ensure it doesn't get closed please feel free to edit, or inform me otherwise.


AND is better or using Internal "IF"

In a situation like this:"               if ((metadata != null) && (metadata.TypeEnum != VariantInfoMetadata.CellTypeEnum.Status))      do you recommend to keep the code as it is above? Or is it better to make a nested "if" statement and breaks the condition into two sections where "outer if" makes sure metadata is not null and inner if does the rest of the checking. I think a nested if takes care of possible null reference exception if value of metadata gets null.


Using Domain name in EULA of a software rather than my name in the Licensor field

I intend to sell a software solution.I have already registered a domain but i dont have a registered company.Can i use my website/domain name eg:myproduct.com for the licensor field in the EULA rather than using myname.I will renew my domain yearly is there a problem with this.Do you know any software companies that work like this.Im confused about the users point of view will they find it a bit different. Please help me out.


Should you Create Class Diagrams before or after implementation?

The way I see it if you create one before you get the advantage of:   * Planning ahead   * Overview of the project but you lose:   * Time (doing work you'll probably end up repeating when writing code) On the other hand, I could just create them all after writing my code just to keep it as a reference for future developers. Which one serves the purpose of class diagrams and which is more advantageous?


Models per database table?

I am using codeigniter, and have found myself in a similar situation where I have repeated Model methods. I am creating a Model per Controller. But I would creating a Model per database table be considered good practice? That way methods aren't written twice. Instead of Model per Controller or Several small Models that are shared. Example if I have a model method get_user($user_id) I could write it on users_models.php ... One of the downsides I see of this is that I might have to call several models, rather than just controllername_models.php . Could loading several models where several methods might not be used from a controller affect performance and speed? What could be the best way to tackle this down? Note: There are similar question, but they do not cover the ground of Model per database table.


Is it better to return NULL or empty values from functions/methods where the return value is not present?

I am looking for a recommendation here. I am struggling with whether it is better to return NULL or an empty value from a method when the return value is not present or cannot be determined. Take the following two methods as an examples:               string ReverseString(string stringToReverse) // takes a string and reverses it.     Person FindPerson(int personID)    // finds a Person with a matching personID.      In `ReverseString()`, I would say return an empty string because the return type is string, so the caller is expecting that. Also, this way, the caller would not have to check to see if a NULL was returned. In `FindPerson()`, returning NULL seems like a better fit. Regardless of whether or not NULL or an empty Person Object (`new Person()`) is returned the caller is going to have to check to see if the Person Object is NULL or empty before doing anything to it (like calling `UpdateName()`). So why not just return NULL here and then the caller only has to check for NULL. Does anyone else struggle with this? Any help or insight is appreciated.


How to store collections of linked Text objects in database

I'm writing a Java program that works as a presentation of a written document, which needs to be stored in a database (I'm using MySQL, but am open to suggestions of other DB types). The Essay class is a collection of objects of the Paragraph class (more specifically `Essay extends LinkedList<Paragraph>`, which consists primarily of an `int ID` and a `String content`. The Essay object is stored as its own table in the DB, which is fairly straightforward (with columns `int paragraphId` and `Blob text`), and I do a simple query that creates a new Paragraph object for each row in the table when the program gets initialized. Within each paragraph, certain hyperlinked words link to other Essay objects, which also need to be stored in the database. My question is how best to save them - the options I'm considering are:   * Creating a single additional DB table where each essay is stored on a row, with paragraphs being stored in a single text object separated by a delimiter, and the program separates them into separate Paragraph object as it pulls them from the DB. (this is fairly manageable because these linked essays are much shorter than the main essay).    * Create a single additional table, with a large number of content columns, storing each paragraph in a separate column. Then, when the data is pulled from the database, it creates a new essay for each row and a new paragraph for each column in that row, until it comes upon one that is null.   * Dynamically create a separate DB table for each linked essay, setting it up identically to the primary one. This doesn't seem ideal because it would end up being a very large number of tables, and many of them would only have two or three paragraphs, making a new table seem wasteful.    * Do a different arrangement altogether: Have one Paragraphs table, where all paragraphs from all essays are stored, and another table called Essays, which uses a `SET` datatype to store the IDs (foreign keys) of the paragraphs included in each essay.  I've modified my actual use case here to make it more simple to explain. I'm new to database programming, and am doing this largely as an exercise, so I'm looking for general tips about the pros/cons of these approaches, as well as any additional suggestions.


Leading a  not-so-good team

How would you manage if you are allocated a team of 5 with, say, 4 incompetent programmers and you are asked to lead? Obviously you can't code for the 4 guys (you can, but that is not a good idea. At least I burned out doing that). Have you come across these kind of situations? Edit: I think I sounded rude by choosing a wrong word (incompetent) to address my problem. To rephrase the question, how do you deal with people who do not complete assigned tasks (for whatever reasons [ranging from incompetence to 'I don't care' stuff])?


Thinking in C++

> **Possible Duplicate:**   >  Is there a good book to grok C++? I've been looking for a good book to understand the C++ (and the OOP) as well as I can do, and during my searches I found **Thinking in C++** (wrote by Bruce Eckel) and many excited opinions about it. So, my question is: Is this book really good, or there are something better to understand C++ in detail?


Why not embed styles/scripts in HTML instead of linking?

We concatenate CSS and JavaScript files to reduce the number of HTTP requests, which improves performance. The result is HTML like this:               <link rel="stylesheet" href="all-my-css-0fn392nf.min.css">     <!-- later... -->     <script src="all-my-js-0fn392nf.min.js"></script>      If we've got server-side/build logic to do all this for us, why not take it one step further and embed those concatenated styles and scripts in the HTML?               <style>.all{width:100%;}.my{display:none;}.css{color:white;}</style>     <!-- later... -->     <script>var all, my, js;</script>      That's two fewer HTTP requests, yet I've not seen this technique in practice. Why not?


Programming late at night problem

I recently found out that programming late at night causes sleeping problems, so what are the best hours for 'after-job' programming? Maybe there is some time interval that should be set after finishing programming and going to bed, or some activity involved?


Is it possible for business logic not to creep into the view?

I've developed for several web application projects for the last 3 years, both personal and at work, and I can't seem to figure out whether it's possible for at least _some_ business logic not ending up in the view layer of the application. In most cases there will be problems like "If the user has selected option x then the application must enable him to supply info for y, if not then s/he should supply info z". Or do some AJAX operation which should apply some changes to the model but NOT commit them until the user has explicitly requested so. These are some of the simplest problems I've encountered and I can't figure out how it's possible to avoid complex logic in the view. Most of the books I've read describing MVC usually showcase some very trivial examples, like CRUD operations that just update data on the server and display them, but CRUD is not the case on most rich applications. Is it possible to achieve having a view with no business logic at all?


Getting solutions off the internet. Bad or Good?

I was looking on the internet for common interview questions. I came upon one that was about finding the occurrences of certain characters in an array. The solution written right below it was in my opinion very elegant. But then another thought came to my mind that, this solution is way better than what came to my mind. So even though I know the solution (that most probably someone with a better IQ had provided) my IQ was still the same. So that means that even though i may know the answer, it still wasn't mine. hence if that question was asked and i was hired upon my answer to that question i couldn't reproduce that same elegance in my other ventures within the organization My question is what do you guys think about such "borrowed intelligence"? Is it good? Do you feel that if solutions are found off the internet, it makes you think in that same more elegant way?


Is there a best practice for populating a dropdown in ASP.Net MVC?

I'm coming into a project where the overlying method is to open the page, then use jquery AJAX calls to populate all of the dropdowns dynamically in the page. To me, this seems like an extra burden on the server and it looks terrible, plus the functionality seems to be limited as the user can start using the dropdowns even though they aren't loaded yet. To me, it seems to make much more sense to create a SelectList in the model and populate the dropdown in the View before the page is ever sent over to the browser. Am I missing something in my thinking here? Is there a good reason to dynamically bind the dropdown via AJAX initially?


Global vs Individual object event handlers

Lately I've been studying a lot of javascript samples, both with/without libraries, jQuery to mention one. As an old JavaScript developer, I learned early to make use of unobtrusive javascript where one were adding mouse click events to a global handler using `document.onclick = mylib.document_onclick;` Then, by tagging any element with a custom attribute/property/expando, I been able to deal with all kinds of functions in a very simple way.               //  HTML
 Logout
     Start page 1     Start page 2               // JS          document_onclick: function (e) {         e = getEvObj(e);                             // custom method to get event object         var evSrcTag = getSrcObj(e);                 // custom method to get source element              //mouseclick         if (evSrcTag.getAttribute('data-mc') != undefined) {             switch (evSrcTag.getAttribute('data-mc')) {                      case 'logout':                     if (!confirm(myconfig.msg['asklogout'])) {                         return cancelEv(e);          // custom method to cancel the event                     }                     break;                      case 'ajax':                     //process ajax request as javascript is available, cancel default event (href)                      //case ......             }         }     },      Today I see a lot solutions where the event is bound/attached straight to a specific element. It appears to quikly become a long list of handlers to be added, together with individual functions and class names tied/added.               //  HTML     create link dynamically     create link dynamically     create link dynamically               //  JS     $(function(){              $("#anchor1").click( function() {             $("#anchor1").append('test1');         });              $("#anchor2").click( function() {             $("#anchor2").append('test2');         });              $("#anchor3").click( function() {             $("#anchor3").append('test3');         });          });      Referring to the way setting up handlers, is one approach better than the other, and if so, which one is and why?


how to model this relationship ? in ERD

I have three entities :               Technician     Vehicle     Repair      The question is how to model this in ERD? Knowing that a technician can repair multiple cars, and the same car can be repaired by one and only one technician? How should the repair entity tied to all this?


"Overtime is part of the job" true but a bad attitude?

My manager told me that working overtime is just part of the job and that I'm expected to work overtime. We're not paid overtime like most companies. I'm aware that most programmers put in 50-60+ hour work weeks, but is that the attitude a manager should take? It seems like they're taking it for granted. Or maybe I'm totally wrong and it's completely normal :P


Turning n-dim points into m-dim where m<n and where point-to-point distance deviation is minimized

I want to apply k-means clustering to a (sparse) adjacency graph. For this I need to assign the nodes to a position in an euclidean space. Trivially I can do this by having a space with as many dimensions as there are nodes where each component corresponds to another node. Now, in order to make the clustering a bit more understandable, or maybe just different, I'm thinking about whether there are ways of "folding" the n-dimensional space of points into a more manageable space, perhaps 3-dim or maybe just m-dim where m < n. While doing this I want to maintain distance relations between nodes - so I want to minimize the deviation between the straight line distance between any two points before the fold compared to after the fold, or in other words, the sum of all deviations. So I can't seem to find any to-the-point info on this when looking. Perhaps I'm missing terminology. What good/efficient methods are there for this? Algorithms? It seems like a somewhat archetypical optimization/mean square minimization problem. A simple base case:               P1 = (1,1,1)     P2 = (1,1,0)     p3 = (1,0,1)     newPoints = spacefold(2,[P1,P2,P3])          // example output:     // newPoints = [(1,1),     //              (1,0),     //              (0,1)]      For this example they happened to be conveniently placed in a plane - removing the x component gives an optimal solution.


Looking at so many programming languages we have today, each one being unique in it's own way, I've tried to figure out what the first programming language written for computers is. Looking at the release date for the popular ones I got somewhat close but I didn't look at less obvious ones, programming languages which are either dead or very little use nowadays. Fortran is the closest thing I got but I don't know if it's real. In a nutshell: What was the first programming language written for computers? Are there any languages that derived from that language?


Layered architecture using Entity Framework with different class libraries

Our business requirements required to create a layered and modular architecture. So I designed an architecture to make it as decoupled and as modular as possible. I will list my layers below   * ASP .NET MVC Application (UI)   * Business Logic Layer (BLL)    * Data Access Layer (DAL) I have further used IOC where each BLL module defines its Data Access requirements in terms of interfaces. So DAL has now to implement these interfaces. It is important to note that   * Both UI and DAL are dependent on the BLL   * BLL is not dependent on any other solution. Using Interfaces I have done IOC so now DAL is dependent on BLL and not the other way round.   * BLL is not just one project but a set of class library projects - one class library each for each business module.   * DAL is a single class library project "shared" by all the BLL projects (since Database is same and it did not make sense dividing DAL into separate projects). I will not go into details here but let us say there was a decision to use EDMX. However now I do not see how EDMX will fit into this mix. I believe I am not the only person ever to divide the BLL into different class libraries but have a single DAL project. But can EDMX or for that matter any ORM support such "distributed" architecture ?


Better background or more hands on experience

Recently, I just finished Michael Hartl's rails tutorial. Throughout the book he recommended The Rails 3 Way after you finished his book. From your experience do you think it would be better to read another book or start building an app and figuring out things on my own?


Why do we not prefix Enums, Abstract classes and Structs?

The C# community has so ubiquitously used the "I" prefix to denote an interface that even the most inexperienced programmers know to use it. Why is it then that we do not prefix enums, abstract classes or structs (possibly with "E", "A" and "S" respectively)? For example, if we did mark all abstract classes with an "A", it would provide valuable information about that type which, while it could be inferred, is not immediately obvious. Please note that I am not advocating for this change, I am merely trying to understand why we do not do things this way. This thread answers why we do use the "I" prefix but doesn't answer why we _don't_ use other prefixes.


The best possible way to implement Business Rules in PHP

I'm planning to write an e-commerce app using PHP & MySQL with lots & lots of custom rules. Say for example, I want to have a rule like " _Give Customer X, a 10% a discount for Product Y if he bundles it with Product Z_ " I've heard about Business rules engine(in Java and others). I intend to implement a flexible business rules functionality **without hard-coding** anything into PHP and with a good, solid architecture with the goal of maintainability and re-usability with the help of PHP OOPS. Please advice me on the following aspects: Does decision table fit my intended purpose? How can I change rule/business logic of the PHP application without redeploying/re-writing?


Are there any free tools to measure web project's performance, security and other standards?

Are there any open-source tools to measure the standard of a web application project? I want to verify my project for:   * Possible security leaks (SQL Injection etc.)   * Performance    * Stability (in high concurrent environment) and other quality metrics.


Is the 'Law of Demeter' applicable to public/API method signatures?

Given that changes to the API/public method signature should be minimal to prevent breaking those client codes that use these methods, I was wondering if the Law of Demeter is less applicable to these. A simple example:               class Account() {        double balance;        public void debit(Transaction t) {           balance -= t.getAmount();        }     }      Notice that the debit method passes the Transaction object rather than just double amount (the 'Law of Demeter', as I understand it, would say to just pass the required info, in this case just the amount, not the Transaction object...). The reason behind this, is because the method in the future might require some other Transaction properties aside from amount. From what I understand, this will prevent breaking the method signature by adding a new parameter in the future. Does this make it a sensible choice then? Or am I missing something?


Best solution for getting referral information in PHP

I am currently redoing some link structuring on a website. In the past we have used specific php files on the last step to direct the user to the proper place. Example:               www.example.com/action/go-to-blue.php      or               www.example.com/action/short/go-to-red.php          www.example.com/action/tall/go-to-red.php      We are now restructuring to eliminate the `/short/` or `/tall/` directory. What this means is now `go-to-blue.php` will be doing some extra processing to make sure it sends the visitor to the proper place. The static method of the past was quite effective, because, well, if they left from that page we knew we had it right. Now since we are 301 redirecting `action/short/go-to-red.php` to just `action/go-to-red.php` it is quite important on `go-to-red.php` that we realize a user may have been redirected from `/short/` or `/tall/`. So right now I am using HTTP_REFERRER and of course in my testing that works fine, but after a lot of reading it is clear that this is not a solid solution, so I was starting to brainstorm on other ways to check and make sure we get the proper referral information. If we could check HTTP_REFERRER plus some other test, I would feel confident we have a pretty good system in place to send the visitor to the right place. Some questions/comments:   1. Could I use a session variable or a cookie to accomplish this goal?   2. If so, would that be maintained through the 301 redirect? I don't see why it wouldn't be..   3. Passing the url in the url is not an option in this case.


How would you design an application with many target platforms and devices?

I'm in a very beginning of the design phase of an application that will have to run in the following platforms/devices:   * Desktop: Windows, Linux & Mac   * Mobile: Android, iPhone/iPad & Windows Phone 7   * Web: Silverlight I will use C# on Mono and I want to maximize code re-usability. Except for the desktop (I'll use WinForms/GTK#), **my concern is related to many different GUI that I will face**. What would be your approach? Obviously, the views will be different, but what about the controllers, data access, utility classes, etc. Is it really acceptable to share everything but the views?


Thinking of switching from mac to windows, need a little guidance

Looking to switch to Win7 as machines are cheaper, easier to repair and as a web developer, I wouldn't have to emulate IE anymore. I want as smooth a transition as possible, so what would be the closest match to my current stack of apps. MAMP TextMate Transmit Filemerge (for use with GIT DIFF's)


Colour curves tool for "value" channel

I'm trying to write a program to read GIMP curves files and apply them to an image. I have successfully implemented the curves for the red, green and blue channels, but I can't get it working for the value pseudochannel. For the colour channels I just create a lookup table from the curves, and iterate through the pixels doing something like:               red = redlookup[red]     green = greenlookup[green]     blue = bluelookup[blue]      Good so far, I get exactly the same results in my program and GIMP. In the GIMP page linked above, it is claimed that the value channel is defined as `v = max(r, g, b)` but I don't understand how to adjust each colour channel from looking up this value. I'm currently knee deep in GIMP source code but it is quite convoluted. **In summary:** if I have an array `valuelookup` representing the curve for the value pseudochannel, how can I use it to adjust the RGB values for each pixel in an image? * * * GIMP defines the channels as follows: **Value** > The curve represents the Value, i.e. the brightness of pixels as you can see > them in the composite image. **Red; Green; Blue** > The curve represents the quantity of color in each of the three RGB > channels. Here, dark means little of the color. Light means a lot of the > color. The values range from 0 to 255.


Benefits of integration platform

We are looking at introducing an integration platform. In the begining it is an extra layer and an extra cost. But after a while the service that a new system needs will be available on the integration platform, therefore saving development effort. Question is does anyone know of any studies that look at how long the above "a while" is? Or are there any ROI studies on the use of integration platforms?


Applications of Artificial Intelligence on regular business applications

This is a doubt I had for a really long time. I'm currently learning the basics of AI, mostly from Peter Norvig's book. I already know that you can use several AI techniques in Data Mining and Business Intelligence, but I wonder if there aren't more "normal" scenarios where you can apply AI. Could a scenario where an application can be improved by using AI? Books really don't specify more than a few select business cases. Thanks in advance **EDIT** Based on comments i'll be more specific. How can an application be improved by usig AI thechniques? And I don't mean adding search capabilities (when there are tools for that already) or BI stuff (I already know that to be AI based). What I want to know, is if it is possible to take a regular application (take a shipment scheduling application) and apply some AI techniques to improve its results, or to make recommendations to the user.


How to migrate my thinking from C++ to C#

I am an experienced C++ developer, I know the language in great details and have used some of its specific features intensively. Also, I know principles of OOD and design patterns. I am now learning C# but I cannot stop the feeling not being able to get rid of C++ mindset. I tied myself so hard to the strengths of C++ that I cannot live without some of the features. And I cannot find any good workarounds or replacements for them in C#. What **good practices** , **design patterns** , **idioms** that are different in C# from C++ perspective can you suggest? How to get a perfect C++ design not looking dumb in C#? Specifically, I cannot find a good C#-ish way to deal with (recent examples):   * Controlling the lifetime of resources that require deterministic cleanup (like files). This is easy having `using` in hand but how to use it properly when ownership of the resource is being transfered [... betwen threads]? In C++ I would simply use shared pointers and let it take care of 'garbage collection' just at the right time.   * Constant struggling with overriding functions for specific generics (I love things like partial template specialization in C++). Should I just abandon any attempts to do any generic programming in C#? Maybe generics are limited on purpose and it is not C#-ish to use them except for a specific domain of problems?   * Macro-like functionality. While generally a bad idea, for some domain of problems there is no other workaround (e.g. conditional evaluation of a statement, like with logs that should only go to Debug releases). Not having them means that I need to put more `if (condition) {...}` boilerplate and it is still not equal in terms of triggering side effects.


What to consider when designing a web application that will be deployed under a load balancer?

I am currently maintaining a Java web application that is initially designed to work only as a single instance (not in a cluster/farm). Now, the client is planning to upgrade their infrastructure and part of their plan is to place our web application behind a load balancer.      I have already identified several serious design problems:   1. Users can upload files and our application store those files in the local filesystem.   2. There are scheduled jobs that might cause problems when executed concurrently (i.e. generating files).   3. Session variables are heavily used in most modules.    I need opinion on my proposed solutions below.     1. I can solve item 1 by storing all files in an external/shared storage (SAN, etc..)    2. With item 2, I can create a locking mechanism in the database so when the scheduled jobs run, the web apps will first check the table and only the first one to update will run the said job.    3. Actually, I'm still not sure if item 3 can cause problems. If a user logs in to our application and the load balancer directs him to Server 1, is it possible that the load balancer will point him to Server 2 the next time he click a link? I have no idea yet how the load balancer works in this level.  Also, what are the other things that I should consider when designing a horizontal-scalable web application [from scratch]?


Is it practical to have perfect validation score on HTML?

I was in a heated discussion the other day, about whether or not it's practical to have a perfect validation score on any HTML document. By practical I mean:   * Does not take a ridiculous amount of time compared to it's almost-perfect counterpart.   * Can be made to **look good on _older browsers_** and to **be usable on _very old browsers_**.   * Justifies the effort it may take to do so (does it come with some kind of reward on SEO/Usability/Accessibility that cannot be achieved in a simpler way with almost-perfect validation) So basically, **is perfect validation score practical on any HTML document?**


Modularity vs Single class simplicity

I have been part of the organization I work in for the past year and a half or so. The company basically writes Perl code and they have large amounts of legacy code which originally prevented the company from moving forward with any code changes. My first observation with the existing code was non existence of Modularity. Over the time I worked here I, with the help of a few (who left the company), did a lot of hardwork Modularizing all the core sections of the application. I believe that we now have about 70% of the core systems modularized, coherent and layered. At this point in time I am accused of complicating the system design and everything I try to do is sort of looked at with suspicion. To design these systems I applied all the best design approaches(patterns) and methodologies(SOLID) available or known to me. When I wrote it, it was all appreciated but now the developers want to revert back to what they believe as simpler methodologies(which basically involves having large single classes, doing 100's of things). I still do not believe that those approaches are actually going to lead to simpler design but no one is actually ready to listen. To give an example, our code basically loads a bunch of files during its lifetime. Traditionally the class handled a lot of things like loading the file, repeatedly checking if the file has changed, is the right version of the file loaded etc. We also load a different set of files for test cases to ensure that it is working fine. All this was done very un organized fashion earlier. Every one created their own version of the file. There were lots of versions of these files and they were un manageable. I introduced a subsystem that will load you the right file(do the version verifications) given a name and a configuration that will tell all the versions of the file available. It eventually ensured that only two to three versions of the files are used across all the test cases. It basically follows a facade and factory pattern where the loader will create the right file object, which will have interface to load, save and should_reload. It was eventually even used to load contents from CouchDB as they only represent a document. This is now too complicated for the developers and no one really reads the code or the documentation I wrote. I do agree that going back to our old system will remove one sub system but will bring back the problem of un manageable number of files. At this juncture I find myself quite unsure of all the things I have learnt. I find myself not really interested in suggesting any improvements as my solution will only be accused of being too complicated. What do you think I can do at this point in time?


How to develop an algorithm for brute-forcing / backtracking?

As a beginner programmer, I don't know how to conceptually think about brute- forcing. My mind can't really fathom how to write code that will try every possibility. I have a problem that I want to solve. Here is a code snippet (there are other functions, but no reason to include them here, they just do background work):               main():         step_segment = []           # contains current segment             STATS = [250,0,0,0,13,0]        # contains 1 step (current step stats)             # STATS = [step_id, danger, danger_limit, rnd, b_loop, enc]              # Temporary Interface         choice = None         while choice != "0":             print \             "\n1 - Benchmark Run"             choice = raw_input("Choice: ")             if choice == "0":                 print "\nGoodbye."                  elif choice == "1":                 while (len(step_segment)) < 128:                     step_segment, STATS = take_step(step_segment, STATS)                     if STATS[5] == "B":                         "Dont know what to do here. Try every possibility!?"      **The goal:** I want to produce a list of every possible 'route' through a segment, along with how long it takes. **Description:**   1. I will take a step in the route (There's only one direction: forward). Every time I take a step, my stats are updated. This takes a step and updates the stats: `step_segment, STATS = take_step(step_segment, STATS)`   2. A list of steps taken, along with the stats, are kept in `step_segment`. This is so I can 'undo' an arbitrary amount of steps, if I want. To undo a step call the function: `step_segment, STATS = undo_step(step_segment, STATS)`   3. I can see how long my current route has taken by doing: `time = frames(step_segment)`.   4. At some point, I will get into a Battle. I get into a Battle when `STATS[5] == "B"`   5. When there is a battle, I simply have two choices: **i.** Fight the battle, or, **ii.** Run away.   6. If I want to Fight, I do: `step_segment = do_fight(step_segment, STATS)`. This also records that I chose to fight, along with the stats, in `step_segment`. (So I can undo it, if i want).   7. If I want to Run Away, I do: `step_segment = run_away(step_segment,STATS)`. Can someone advise me, how I can code a brute forcer for this problem? **Specifically** , I would like to know how I can tell the computer to try every possibility; I simply cannot think how to... >.<' I want to see every possible combination of Run & Fight (the only two choices, when I reach a battle). There are only around 200 possibilities. I only need to take 128 steps, so there are a finite amount of possibilities, hence: `while (len(step_segment)) < 128`. I just don't know how to accomplish such a thing in Python. My whole reason for learning how to program is to solve this problem.. I think I can explain the solution in English, as I have done above, but I don't know how to code it. I would be **very** appreciative if someone could advise me on this!! Thank you.


OO design for client-server/RPC/n-tier data transfer (specifically SignalR)

I'm using SignalR to implement a client/server system, but I guess this question could apply to other tiered/client-server/RPC systems. If you aren't familiar with SignalR, you basically create a server-side class (called a "hub") that contains methods you want to expose to clients. On the client- side, SignalR exposes a "hub proxy" class via which you can invoke the server- side hub methods. Let's say I want to remotely control cars from my client application. My first thought was to create an abstract `CarBase` base class with methods such as Start(), Stop(), Steer(), etc. On the client-side I would implement a concrete `Car` class whose methods would invoke (via the SignalR hub proxy) the relevant methods on the server hub. Similarly, on the server-side I would implement a concrete `Car` class, but this time its methods would carry out the relevant actions on the "physical" car. Let's say the client wants to start a car:-               var car = new Car();     car.Id = 123;     car.Start();      The Car's `Start` method would basically invoke the relevant server method via the hub proxy, e.g.:-               public override void Start()     {         _hubProxy.Invoke("StartCar", this);     }      _Here is my first question_ \- is it acceptable for the Car class to have a dependency on the hub proxy, and pass itself to the remote method like this? I've read that functionality such as persistence is a separate concern and should therefore live in a separate class, and I'm in two minds about whether that guideline applies to what I'm doing here. If so, it would result in client code such as `_hubProxy.StartCar(car);` rather than the more OO- friendly and intuitive "car.Start();". Moving on, on the server-side, the "hub" class's StartCar() method might look something like this:-               public void StartCar(CarBase clientCar)     {         // Instantiate a server-side Car         // (this implementation interacts with the "physical" car).         var serverCar = new Car();              // Map properties from received client car         serverCar.Id = clientCar.Id;         .. etc..              serverCar.Start();     }      Is this an acceptable approach, i.e. having the client-side pass in its Car object? Or should I be passing around something else, e.g. just the car's ID and other pertient properties? I guess I can't avoid instantiating the server- side Car (and mapping its properties) - after all, this is where the functionality to interact with the physical car lives. I've gone round in circles trying to think of a better solution, and have reached the point where I can't see the wood for the trees.


What is a good rule-of-thumb for naming link-tables?

In the same way that a `publication` table might relate to a `person` table via `subscriptions`, or a `company` table might relate to a `person` table via `employee`, I'm wondering if there is a descriptive way to relate a `company` table to a `company_type` table. Here are some rough (and simplified) examples of the relevant tables.   **company:**   \- |id|name|   **company_type:**   \- |type|description|   **{name needed}:**   \- |id|company_id|type| Also, I realize that not all relationships can be as succinctly named as `subscriptions` or `employee`, so if that's the case here, what would be a good rule of thumb to avoid a near name-collision with something like `company_types`? _Additional Details:_   Company types, in our current case, are _somewhat_ convoluted. This industry has multiple supply channels and multiple customer channels, so while "vendor" is a valid company_type, a vendor can also be "independent", "authorized", or "franchised" ... or any mix of the three.   Customer types are very similarly multi-faceted, and to further compound the issue, a single company can simultaneously be of some vendor and customer types.


How to bypass middlemen?

I'm freelancing on a project where I'm the only programmer, and find myself at the end of a line of four middlemen, who stand between me and the actual customer, each passing my work as internal to their own company. Communication is terrible and the requirements, made by an advertising company, are flimsy. I've managed to communicate with people upper the ladder by keeping asking questions that made people face their ignorance, but they won't let me contact the end client since, from his end, it's pretty much a done deal. The project will soon be over though, and I've decided it's the last time I'll be working under these conditions. The middlemen, are pretty much useless from the perspective of shipping a product, but still necessary to me since they are the ones bringing the contracts in. Hence I'm not thinking about crossing them altogether, which would probably end badly. Rather I'm looking for a way to make them understand I need to be part of the requirements and design process, meet the clients, and shouldn't have to go through a whole channel of clueless people each time I require some information. Sorry for the venting :) Any ideas ?


What logic is used to control Lock and Update actions in P2P networks? (similar to Bitcoin)

Bitcoin relies on Proof of Work (hashing) to control the writing to a central repository (the blockchain). It also relies on a set of rules for these updates, and defines what happens if a conflict is found (longest chain wins) Using that as an example for my question:   * What are some architectural examples of different distributed lock and/or update mechanisms suitable for P2P networks? (I'm looking for descriptions of software design suitable to this project, not software products)   * What key logic or rules are fundamental to that decentralized "database"?


What to do when a company request permission to use open source code without attribution?

I have an opensource project currently under MIT license. I have received a request from a company to use my code for their commercial project without having to give any attribution or credit. To be honest, when I released the code, my sole intention was only to help a fellow programmer, and I didn't really think about if I was credited. Choosing the license was just one of the step I had to do to set up the project on codeplex. On one hand, I feel honored and appreciate that they actually bothered to ask, on the other hand, I felt if I just allowed them to do so without any cost may just destroy the spirit of open source. **What are the typical things I or other code owners can do or request from the company to make it a fair trade? Should I even allow it?** I am thinking of asking the company to write a official letter of intent and I will sign against it just to make it more formal; and also to request a donation to project/charity of my choice or buy something on my wishlist as compensation (not very expensive). Will that be too much?


Django as Python extension?

I come from **php** community and just started learning **Python**. I have to create server-side scripts that manipulate databases, files, and send emails. Some of it I found hard to do in python, comparing to php, like sending emails and querying databases. Where in **php** you have functions like **mysql_query()** , or **email()** , in python you have to write whole bunch of code. Recently I found Django, and my question is: is it a good framework for network-oriented scripts, instead of using it as a web-framework?


I am new to jQuery and mobile apps development. I know the features of jQuery Mobile. I want to know where and why to use it. Can I use jQuery Mobile if I am developing a native app?


Entry level software developer technical interview... I need preparation advice

I'm pretty fresh out of college. So I don't have a lot of experience with job interviews. I'm interviewing for an entry level software developer job. I've already made it past the first phone screen and a coding challenge. Now I'm going in for a face to face technical interview. If I pass this then I probably get the job. The job description that I'm interviewing for now says I will be working mainly with C++, some C#, databases, and web development. It's a smaller comopany and my responsibilities will be a little of everything (design, documentation, coding, and QA). I bombed my last technical interview (with a different company) because I prepared by studying the crap out of all the technologies mentioned in the job description (c#, html, sql, ajax, javascript, etc) but the interview was all questions about hash maps vs binary trees, abstract classes vs interfaces, and recursion and absolutely nothing about the technologies mentioned in the job description. Which I would have done amazing on it if I prepared by going over everything I learned in college... but the last time I worked with most of the stuff he asked about was my sophomore year in college so i was very rusty. Anyway, I'm just looking for some advice on my situation. Should I focus on the computer science stuff that I learned in college like data structures, algorithms, recursion, etc. or should I focus on the technologies they mention in the job description? Any advice from someone with experience would be greatly appreciated.


Maintaining sorted Array speed

I have a for loop running over a list of objects like:               [{a: 2001, b: "hello"}, {a: 54, b: "hi"}....]      In this loop, I filter out objects based on certain field values (like, b == hello?) and create a new list of filtered objects. Once the for loop is complete, I sort the remaining objects by the value of a. This is an oversimplified example, so presorting by field a isn't possible. My question is, is it faster to do the sort after the loop is complete vs doing something like a binary search at the end of each iteration and then insert the object then? That would avoid sorting at the end, but I don't really know if that ends up costing more.


Traversing an AST using Visitors

I'm writing a compiler for a C-like language, and I'm looking for an elegant way to traverse my abstract syntax tree. I'm trying to implement the Visitor pattern, although I'm not convinced that I'm doing it correctly.               struct Visitor {            // Expressions         virtual void visit(AsgnExpression&);         virtual void visit(ConstantExpression&);         ...         virtual void visit(Statement&);         ...              virtual void finished(ASTNode&);          protected:         virtual void visit(ASTNode&) = 0;     };      `visit` is overloaded for each type, and by default each overload will call `visit(ASTNode&)` which subclasses are forced to implement. This makes it easier to do quick and dirty things, although defining a `visit` for each type is tedious. Each subclass of `ASTNode` must implement an `accept` method which is used to traverse the tree structure.               class ASTNode {     public:         virtual ~ASTNode();         virtual void accept(Visitor& visitor) = 0;     };      However, this design is quickly becoming tedious because the `accept` methods are often very similar. **Who should be responsible for traversing the structure, the nodes or the visitor?** I'm leaning towards having `ASTNode` provide an iterator for accessing its children, and then having the visitor traverse the structure. If you have any experience designing Abstract Syntax Trees, please share your wisdom with me!


Objective-C style: Do I implement factory methods or init methods?

I'm new to Objective-C programming, and creating various classes for an iOS application I'm working on. When creating objects, it seems like many classes in the built-in frameworks use the "static factory method" pattern, like this:               MyObject* m = [MyObject objectWithName:@"foo" id:@7 description:@"bar"];      however, many classes also simply have overrides on `init`, like this:               MyObject* m = [[MyObject alloc] initWithName:@"foo" id:@7 description:@"bar"];      I can see that if I want to cover all my bases, I'd implement both, and have the `objectWithName...` method call `initWithName...`, however this seems quite tedious. I was wondering - is there any style or guidance from around when I should implement the factory method pattern vs an `init` overload? I've googled for this, but have been unable to find anything (most likely because the terms are quite generic and google doesn't search well for them) Any advice or opinions would be much appreciated


How much is Google investing in the Go language?

I have read quite a bit about the Go language, and it seems promising. The last important bit of information I am missing before I decide on spending more effort on the language is: How much money/man power does Google or other companies invest in the development effort? If this information cannot be provided, do you have any other information showing the commitment of Google to the project. Is it being used as the primary language for a new investment or similar (my guess is that it is too early for this, but I do not know)?


Is there another meaning to prototype?

I am reading Pro C#. It says > do be aware that the value 0 is automatically returned, even if you > construct a Main() method prototyped to return void. What does prototyped mean in this context? The only C# related definition of a prototype I'm aware of has to do with a model or test program tossed together without the intention to go to production.


Is it sensible to teach programming with a language I don't know myself (yet)?

I have a friend who has asked me to teach him how to program. I was thinking that using a language that I do not know could be beneficial because:   * I will learn something new too.   * That will make me slow down, as I've been told that I usually explain things too fast. So now I need to find some balance between what is didactic for a _newbie_ and is useful to me. My draft of requirements:   * Not C, Java or Python (because I already know).   * My personal interests now are on Erlang, Scala and C++ (but they might be too hardcore)... I could refresh Scheme or Prolog too.   * Need a good IDE or REPL to play with.   * Clean and simple language.   * Good (and free!) documentation.   * Some practical for the real world (i.e. making a web application, image processing, statistical analysis...) About the methodology, I was thinking about this sequence:   * Introduction to logic.   * Basic maths and algorithms.   * Software design principles.   * Some foundations on computer technology.   * Make some large project. So, any suggestions about the language or methodology? **edit** : My "student" is a 28 years old MD, his goal is to make a web site for medicine students. As he is also into research, so I think he could find immediate use to his new programming skills for data analysis and plotting. Ultimately I might help him directly with the project.


How to increase the speed of the page loading in ASP.NET?

I am .net programmer using Asp.net ,C# and Sql server 2005 to display set of information. My project is to create tools for Call Center Systems in my office. Now i am have created the project. but its too slow and takes much time in the time of page loading and post back. I need Suggestions to improve page performances and wat technologies can be used to make the tool efficient...


Interviewing by providing an application to work on?

While thinking about better ways to design technical interviews (meaning not based on social skills but purely technical ones) I started to think about this possible way of doing (without having the possibility to test it):   1. Determine the kind of problems, high or low level of abstraction, from architecture to bitwise manipulations if that's your shop's business, that you are solving every day in the applications you work for. For this example I'll suppose we are in a PC game development company that produce a game based on extensions via modules.   2. Write a simple application that solve those problems. Lets say a simple game that have not the same scale than the one we're working on but that would be    3. Add bugs. Architecture bugs and more language-knowledge related bugs if it's critical (for example it's important to know about virtual destructors in C++). Make it obviously buggy, maybe make it crash first and buggy after that. Make sure it works with the tools that most people use in the domain (like cross-platform C++ for a simple game, providing the libraries code with the rest).   4. Provide the full source code of the application to the candidate and tell him to a) fix the code, b) add a functionality (related to the position if necessary). The candidate would have a limited time to send something back. For example, one week or two. That time would be several times the time needed to do the work in full time, it have to be fair. 4'. Maybe a different way to do that would be to provide the application source code publicly online and start to meet only the candidates who sent you the working application with the additional feature...but that would work very differently so I'm not sure if it's really interesting too. For 4.b., I'm assuming that the functionality to add is simple but requires basic understanding of the overall organisation of the code. That would not be adding content. 5) Make the candidate explain what he did. All that process would be a kind of interview screening, there would be a meeting after that if the candidate did provide something. It feels like parallel screening : you screen several people at the same time without spending time sequentially on each. A meeting with discussions about the code is obviously really necessary. The questions : a) Do you think that it would be pertinent? What do you think? (I'm not very experienced in interviewing so I'm relying on your experiences) b) Would it be considered as paid work? Even if it's not work done on your product but just a interview-specific application? c) I'm assuming that the candidate will use whatever he have available to solve the problems, even friends helping because I think that reflect better an real development environmental. Is there something wrong with assuming that? (Yes I'm questioning my own way of thinking, they say that's sane. Are they wrong?) d) Is there a variant that would be more interesting?


Stable, Hash Based Symmetrical Difference

A lot of thought went into the implementation of the set algorithms in LINQ: `Distinct`, `Except`, `Intersect` and `Union`. They guarantee that the items are returned in the same order that they appear in before calling the method. So, these two expressions return the items in the same order:               var authors1 = books.Select(b => b.Author).OrderBy(a => a).Distinct();     var authors2 = books.Select(b => b.Author).Distinct().OrderBy(a => a);      The implementation of `Distinct` would look something like this:               public IEnumerable<T> Distinct<T>(this IEnumerable<T> source)     {         HashSet<T> set = new HashSet<T>();         foreach (T item in source)         {             if (set.Add(item))             {                 yield return item;             }         }     }      The implementation of `Except` would look like this:               public static IEnumerable<T> Except<T>(this IEnumerable<T> source1, IEnumerable<T> source2)     {         HashSet<T> set = new HashSet<T>(source2);         foreach (T item in source1)         {             if (set.Add(item))             {                 yield return item;             }         }     }      The implementation of `Intersect` would look something like this:               public static IEnumerable<T> Intersect<T>(this IEnumerable<T> source1, IEnumerable<T> source2)     {         HashSet<T> set = new HashSet<T>(source2);         HashSet<T> found = new HashSet<T>();         foreach (T item in source1)         {             if (set.Contains(item) && found.Add(item))             {                 yield return item;             }         }     }      I added a second set to remove duplicates from the list. Finally, `Union` is a little more complex, but basically the same thing:               public static IEnumerable<T> Union<T>(this IEnumerable<T> source1, IEnumerable<T> source2)     {         HashSet<T> set = new HashSet<T>();         foreach (T item in source1)         {             if (set.Add(item))             {                 yield return item;             }         }         foreach (T item in source2)         {             if (set.Add(item))             {                 yield return item;             }         }     }      So, the only operation not supported by LINQ is symmetrical difference or `SymmetricExcept`. I have been playing around with creating a "stable" version of this algorithm and out of pure curiosity am wondering if there is a better implementation. The most straight-forward implementation is to just call `Except` twice:               public static IEnumerable<T> SymmetricExcept<T>(this IEnumerable<T> source1, IEnumerable<T> source2)     {         var except1 = source1.Except(source2);         var except2 = source2.Except(source1);         return except1.Concat(except2);     }      Although, this requires going through both lists twice. So I wrote a version that only requires going through the second list twice:               public static IEnumerable<T> SymmetricExcept<T>(this IEnumerable<T> source1, IEnumerable<T> source2)     {         HashSet<T> set = new HashSet<T>(source2);         HashSet<T> found = new HashSet<T>();         foreach (T item in source1)         {             if (!set.Contains(item) && found.Add(item))             {                 yield return item;             }         }         foreach (T item in source2)         {             if (found.Add(item))             {                 yield return item;             }         }     }      I haven't verified the correctness of these algorithms. There is some ambiguity about how LINQ handles duplicates. I am curious if there is a more efficient way to do `SymmetricExcept`, something better than `O(m + 2n)`.


Is splitting up a function into several inner functions an anti-pattern?

Imagine a long and complicated process, which is started by calling function `foo()`. There are several consecutive steps in this process, each of them depending on result of the previous step. The function itself is, say, about 250 lines. It is highly unlikely that these steps would be useful on their own, not as a part of this whole process. Languages such as Javascript allow creating inner functions inside a parent function, which are inaccessible to outer functions (unless they are passed as a parameter). A colleague of mine suggest that we can **split up the content of`foo()` into 5 inner functions**, each function being a step. These functions are inaccessible to outer functions (signifying their uselessness outside of the parent function). The main body of `foo()` simply calls these inner function one by one:               foo(stuff) {         var barred = bar(stuff);         var bazzed = baz(barred);         var confabulated = confabulate(bazzed);         var reticulated = reticulate(confabulated);         var spliced = splice(reticulated);              return spliced;              // function definitions follow ...     }      **Is this an anti-pattern of some sort? Or is this a reasonable way to split up long functions?** Another question is: is this acceptable when using OOP paradigm in Javascript? **Is it OK to split an object's method this way** , or does this warrant another object, which contains all these inner functions as private methods? **See also:**   * Is it OK to split long functions and methods into smaller ones even though they won't be called by anything else? \- a previous question of mine, which leads into this one.   * @KilianFoth's answer to a very similar question which provides a different perspective compared to the answers given here.


Best practice for security checks, in surface or deep layer?

Let's take a server-side WebServices app, we need to make sure that all function applies every security rules, and keep the code clean. In such a case, I usually prefer to place my security checks on the upper layers. As soon as the user call a function, I check if he has the rights to access it or not. But this strategy doesn't always works, if we need to retrieve infos from the database before performing all the checks, for instance. Is this a bad idea? Should it be better to place security checks in deep layers, just before/after accessing database? I'm trying to figure out the best approach for a system that have a lot of security checks, and avoiding creating a big spaguetti. The question could be like "What are the best practice to make sure an app is secure and the code is easy to maintain?".


Job title inflation and fluffing

When you work on the same project for a relative long time you get more experienced. You may also master many new technologies. Besides the coding you may also do what would classify other roles. There is however one part of your career that may not get updated. That is your job title. It seems beside all technological hypes there is also job title hype. It all depends on which company you work for. Many companies give employer better job titles because they want to keep them. The employee doesn’t change their job because the current title is much better, even if they would get better working condition and benefits if they changed their job. When you consider changing you job you notice that your job title is kind of “outdated”. People with less skill have a much better title for their job than you. You may very well explain what you did on your project but the fact is that many employers go by the title. So here are the questions:   * Do you change your current title in your CV?   * What are other options? Here are some good readings regarding these phenomena:   * Job title inflation   * Job title fluffing


What companies hire data scientists?

What kind of data jobs are there in the software industry for someone with a B.S. in pure mathematics and a minor in statistics but with little experience in programming? I want to work on the data research side rather than on the software developement side. What companies hire data scientists?


Single complex or multiple simple autoload functions

Using the **spl_autoload_register()** , should I use a single autoload function that contains all the logic to determine where the include files are or should I break each include grouping into it's own function with it's own logic to include the files for the called function? As the places where include files may reside expands so too will the logic of a single function. If I break it into multiple functions I can add functions as new groupings are added, but the functions will be copy/pastes of each other with minor alterations. Currently I have a tool with a single registered autoload function that picks apart the class name and tries to predict where it is and then includes it. Due to naming conventions for the project this has been pretty simple.               if has namespace        if in template namespace look in Root\Templates       else look in Root\Modules\Namespace     else       look in Root\System     if file exists include      But we are starting to include Interfaces and Traits into our codebase and it hurts me to include the type of a thing in it's name. So we are looking at instead of a single autoload function that digs through the class name and looks for the file and has increasingly complex logic to it, we are looking at having multiple autoload functions registered. But each one follows the same pattern and any time I see that I get paranoid about code copying.               function systemAutoloadFunc       logic to create probable filename       if filename exists in system include it and return true       else return false          function moduleAutoloadFunc       logic to create probable filename       if filename exists in modules include it and return true       else return false      Every autoload function will follow that pattern and the last of each function _if filename exists, include return true else return false_ is going to be identical code. This makes me paranoid about having to update it later across the board if the file_exists include pattern we are using ever changes. Or is it just that, paranoia and the multiple functions with some identical code is the best option?


How can I properly compare double values for equality in a unit test?

I recently designed a time series module where my time series is essentially a `SortedDictionnary<DateTime, double>`. Now I would like to create unit tests to make sure that this module is always working and producing the expected result. A common operation is to compute the performance between the points in the time series. So what I do is create a time series with, say, {1.0, 2.0, 4.0} (at some dates), and I expect the result to be {100%, 100%}. The thing is, if I manually create a time series with the values {1.0, 1.0} and I check for equality (by comparing each point), the test would not pass, as there will always be inaccuracies when working with binary representations of real numbers. Hence, I decided to create the following function:               private static bool isCloseEnough(double expected, double actual, double tolerance=0.002)     {         return squaredDifference(expected, actual) < Math.Pow(tolerance,2);     }      Is there another common way of dealing with such a case?


Secure an Application/Software by expiration with Date?

I have been working on some software application and I update them every 6 months. Currently, the way I track the date is by extracting the date from the system when the user installs the application, encrypt it and store it in a file locally. Whenever the application is started, it checks if 6 months have passed, then it works or it doesn't, in which case it shows an error message telling the user to update. If the user finds the encrypted date in the file they can simply replace it with one from a more recent install. I am wondering if there's a more secure way to do this?


Why there is no markdown for underline?

I am wondering why there is no markdown syntax for underline? I know that basic html tags can be embedded to achieve this but I am trying to understand why `underline` got omitted when **bold** and _italics_ exists