title: Organizing large Javascript applications - The view layer

text: Today Javascript application of a relevant size become more and more common, and as the need arises, certain patterns are identified to manage the code complexity. I try to follow good advice, but I have some trouble in organizing the view layer of an application I am writing. While the other layers are nicely decoupled, I have a big blob for the UI that I would like to avoid. To make things clear, I am not talking of application the size Osmani (see the link above) considers - like Gmail - but still big enough to deserve a slightly better architecture. My problem is that I have a lot of UI elements that I have to place. All these elements can have margins, paddings and so on, and I need to explicitly set their size, as the UI has a lot of constraint that are not expressible by CSS (for instance, some images have to be sized to that an integer number of them appears in a row, without blank space at the end). As if this was not enough, the size of some elements depends on how much space their container allows, and this may depend on the size of other elements and so on. What I am doing right now is to compute the size of all elements every time the window size changes. I start from the first one, which I can compute freely. As soon as this is placed, I fire an event which trigger the computation of the second one and so on. This approach more or less works, but is ugly as hell. Every function is full of code like               function resizeFoo() {         var parent = $('#foo').parent(),             parentWidth = parent.width(),             availableWidth = parentWidth - parseInt(parent.css('padding-left'), 10);              $('#foo').width(availableWidth);     }      only much longer. As soon as I add some right padding to #foo's parent, I have to update this. Of course, I could subtract the padding from both sides right from the start, making it event longer. > Are there any useful patterns to handle complex UI sizing and positioning > requirements, so that I can reorganize all of the above mess into something > meaningful?


title: Using lookahead assertions in regular expressions

text: I use regular expressions on a daily basis, as my daily work is 90% in Perl (legacy codebase, but that's a different issue). Despite this, I still find lookahead and lookbehind to be terribly confusing and often unreadable. Right now, if I were to get a code review with a lookahead or lookbehind, I would immediately send it back to see if the problem can be solved by using multiple regular expressions or a different approach. The following are the main reasons I tend not to like them:   * They can be terribly unreadable. Lookahead assertions, for example, start from the beginning of the string no matter where they are placed. That, among other things, can cause some very "interesting" and non-obvious behaviors.   * It used to be the case that many languages didn't support lookahead/lookbehind (or supported them as "experimental features"). This isn't the case quite as much, but there's still always the question as to how well it's supported.   * Quite frankly, they feel like a dirty hack. Regexps often already are, but they can also be quite elegant, and have gained widespread acceptance.   * I've gotten by without any need for them at all... sometimes I think that they're extraneous. Now, I'll freely admit that especially the last two reasons aren't really good ones, but I felt that I should enumerate what goes through my mind when I see one. I'm more than willing to change my mind about them, but I feel that they violate some of my core tenets of programming, including:   * Code should be as readable as possible without sacrificing functionality -- this may include doing something in a less efficient, but clearer way as long as the difference is negligible or unimportant to the application as a whole.   * Code should be maintainable -- if another programmer comes along to fix my code, non-obvious behavior can hide bugs or make functional code appear buggy (see readability)   * "The right tool for the right job" -- I'm sure you can come up with contrived examples that could use lookahead, but I've never come across something that really needs them in my real-world development work. Is there anything that they're really the best tool for, as opposed to, say, multiple regexps (or, alternatively, are they the best tool for most cases they're used for today)? My question is this: **Is it good practice to use lookahead/lookbehind in regular expressions, or are they simply a hack that have found their way into modern production code?** I'd be perfectly happy to be convinced that I'm wrong about this, and simple examples are useful for examples or illustration, but by themselves, won't be enough to convince me.


title: Python simulation-scripts architecture

text: **Situation:**   I've some scripts that simulate user-activity on desktop. Therefore I've defined a few cases (workflows) and implemented them in Python. I've also written some classes for interacting with the users' software (e.g. web browser etc.). **Problem:**   I'm a total beginner in software design / architecture (coding isn't a problem). How could I structure what I described above? Providing a library which contains all the workflows as functions, or a separate class/module etc. for each workflow? I want to keep the the workflows simple. The complexity should be hidden in the classes for interacting with the users' software. Are there any papers / books I could read about this, or could you provide some tips?


title: Designing controller for modular Java architecture

text: We are designing a system which mimics a BPEL application with sets of functional requirements such as bulk messaging, managing SLAs, error handling and so on. One of the intentions is to modularize these functional and non-functional aspects into separate web apps so that we can choose at build time and plug them all together. How does one go about designing this app - choosing design patterns for a controlling framework that delegates between the modules? Put another way - it's like the chain of activities in an ESB, so the controller passes on to A then B then C. In other cases it goes A > B > D and so on. So my question: what design pattern does this controller have? How can it decide the logic of whether at the end of A, should it call B or C


title: what does composition example vs aggregation

text: Composition and aggregation both are confusion to me. Does my code sample below indicate composition or aggregation?               class A {          public static function getData($id) {              //something          }               public static function checkUrl($url) {              // something          }           class B {         public function executePatch() {                $data = A::getData(12);           }              public function readUrl() {                $url = A::checkUrl('http/erere.com');          }              public function storeData() {                 //something not related to class A at all          }       }     }      Is class B a composition of class A or is it aggregation of class A? Does composition purely mean that if class A gets deleted class B does not works at all and aggregation if class A gets deleted methods in class B that do not use class A will work?


title: Suggestion on how to fill a web form (several times)

text: I need to fill a form using data from a CSV file. I was planning to use CURL+PHP to do it, but then I realized the form has several steps (one on each page), plus it uses javascript to fill hidden inputs. It is an ASP.NET form, so it has a lot of variables a postback, etc. I am thinking now, to make a browser extension that would load the CSV file and without any more user input would fill the form, and advance from page to page filling up the form and then somehow wait for the form to finish processing, retrieve the output and restart the form. I would like to repeat this for 500-600 times. The website in question does not provide an API so filling up forms is the only way. Does this idea sound feasible, any other ideas?


title: Pointer access and cache coherency

text: To my understanding, when you access a variable, that variable and the surrounding area of memory is put into the L1 cache. If I'm wrong here, please tell me. Now my question is, say I have an array of pointers, and I want to iterate through them all performing operation X. If I first have to access the pointer, to get the address of the actual data, does this mean that the memory near the pointer will be put into cache, then the memory near the data, then back to the pointer, then to the data etc? i.e. Cache thrashing? If this is the case, how might one go about keep cache coherency?


title: Relevance of search results

text: I implemented an easy-to-use text search for our application. It has the usual text fields for   * all of the keywords   * any of the keywords    * none of the keywords Now I would like to prioritize my results. Just counting the "all" and "any" hits would be probably good enough, but may be the result is more relevant if more than the one necessary "any" term was hit. Or one could say that a lot of hits for a single word should yield "diminishing returns". Could you please give me a hint how this problem is usually handled? **Disclaimer** : I know that a "hand made" search won't scale and won't give the best possible results. This implementation is just a temporary solution, which will be replaced by something like Apache Solr, as soon as we have the resources.


title: Why should I learn to make apps for Windows Phone 7 instead of Android?

text: What would be the reason one learn to make apps for Windows Phone 7 instead of Android phones? Is there any reason why Windows Phone 7 is the platform that a developer choose instead of Android? Thanks heaps


title: Is there a difference in the C++ language between Visual Studio and Code::Blocks?

text: I used to program C++ on Code::Blocks, but it's boring now. The view of Visual studio is that it's much better. Will it change anything? Or is it the same thing? Same syntax?


title: How important is it that you know the C++ standard?

text: I did try searching, but I did not see a similar question (either that or my search terminology was incorrect - if so, feel free to close). I am an avid user of SO, and I notice that there are lots of references to the C++ standard in discussions and answers - and I have to admit, I have never read this particular document, the language makes my eyes hurt... So, the question is, can a C++ developer really code for a living without ever having read this document? Is it really important for us mere mortals who are not in the business of writing compilers?


title: Does Microsoft really offer "support"?

text: One of the arguments against using Open Source is that there is no "support". However, do big vendors (e.g. Microsoft) really offer "support" of any kind? I'm sure there is some sort of 4-figure-per-hour "paid support" option out there, but is that really an "option" for any problem short of one that is going to bankrupt your business? To put it more concretely... I buy a Microsoft product... it has a bug... now what? And how is that better than what I get from Open Source?


title: Pythonic version of Java interfaces

text: I fully acknowledge that Python and Java are different programming languages and should be used differently. That said, "Program to an interface, not to an implementation" is good language-agnostic programming advice. Say I have some DAO interface in Java:               public interface DataDao {            Object load();       void update();       void delete();     }      Programming to that interface allows me to persist data in files while I'm prototyping, swap that out for a database as I get further along, etc. rather painlessly as long as I honor the contract of the `DataDao`. What's the Pythonic approach/version (if any) to programming to a contract to keep your classes orthogonal, modular, and enable frictionless implementation changes?


title: My coworker created a 96 columns SQL table

text: Here we are in 2010, software engineers with 4 or 5 years or experience, still designing tables with 96 fracking columns. I told him it's gonna be a nightmare.   I showed him that we have to use ordinals to interface MySQL with C#.   I explained that tables with more columns than rows are a huge smell. Still, I get the "It's going to be simpler this way". What should I do? EDIT * This table contains data from sensors.   We have sensor 1 with   Dynamic_D1X   Dynamic_D1Y   [...] Dynamic_D6X   Dynamic_D6Y   [...] EDIT2 * Well, I finally left that job. It is a sign when the other programmer goes dark for months at the time, it is another sign when management does not realise this is a problem


title: How a freelancer can learn industry standards?

text: Being a freelancer, I don't have access to corporate training programs where employees learn best practices. Most of the time I am advised to look into the available code on the Internet. Ideal places would be: CodePlex and SourceForge. But this proves to be of limited rather very little help. I want my existing code to be analyzed and a better solution be suggested to improve the quality of the code. How to learn coding that matches standards?


title: Apple eating problem

text: Player A and Player B play a game. On the middle of the table there is a pot full of N apples of different weights. Player A starts first and choose an apple and start eating it. Losing no time player B do the same. When a player eats the whole apple, without losing time repeat the same procedure. In case both player have eaten the apple at the same time, Player A still have the advantage of choosing first. Note that both players eat with same speed What apple should the Player A choose at first to ensure that with right tactics he'll eat as much as grams of apples possible if the player B plays optimally? * * * I thought that choosing the smallest or the biggest apple should do the job, but there are specific cases when this doesn't work. This is C++ contest problem, so there should be a nice solution to this. I think that brute force maybe provide a solution, but this will require much time, because the number of apples is up to 10000. I would rather like some hint on how to approach this question, how to find the optimal tactic or intuition rather than a code.


title: What could be the Model Layer when consuming Web-Services and no Database in Django?

text: I'm using Django as an application framework and it only needs to consume web services (no need to have traditional Django Models and the related ORM). In this case, since Django is a variant on the MVC architecture (MVT, to be precise) should I wrap the web service calls into a 'model' that my App uses or should I just call those web services directly from the Django View and remove the model layer?


title: Sell a web app with limit per client?

text: This is not a "classic" programming question, but it's related to our job. I develop and sell data driven web app for some customer, some small (10 employess or less), some bigger (1000-2000 employers). My questions are:   1. Can i sell my app with different prices, based on customer's "dimension" ? Is it common in "software market"..isn't ?   2. How can **"control" and maybe "limit to work" my asp.net web** app when customer exceed their limit license ? Are there some ready-made server side component to do that ? Thanks EDIT: Last question: how to _justify_ the higher price for big company against small price for smaller company ?


title: Pragma Mark in Cocoa

text: I'm a newb to cocoa programming and looking around in various open source code online I see things like:               #pragma mark global variable declaration      and I was wondering what the meaning of "pragma mark" is in that is it any different than a // or /* (comment) block..like is it used throughout the program, and is there a commonly used methodology to it, or is it more or less a way for programmers to organize and collect their code for themselves (and others if the case may be) to use later? I found this article: http://inchoo.net/mobile-development/iphone- development/what-is-a-pragma-mark/ and it is pretty helpful, but I just needed to clarify again if it's more or less used by the coder or used by XCode? Thanks!


title: Can a freelancer use agile development?

text: I want to improve the way that I develop software. I want to develop faster and a great code! Today I use the waterfall method as freelancer, writing web stuffs (sites, systems, etc). Is there a way to use agile development (XP, SCRUM, etc) working in this way? I don't know nothing about agile development, where should I start? Thank you very much.


title: GPL copyright notice

text: I don't have copyright licence from local government. How can I use GPL? As far as I know a step to apply GPL is to add the copyright notice:               Copyright XXXX shabab haider...      What shall I write in this section? Am I eligible to write such thing? Do I have to redirect the copyright to free software foundation or something similar?


title: Cpu-heavy web server

text: When reading about web servers, frameworks, etc most of the time I notice that the goal is to have a technology that has the next features:   * Able to handle as many connections as possible.   * Fit an I/O model (connections to DBs and other web services). Those features fit the actual web model but I am interested in knowing which technologies will fit a heavy-cpu user case. For example, Node.js is a technology that really shines when you have to write an application that uses a lot of I/O. On the other hand, due to the Node.js nature of being evented, It is not suitable for being use in CPU-heavy user cases.(video encoding, machine learning, graphics) I also have take a look at Haskell web frameworks like Snap and Warp and at the benchmarks they really are fast. Are they Haskell web frameworks suitable for CPU-heavy problem? Which other languages/technologies are candidates?


title: What are the advantages of storing xml in a relational database?

text: I was poking around the AdventureWorks database today and I noticed that a number of tables (`HumanResources.JobCandidate` and `Sales.Individual` for example) have a column which is storing xml data. What I would to know is, what is the advantage of storing basically a database table row's worth of data in another table's column? Doesn't this make it difficult to query off of this information? Or is the assumption that the data won't need to be queried and just needs to be stored?


title: Why no gender recognition studies are performed yet to recognize gender without seeing (based on behavior)?

text: Each website has visitors, and each visitor might be a potential customer (lead), thus it's really good to do whatever a marketer can do to attract that lead and turn it into a real customer. However, some marketing strategies work on the gender of the lead. In other words, men would be attracted in one way, and women in another way. I see that there are some studies on **gender recognition** based on some physiological and facial patterns like: http://ieeexplore.ieee.org/xpl/articleDetails.jsp?arnumber=6249810 http://stackoverflow.com/questions/5268753/face-gender-detection-library http://www.advancedsourcecode.com/gagender.asp However, in online marketing, which is a hot topic in the realm of Internet, you can't see the face of the visitor of your site. But still based on some preferences and some attribute there might be chances that you guess the gender of the visitor, which might increase the profit overall by absorbing more customers through good strategies. For example women usually like pink color and men usually like online games. But I wonder why till now no study has been done for that? In a world where Google and Facebook and internet giants try to understand their users more and more, seems a little odd that websites which have many visitors (like news websites cnn, bbc, msn, yahoo, etc.) has done nothing or few things to handle this concept. Imagine how much work can be done once you understand that the visitor is male, or female. So, are there any technical limitations for not working on **gender recognition** just the way we've worked on **handwriting recognition** and **speech recognition** and **face recognition**?


title: Why doesn't Python need a compiler?

text: Just wondering (now that I've started with C++ which needs a compiler) why Python doesn't need a compiler? I just enter the code, save it as an exec, and run it. In C++ I have to make builds and all of that other fun stuff.


title: Do I need IDs in my database if the records could be identified by the date?

text: I am writing my first application for Android and will use the SQLite database so will be trying to limit the size as much as possible, but I think the question applies in general to database design. I am planning to store records that will have text and the date of creation. The app is a stand-alone app, i.e. it will not link to the internet and only one user will be updating it, so there is no chance that there will be more than one entry with a given date. Does my table still need an ID column? If so, what are the advantages of using the ID as a record identifier as opposed to the Date?


title: Duck typing, data validation and assertive programming in Python

text: About duck typing: > Duck typing is aided by habitually not testing for the type of arguments in > method and function bodies, relying on documentation, clear code and testing > to ensure correct use. About argument validation (EAFP: Easier to ask for forgiveness than permission). An adapted example from here: > ...it is considered more pythonic to do :               def my_method(self, key):         try:             value = self.a_dict[member]         except TypeError:             # do something else      > This means that anyone else using your code doesn't have to use a real > dictionary or subclass - they can use any object that implements the mapping > interface. > > Unfortunately in practise it's not that simple. What if member in the above > example might be an integer ? Integers are immutable - so it's perfectly > reasonable to use them as dictionary keys. However they are also used to > index sequence type objects. If member happens to be an integer then example > two could let through lists and strings as well as dictionaries. About assertive programming: > Assertions are a systematic way to check that the internal state of a > program is as the programmer expected, with the goal of catching bugs. In > particular, they're good for catching false assumptions that were made while > writing the code, or abuse of an interface by another programmer. In > addition, they can act as in-line documentation to some extent, by making > the programmer's assumptions obvious. ("Explicit is better than implicit.") The mentioned concepts are sometimes in conflict, so i count on the following factors when choosing if i don't do any data validation at all, do strong validation or use asserts:   1. Strong validation. By strong validation I mean raising a custom Exception (`ApiError` for example). If my function/method is part of a public API, it's better to validate the argument to show a good error message about unexpected type. By checking the type I do not mean using only `isinstance`, but also if the object passed supports the needed interface (duck typing). While I document the API and specify the expected type and the user might want to use my function in an unexpected way, I feel safer when I check the assumptions. I usually use `isinstance` and if later I want to support other types or ducks, I change the validation logic.   2. Assertive programming. If my code is new, i use asserts a lot. What are your advices on this? Do you later remove asserts from the code?   3. If my function/method is not part of an API, but passes some of its arguments through to a other code not written, studied or tested by me, I do a lot of asserts according to the called interface. My logic behind this - better fail in my code, then somewhere 10 levels deeper in stacktrace with incomprehensible error which forces be to debug a lot and later add the assert to my code anyway.  Comments and advices on when to use or not to use type/value validation, asserts? Sorry for not the best formulation of the question. For example consider the following function, where `Customer` is a SQLAlchemy declarative model:               def add_customer(self, customer):         """Save new customer into the database.         @param customer: Customer instance, whose id is None         @return: merged into global session customer         """         # no validation here at all         # let's hope SQLAlchemy session will break if `customer` is not a model instance         customer = self.session.add(customer)         self.session.commit()         return customer      So, there several ways to handle validation:               def add_customer(self, customer):         # this is an API method, so let's validate the input         if not isinstance(customer, Customer):             raise ApiError('Invalid type')         if customer.id is not None:             raise ApiError('id should be None')              customer = self.session.add(customer)         self.session.commit()         return customer      or               def add_customer(self, customer):         # this is an internal method, but i want to be sure         # that it's a customer model instance         assert isinstance(customer, Customer), 'Achtung!'         assert customer.id is None              customer = self.session.add(customer)         self.session.commit()         return customer      When and why would you use each of these in the context of duck typing, type checking, data validation?


title: Is testing the easiest way to contribute to an Open Source Project?

text: I want to contribute to an open source project, but I don't know much about unit testing. I want to learn how to test and then practice my skills on an open source. Will this also be acknowledged as a contribution. I want to first get my name out there and then conc. on development.


title: Reason for return statement in recursive function call

text: I just had a doubt in my mind. The following subroutine(to search an element, in a list, for example) has a return statement at the end:               list *search_list(list *l, item_type x) {       if (l == NULL) return(NULL);       if (l->item == x)         return(l);       else         return( search_list(l->next, x) );     }      I cannot get the significance of return statement at the end (i.e. return search_list(l->next, x) ). It would be really helpful if anyone could explain this concept, using stack model.


title: Deleting Old Nuget Package Folders after upgrading

text: Should you delete the old Nuget package files/folders under the packages directory after you upgrade a package? Maybe I'm just being overly picky, but seeing files/folder for older package versions it bothering me. Is there a good reason NOT to delete the package folders for previous package versions?


title: Inter-process and inter-thread data sharing

text: I know that operating systems facilitate inter-process and inter-thread data sharing. I want to know about the mechanisms used to facilitate such sharing. I read about "pipes". What are the other ways?


title: Sharing Large Database Backup Among Team

text: I work on a team of three - five developers that work on an ASP.net web application remotely. We currently run a full local database from a recent backup on all of our machines during development. The current backup, compressed, is about 18 GB. I'm looking to see if there's an easier way to keep all of our local copies relatively fresh without each of us individually downloading the 18 GB file over HTTP from our web server on a regular basis. I guess FTP is an option, but it won't speed the process up at all. I'm familiar with torrents and the thought keeps hitting me that something like that would be effective, but I'm unsure of the security or the process.


title: Three variants of circular references between objects: how to choose?

text: I'm designing an object dependency graph of my program and one ambiguity between design variants appears from time to time. Imagine two objects having a reference to each other. Obviously, at least one reference should be assigned after object's initialization (for example, through a subscription method) and another one optionally can be a direct dependency. Here's an object diagram ![enter image description here](http://i.stack.imgur.com/7w2Jl.png) I'm not sure I've used correct UML, so here's my description: 1) Both objects have subscription/binding methods. Usage:               A a = new A();         B b = new B();         a.Set(b);         b.Set(a);      2) `ObjectB` is a component of `ObjectA`:               A a = new A(new B());               // somewhere, possibly in a's method :         b.Set(a);      3) Third is actually an opposite of the second, no need to explain. In my situation I can use any of these and my program will work, but I want some theoretical reasons. Can they be found?


title: What is the "default" software license?

text: If I release some code and binaries, but I don't include any license at all with it, what are the legal terms that apply by default (in the US, where I am). I know that I automatically have copyright without doing anything, but what restrictions are there on it? If I upload my code to github and announce it as a free download / contribute at will, then are people allowed to modify and close source my work? I haven't said that they cannot, as a GPL would, but I don't feel that it would by default be acceptable to steal my work either. So what can and cannot people do with code that is freely available, but has absolutely no licensing terms attached? By the way, I know that it would be a good idea for me to pick a license and apply it to my code soon, but I'm still curious about this.


title: Common Javascript mistakes that severely affect performance?

text: At a recent UI/UX MeetUp that I attended, I gave some feedback on a website that used Javascript (jQuery) for its interaction and UI - it was fairly simple animations and manipulation, but the performance on a decent computer was horrific. It actually reminded me of a lot of sites/programs that I've seen with the same issue, where certain actions just absolutely destroy performance. It is mostly in (or at least more noticeable in) situations where Javascript is almost serving as a Flash replacement. This is in stark contrast to some of the webapps that I have used that have far more Javascript and functionality but run very smoothly (COGNOS by IBM is one I can think of off the top of my head). I'd love to know some of the common issues that aren't considered when developing JS that will kill the performance of the site.


title: Why do we write the action to be performed by a function in jQuery inside the parentheses?

text: Generally whenever we're programming in any Programming language, say C, we would pass the parameters we need to pass to a function using the parentheses next to the name of the function. Whereas in jQuery, other than the user defined `function()` we write the action we need the function to perform inside the parentheses, for example,               $('div').mouseenter(function(){        /* blah blah blah*/     });      Why?


title: Are there advantages to declaring stack variables constant in C++

text: It's not clear to me what benefits there are of declaring your stack variables as constant in C++, I was hoping somebody might explain the benefits and purpose for this technique. For example:               void func(const std::string& arg)     {        if(someCondition)        {           const std::string foo ("some string plus " + arg);           std::out << foo << std::endl;           someFunction(foo);           // dozens more lines of code...        }        // bla bla bla...     }      Thanks!


title: What would be the best way to manage a lot of jQuery code?

text: Sorry for the blunt question, I will try to explain further. I am going to have a website which uses jQuery, and I feel that at some point in time, there will be A LOT of jQuery code, meaning A LOT of functions, jQuery selectors, etc. Is there a way to limit the availability of jQuery code for specific pages? Perhaps using objects? I'm looking for the best approach here so I don't just run off into a storm and can't find my way out. Thanks.


title: Why do some sorting methods sort by 1, 10, 2, 3...?

text: I've noticed than many numerical sorting methods seem to sort by 1, 10, 2, 3... rather than the expected 1, 2, 3, 10... I'm having trouble coming up with a scenario where I would need the first method and, as a user, I get frustrated whenever I see it in practice. Are there legitimate use cases for the first style over the second? If so, what are they? If not, how did the first sort style ever come into being? What are the official names for each sort method?


title: Why does the Git community seem to ignore side-by-side diffs

text: I used to use Windows, SVN, Tortoise SVN, and Beyond Compare. It was a great combination for doing code reviews. Now I use OSX and Git. I've managed to kludge together a bash script along with Gitx and DiffMerge to come up with a barely acceptable solution. I've muddled along with this setup, and similar ones, for over a year. I've also tried using the Github diff viewer and the Gitx diff viewer, so it's not like I've not given them a chance. There are so many smart people doing great stuff with Git. Why not the side- by-side diff with the option of seeing the entire file? With people who have used both, I've never heard of anyone that likes the single +/- view better, at least for more than a quick check.


title: How to best annotate MVC custom action filters?

text: As I get deeper into the area of ASP.NET MVC 3, I feel like I'm finding a lot of very nice technical nuggets as well as new ways of doing things versus classic ASP.NET. One of those "nuggets" is custom action filters. You can simply decorate your controller classes or methods with attributes that, by convention, point to a "custom action filter" class that can perfom some operations given some point of execution (e.g. On Exception, On Method Execution, etc). They are VERY handy if you have some sort of operation that needs to be performed at a regular point in the execution of your code. The question is this: How does this best fit in with object oriented design? What do you think is the best way of annotating that on a UML diagram or when you are trying to draw them up on a white board and explaining the design? I'm very visual, so I like explaining my designs on the white board, but I'm at a loss of how to best convey custom action filters in an Object Oriented basis. They are not really an interface that needs to be implemented. They do take advantage of inheritance, but not in the context of where they are executed. They seem to fit best under the realm of "Aspect oriented" programming, where you have actions that take place under the covers for different scenarios (e.g. Logging, Exceptions). Any thoughts are appreciated.


title: How much freedom should a programmer have in choosing a language and framework?

text: I started working at a company that is primarily C# oriented. We have a few people who like Java and JRuby, but a majority of programmers here like C#. I was hired because I have a lot of experience building web applications and because I lean towards newer technologies like JRuby on Rails or nodejs. I have recently started on a project building a web application with a focus on getting a lot of stuff done in a short amount of time. The software lead has dictated that I use mvc4 instead of rails. That might be OK, except I don't know mvc4, I don't know C# and I am the only one responsible for creating the web application server and front-end UI. Wouldn't it make sense to use a framework that I already know extremely well (Rails) instead of using mvc4? The reasoning behind the decision was that the tech lead doesn't know Jruby/rails and there would be no way to reuse the code. Counter arguments:   * He won't be contributing to the code and is, frankly, not needed on   this project. So, it doesn't really matter if he knows JRuby/rails or not.   * We actually can reuse the code since we have a lot of java apps that JRuby can pull code from and vice-versa. In fact, he has dedicated some resources to convert a Java library to C#, instead of just running the Java library on the JRuby on Rails app. All because he doesn't like Java or JRuby I have built many web applications, but using something unfamiliar is causing some spin-up and I am unable to build an awesome application in as short of a time as I'm used to. This would be fine; learning new technologies is important in this field. The problem is, for this project we need to get a lot done fast. At what point should a developer be allowed to choose his tools? Is this dependent on the company? Does my company suck or is this considered normal? Do greener pastures exist? Am I looking at this the wrong way?


title: Overwhelmed by complex C#/ASP.NET project in Visual Studio 2008

text: I have been hired as a junior programmer to work on projects that extend existing functionality in a very large, complex solution. The code base consists of C#, ASP.NET, jQuery, javascript, html and xml. I have some knowledge of all these in addition to fair knowledge of object- oriented programming and its fundamental concepts of inheritance, abstraction, polymorphism and encapsulation. I can follow code up through its base classes, interfaces, abstract classes and understand a large part of the code that I read while doing this. However, this solution is so humongous and so many things get tied together whenever I navigate through the code that I feel absolutely overwhelmed. I often find myself unable to fully follow everything that is going on with objects being serialized, large amounts of C# and javascript operating on the same pages and methods being called from template files that consist mainly of markup. I love learning about code, but trying to deal with this really stresses me out. Additionally, I do know that a significant amount of unit testing has been done but I know nothing about unit testing or how to utilize it. Any advice anyone could offer me regarding dealing with a large code base while using Visual Studio 2008 would be greatly appreciated. Are there tools that I can use to help get a handle on what is going on? Perhaps there are things even in Visual Studio that I am not aware of. How can I follow the code to low level functionality in order to get a better grasp of what is going on at a high level?


title: How did separation of code and data become a practice?

text: **Please read the question carefully: it asks _how_ , not _why_.** I recently came across this answer, which suggests using a database to store immutable data: > It sounds like many of the magic numbers you describe - particularly if they > are part dependent - are really data, not code. [...] It may mean an SQL > type database, or it may simply mean a formatted text file. It would seem to me that if you have data that is part of what your program does, then the thing to do is to put it _in the program_. For example, if your program's function is to count vowels, what's wrong with having `vowels = "aeiou"` in it? After all, most languages have _data structures_ designed for precisely this use. Why would you bother to _separate data_ by putting it in a "formatted text file", as suggested above? Why not just make that text file formatted in your programming language of choice? Now is it a database? Or is it code? I'm sure some will think this is a dumb question, but I ask it in all seriousness. I feel like "separate code and data" is emerging culturally as some sort of self-evident truth, along with other obvious things like "don't give your variables misleading names" and "don't avoid using whitespace just because your language considers it insignificant". Take for example, this article: The Problem with Separating Data from Puppet Code. _The Problem_? What problem? If Puppet is a language for describing my infrastructure, why can't it also describe that the nameserver is 8.8.8.8? It seems to me that the problem isn't that code and data are mingled,1 but that Puppet lacks sufficiently rich data structures and ways to interface to other things. I find this shift disturbing. Object oriented programming said "we want arbitrarily rich data structures", and so endowed data structures with powers of code. You get encapsulation and abstraction as a result. Even SQL databases have stored procedures. When you sequester data into YAML or text files or dumb databases as if you are removing a tumor from the code, you lose all of that. Can anyone explain how this practice of separating data from code came to be, and where it's going? Can anyone cite publications by luminaries, or provide some relevant data that demonstrates "separate code from data" as an emerging commandment, and illustrates its origin? 1: if one can even make such distinctions. I'm looking at you, Lisp programmers.


title: Why did Shannon's outguessing machine beat Hagelbarger's?

text: I'm reading "Rock Breaks Scissors", which describes two "outguessing machines" built at Bell Labs that try to exploit human non-randomness in the game of matching pennies. There was an outguessing machine built by the famous Claude Shannon, and one built by Dave Hagelbarger. The machines worked like this (quoted from the book): > Suppose you win twice in a row with the same choice. What would you pick > next? You could stick with the choice that's been winning - or you could > switch, perhaps on the grounds that three times in a row wouldn't be > "random." > > Each time a particular situation occurred, [Shannon's] machine archived what > the player had decided. Every decision was encoded as a 1 or 0 and slotted > into one of the machine's 16 precious bits of memory. For each of the eight > given situations, Shannon's machine cataloged the last two decisions only. > That filled the machine's 16 bits. > > When the machine needed to predict, it looked at what the player had done > the last two times that the same situation had occurred. Whenever the > player's response had been identical both times, the machine predicted that > the player would do the same thing once again. Otherwise, it guessed > randomly from its [random number generator]. > > The main difference between Shannon's machine and Hagelbarger's was that > Shannon's was simpler. Hagelbarger's machine kept track of a percentage of > outcomes for each of the eight situations. The higher the percentage, the > more likely Hagelbarger's machine was to predict a repeat of the past. This > may sound more reasonable and nuanced than Shannon's all-or-nothing > approach, but in practice, Shannon's device was the better predictor. Shannon's machine beat humans at a higher rate than Hagelbarger's, and also beat Hagelbarger's machine when they played each other. I don't understand why Shannon's simpler approach was significantly better than Hagelbarger's percentage-based approach.


title: Is there a pattern to restrict which classes can update another class?

text: Say I have a class ImportantInfo with a public writable property Data. Many classes will read this property but only a few will ever set it. Basically, if you want to update Data you should really know what you're doing. Is there a pattern I could use to make this explicit other than by documenting it? For example, some way to enforce that only classes that implement IUpdateImportantData can do it (this is just an example)? I'm not talking about security here, but more of a "hey, are you sure you want to do that?" kind of thing. ## UPDATE I've been faced with similar situations before, that's why I tried to keep the question more generic but it seems that a more concrete example is definitely required. So here it goes: I have a Context class with a a property CurrentYear. Many classes use this Context object and, whenever CurrentYear changes, they need to react (reload themselves, for example). Now, there are some classes that can legitimately change CurrentYear. Of course, you don't want just everybody to change CurrentYear as that has an effect in many other classes. How would you go about that?


title: What's better approach when creating a user control: receive a full object or only the needed values?

text: I'm working with ASP.NET Web User Control (WUC) and I got to this question: I'm creating a WUC to show an object's data. This object is already loaded when I call that WUC. I'm wondering what would be better: give the WUC the full object or only the necessary attributes?


title: How do you keep SOA DRY?

text: In our organization, we've shifted to a more "service oriented architecture". To give an example, let's assume we need to retrieve a "Quote" object. This quote has a shipper, a consignee, phone numbers, contacts, email addresses, and other location information. In other words, a Quote object is made up of many other objects. So, it seems like it would make sense to make a "Quote Retrieval Service". In our situation, we've accomplished this by creating a .NET solution and writing the service. The service API looks something like this (in pseudo-code):               Function GetQuote(String ID) Returns Quote      So, so far so good. Now, when this service is consumed, to keep things "de- coupled", we are creating essentially a duplicate of the Quote object and mapping from the QuoteService version of the Quote into the consumer's version of the Quote. In many cases, these classes will have the exact same properties. So, if the Quote service is consumed by 5 other applications, we would have 6 definitions of what a "Quote" is. One for each consumer, and one for the service. This feels wrong. I thought code was supposed to be DRY, but it seems like our method of SOA is forcing us to create tons of duplicated class definitions. What are we doing wrong, or is the code duplication just a "necessary evil" of SOA?


title: Why are JOINS deprecated for a in-memory database?

text: Correct me if I'm misunderstanding. Refer to the following sentence: > Stack Overflow copied a key part of the Wikipedia database design. This > turned out to be a mistake which will need massive and painful database > refactoring to fix. **The refactorings will be to avoid excessive joins in a > lot of key queries.** This is the key lesson from giant multi-terabyte table > schemas (like Google’s BigTable) which are completely join-free. **This is > significant because Stack Overflow's database is almost completely in RAM > and the joins still exact too high a cost.** 1 Actually I'm trying to pass from the interest on single technology like Asp.net MVC to architectures design. Can you better clarify the quoted sentence? [1] http://highscalability.com/stack-overflow-architecture


title: Git work-flow for uncertain premise (pending decision)

text: I am not quite sure, how to name my problem. But I will start with how I usually used git. I am working as a single developer on one git repository. Usually I make feature-branches from master, and merge them back into master, when the feature is finished. When meanwhile another feature-branch was merged into master, I rebase the other branch on master, before merging. That worked very good, until recently. One dependency I have in my project, needs an update. But it was not yet decided how this update will be implemented. But I can simulate the new behavior quite simply. So I branched from master, and simulated that fix. So when the actual fix is available and merged into master, all changes above can be rebased back on master. But the decision on that fix is still pending, and my branches are stacking up:               * ee8d0ab (HEAD, featureTwo)      * e659932      * 27986c0 (featureOne)      * f0011e6      * d4187cf      * 552e35a      * 37d597f (simulatedFix)      * e0eb3d0 (origin/master, master)     * b06583c      * d295b3e       I feel, that this is not good. It feels like I am building up dept. Imagine how this would look at featureTen, or featureTwenty. What are the possible drawbacks of this method? And what is the best way, to handle this situation?


title: How is it called when you define constants that simply refer to a large namespace?

text: I am using JRuby. I have many classes implemented in Java, and I want to create objects off of them in my Ruby scripts. Suppose that I have a class `Sprite` in Java. In Ruby, to refer to it, I use the following:               Java::ComMyWebsiteMyProjectName::Sprite      Because Sprite is defined in the package `com.myWebsite.myProjectName`. Now then, to simplify things, I like to do this:               Sprite = Java::ComMyWebsiteMyProjectName::Sprite      Which sets the constant `Sprite` to the `Sprite` class defined in Java. Now my Ruby code can refer to it by just writing `Sprite`. I have a file full of that kind of declarations. Something like:               Sprite   = Java::ComMyWebsiteMyProjectName::Sprite     Texture  = Java::ComMyWebsiteMyProjectName::Texture     Bitmap   = Java::ComMyWebsiteMyProjectName::Bitmap     Math     = Java::ComMyWebsiteMyProjectName::Math     Geometry = Java::ComMyWebsiteMyProjectName::Geometry      Now, I am not exactly very familiar with programming concepts. I am having problems giving this file a name, because I don't even know if there is a name for this kind of thing. **Does this kind of "practice" have an actual name?**


title: How do you incorporate GTD into your daily programming tasks?

text: David Allen's "Getting Things Done" method seems to be a very useful way of organizing tasks and getting those tasks done. Has anyone here used GTD in their day-to-day programming tasks, and if so, what's the best way to go about it?


title: How can I track programming productivity on a daily basis?

text: How can I track that I'm developing software more or less productive than the previous days?


title: Is smarter software necessarily bigger?

text: This is kind of a vague question so I apologize in advance. When software is "smarter", I tend to interpret that as really just saying that it covers more edge cases. First of all, is this correct? Assuming it is, does this mean that the software is full of if/switch statements to make sure input is handled properly, therefore making it "smarter"? This thinking makes me feel like the code would end up bloated and messy. I'm running into a point where I'm wanting to handle these edge cases, but I don't want to bloat my code merely overlooking some best practice. What am I missing?


title: Is it possible to do decent spam filtering without scanning the contents of emails?

text: I don't have much knowledge of the subject but as I know, when servers receive an email they have two sources of data to classify it as SPAM or not. The contents of the message (subject + body) and the metadata that goes with it (from who / to who / server that sent the message, etc). I know you can do basic filtering by blacklisting emails list and other sorts of metadata. But is it possible to do decent spam filtering without checking the contents of a message? Defining 'check the contents' as using any function that relies on data found on the body/subject of the message to classify it as spam or not spam. **Edit** : The reason I ask for this because of the "scroogled" campaign where Microsoft accuses Google of scanning the contents of emails for advertising purposes, and I think that they do the same for spam prevention purposes. So I asked them and they said: > We have tools and system set up to filter spam emails to and from > Outlook.com email accounts. However, we are not allowed to disclose how > these spam filters work for security purposes. > > ME: So can you assure me that no content from my personal email is being > analysed and cross referenced with other data in any way? > > ...In response to your question, its a yes, we can assure you that.


title: Interview: how to ask development process/culture related questions

text: I just watched a presentation about simplicity by Rich Hickey at InfoQ where he goes over the constructs programmers use to produce artifacts and how those constructs make various trade-offs when it comes to achieving simple artifacts. I think that most programmers would agree with a lot of what he says but at the end of the day I don't know how many development shops are actively practicing development processes and using tools that allow them to make simple artifacts. As an interview candidate I would like to work at a software development shop where producing simple artifacts is a top priority. What are some questions I can ask to figure out if the place that is interviewing me is actually such a place.


title: Best Way to Access Hardware per COM Serial Port over USB Adapter

text: We are starting a total new Branch at our firm. I am usually developing database interfaces or internal server/client applications/tools for our company, but I never had to do something with hardware. **Szenario** My Boss want to sell a device, which has a touch-screen to set up the many, many features. However, the configuration of the device can be very time consuming. He wants to give a software free for a good customer and for a litte charge to "small" customers. The customer should only be able to use the software, if he registers at our system, so that he can't copy the software without a notice by us. **Requirements** The device has a build in USB cable. If you plug it in your computer it opens a new COM serial port. The software has the following requirements:   * Configurating different presents for the device   * Reading and writing the presets to the device   * Software will refuse to start, if the user has no registration at our server   * The user can store his presets at our server and share it with other customers   * One preset, copied over and over to multiple devices My boss has seen similar system (he said something about logitech harmony remote controls) and it is now on me, to create the architecture. Server Side: The server is not that kind of problem. We have enough different machines to suite any kind of favour (IIS, LAMPP, Apache/Tomcat etc.) I could take MSSQL or MySQL DBase to store the data, thats not the problem. Client Side: This is the tricky part for me. I never did something with hardware. My boss suggested I should use Silverlight. I claimed that I want to do it with a native application. But what is the best combination?   * Total Client-Side (C++, C# or Java are the languages I could write)   * Mixed Structure #1 Silverlight + Native "Driver" Application   * Mixed Structure #2 Java-Applet + Native "Driver" Application   * Browser Only - Silverlight or Java-Applet?   * Any other suggest The device is for a special customer group who's getting personal trained with any purchase so security risks like unsafe code or dangerous browser plugins are no negative selling argument. I did some research about COM Serial Port connection with Silverlight and P/Invoke but I don't want to start without a discussion what would be the best way.


title: How do I know I'm not violating a software patent?

text: I'm using a android like lock screen (The one with the nine dots that you have to connect to log in) in my application currently. I'm afraid of getting a mail from google because of some patents that I didn't know. Is the android lock screen patented or can I rebuild it and use it in my application?


title: What is a good stopword in full text indexing?

text: When you go to the Appendix D in Oracle Text Reference they provide lists of stopwords used by Oracle Text when indexing table contents. When I see the English list, nothing puzzles me. But the reason why the French list includes _moyennant_ (French for _in view of which_ ) for example is unclear. Oracle has probably thought it through more than once before including it. How would you constitute a list of appropriate stopwords if you were to design an indexer?


title: Can a layer consist of multiple projects / dlls?

text: I am working on the architecture for a new web application and I am pretty much a complete newbie when it comes to architecture. Working my way through .NET Application Architecture Guide, 2nd Edition and learning a lot. I have decided to go for the "standard" 3-layer architecture: Presentation layer, Business layer, Data layer. Will be using ASP.NET MVC and Entity Framework. Currently the business layer contains the logic and business entities (anemic models). I am planning to use the business entities as EF entities. That would, however, cause the data layer to have a depency on the business layer. This "problem" can be solved by moving the business entities into its own project and have the layers that have dependencies on the business entities reference that project.   1. Is that an ok / good way of doing things?   2. Will / can / should the business entities project be considered part of the business layer?   3. Can a layer consist of multiple projects, that is, the layer only acts as a "logical container"? In the above mentioned book they talk about how the business layer can consist of "Business Workflow", "Business Components", "Business Entities", and I assume that each of those are a separate project (maybe even multiple projects)?


title: What are all the components of a "Facebook App"?

text: I am a developer who has never personally partaken in social media (in any form) for reasons completely outside the scope of this question. I am "off the grid" (no Facebook, Twitter, etc accounts). I'm currently building a web app and would like the app to have a presence on Facebook, and possibly even "port" my app over as a Facebook app. My _understanding_ of Facebook Apps is that they're just normal web apps that get `<iframe>`d into a Facebook page. The app is actually hosted on your server (not FB's servers). But this got me thinking:   1. Don't Facebook Apps have "profile pages"? Is there anything developers can do to customize the behavior of their own profile pages?   2. Do apps have the ability to do things like MySpace themes used to do (i.e., customize and interact with User profile pages, Groups, etc.)?   3. Do Facebook Apps gain any sort of extra capabilities (inside of Facebook) that a normal web app would not have? It seems to me like if all a Facebook App is, is an iframed-web app, that it would still need to communicate with Facebook via its many APIs, just like a normal app would have to, right?   4. If it's not possible to write an app that can customize the UI or behavior of user profiles and other pages, then how do games like "Farmville" interact with User profiles so that you see updates to profiles like "John Smith reached level 2 of Farmville"? Basically, I'm asking any battle-worn Facebook app developers if my understanding of Facebook Apps is correct, or if I'm missing anything big here. It's my understanding that for security reasons (obviously) Facebook doesn't allow apps to customize anything outside of the iframe it lives in. So if I want my app to appear like it's "interacting" with its Facebook users, it looks like I just need to publish stuff to the users' news feeds to try and encourage people to use my app (please correct me if I'm wrong here!). Thanks in advance for any corrections, clarifications, advice or suggestions!


title: How do you keep enthusiam up when working on an overwhelming project?

text: When I'm working on a complex / large programming project and I get overwhelmed or lost, I often lose motivation and just don't have the energy to really dig into the problem once again to figure it out. After some time goes by, I may get back to it and have the renewed enthusiasm it takes to think about the problem from first principles again. This usually works, if I get back to the original problem. More often than not, I get side- tracked on other projects and the original program/problem lies dormant forever. I know this is a common reaction to complexity, or being overwhelmed by a problem and not knowing where to go to next. You run out of steam pretty quickly. But there are things I've come across that I can focus on for fun, and it often gets me stoked to get back into programming, the more complex the project the better! These things would sound incredibly dorky on any other site, but probably less so here. I'm talking about things like listening to a Stack Overflow podcast, reading an old Steve Yegge or Paul Graham article, watching an episode of Matt Chat where he's interviewing some programmer that worked on an old game for the Atari 800, or just watching a movie like Wargames (not many other movies come to mind though). The problem is, sometimes I run out of these ideas that renew my interest in computer science, so I'm asking for some of your ideas. Maybe limit it to one per answer so people can vote for particular answers/recommendations. Thanks for your input!


title: Amazon SOA: database as a Service

text: There is an interesting interview with Werner Vogels which is partly about how Amazon does Service Oriented Architecture: > For us service orientation means encapsulating the data with the business > logic that operates on the data, with the only access through a published > service interface. No direct database access is allowed from outside the > service, and there’s no data sharing among the services. I do not understand that. Why do they need to 'wrap' a database into some layer if it already can be consumed as a service by other service through database adaptors? Does Amazon do that just because they need to expose the database to third parties or because of anything else? Why "no direct database access is allowed"? What are the advantages of such an architectural decision?


title: Ajax application: using SOAP vs REST ?

text: I'm building an ajax heavy application (client-side strictly html/css/js) which will be getting all the data and using server business logic via webservices. I know REST seems to be the hot topic but I can't find any good arguments. The main argument seems to be its "light-weight". My impression so far is that wsdl/soap based services are more expressive and allow for more a more complex transfer of data. It appears that soap would be more useful in the application I'm building where the only code consuming the services will be the js downloaded in the client browser. REST on the other hand seems to have a smaller entry barrier and so can be more useful for services like twitter in allowing other developers to consume these services easily. Also, REST seems to Te better suited for simple data transfers. So in summary SOAP is useful for complex data transfer and REST is useful in simple data transfer. I'm currently under the impression that using SOAP would be best due to the complexity of the messages but perhaps there's other factors. What are your thoughts on the pros/cons of soap/rest for a heavy ajax web app? **EDIT:** While the wsdl is in xml, the data I'm transferring back and forth is actually in JSON. It just appears more natural to use wsdl/soap here due to the nature of the app. The verbs GET and POST may not be enough. I may want to say something like: processQueue, or executeTimer. This is why my conclusion has been wsdl/soap would be good for bridging a complex layer between two applications (client and server) whereas REST would be better (due to its simplicity) for allowing many developer-users to consume resources programmatically. So you could say the choice falls along two lines   * Will the app be verb-oriented (completing tasks: use soap) or noun-oriented (consuming resources: use REST)   * Will the api be consumed by few developers or many developers (REST is strong for many developers)?  Since such an ajax heavy app would potentially use many verbs and would only be used by the client developer it appears soap/wsdl would be the best fit.


title: What kind of screen has the best image quality for reading/programming?

text: I'm thinking about buying a new laptop, and while I bought my original one oblivious to the fact that there could be different quality screens out there, after seeing the screen on my sister's netbook I realized that I might have to be cautious with my next purchase. Granted, I did not confirm that the reason my sister's screen looks the way it does is due to the screen itself and not color scheme/graphics card, but I know very little about the different screen technologies and how they differ in image quality and therefore can't really tell if wondering about it even makes sense or not. So what I'm asking is: should I be worried about screen quality? And if so, what technologies should I be looking for? How do they differ and which are the best ones? What are the different elements that determine the quality of a screen and which stats should I go for in each element? For the record, I'm not interested in opinions about screen size, but picture quality for lots of reading/coding.


title: What is the benefit of using sharp architecture?

text: I'm working in a project that use nhibernate as orm. Is there any benefit for me to use sharp architecture? what is these benefits?


title: AddIn, AddOn, And Plugin

text: Even though at first glance the words AddIn, AddOn, And Plugin give the same meaning, there are some differences between them. Could anyone explain to me the subtle differences between _AddIn_ , _AddOn_ , And _Plugin_?


title: What is the correct UI interface to learn for creating Windows phone 8 apps?

text: I am a veteran Delphi 6 programmer transitioning to C# development. My first project is a open source library that will have a minimal user interface since it is meant to be used as a Component primarily on desktop PCs running Visual Studio. My next project is going to be a Windows 8 phone app and I intend for that platform to be my primary focus for future C# development, not the desktop. My concern is that I waste as little time as possible learning a presentation framework that will benefit or distract me from writing Windows 8 phone apps. The plethora of framework names I have already encountered include, WinForms, WPF (Windows Presentation Framework), Silverlight, Silverlight Mobile, Metro and there may be others. Given my goal outlined in the first paragraph above, which is the correct framework to study for developing Windows 8 phone apps? I read about the Portable Library Tools on this Stack Overflow thread: http://stackoverflow.com/questions/5522355/windows-phone-7-wpf-sharing-a- codebase But the reply by Simon Guindon seemed to indicate to me that it's not the best solution for writing a competitive Windows 8 phone app.


title: What amount of time do you spend doing each of the following

text: Recently I've been thinking I spend too much time on SO and general learning / keeping up with technology rather than actual coding. So my question is what ratio's of your time do you spend on the following:   * Actual coding   * Reading around the subject, improving knowledge, learning new things


title: Are there any good resources for refactoring existing C# code to use LINQ while keeping your tests passing?

text: I've been teaching myself a little LINQ and an exercise I thought would be useful was to take my existing Project Euler C# code, which I built using Test Driven Development and gradually convert it to LINQ. I realise that LINQ is not always the best solution for all of the Project Euler problems, but I don't want to get into that here. I'm wondering whether or not it's feasible to refactor "traditional" OO C# code to use LINQ and functional programming syntax whilst keeping all of your tests passing. I can't find a way to make the tiny steps I'm used to making using TDD when converting to LINQ and this is a roadblock for me. I seem to have to make large changes to come up with a single function that I then replace whole chunks of my code with. I realise I could write this from scratch in LINQ, but in the real world, I'd like to be able to replace parts of my existing C# code to take advantage of LINQ where appropriate. Has anyone been successful with this approach? What resources did you find useful for refactoring existing C# code to use LINQ whilst taking a Test Driven Development approach?


title: Robot arm sample problem in Skiena's "Algorithm Design Manual" seems to be invalid to me

text: I'm reading Skiena's _Algorithm Design Manual_ and there is a problem on page 5, "Robot Tour Optimisation", where he says this about the sample problem: "Suppose we are given a robot arm equipped with a tool, say a soldering iron. In manufacturing circuit boards, all the chips and other components must be fastened onto the substrate. More specifically, each chip has a set of contact points that must be soldered to the board. To program the robot arm for this job, we must first construct an ordering of the contact points so the robot visits the first contact point, second, etc..." "We must first construct an ordering" - that seems strange to me. Because, well, every chip has certain number of pins and they're numbered and their position is documented, look here: ![enter image description here](http://i.stack.imgur.com/Q0MWK.jpg) I mean that chip doesn't have a set of pins, it have an ordered list of pins, ok, it doesn't but it has very specific dimensions and specific order of pins on each side so their precise position (and order) can be easily calculated. Maybe unrelated, but probably IRL the board is moving on some sort of clamp in X, Y dimension and soldering iron only goes up and down. The simplest problem I can give as an example of Robot Optimisation tour is a pizza courier who rides a car and needs to visit all his clients (let's assume that traffic is near zero) and returns to the restaraunt with as little gasoline spent as possible. So he needs a tool (car navigator), that will solve this problem for him. And that navigation application needs to find the optimal route - so, it illustrates the problem. Am I right that original problem illustration with robot arm is wrong?


title: Why is it always "what language should I learn next" instead of "what project should I tackle next"?

text: Why do beginning programmers (like me) always ask about the next language they should learn instead of asking about the next project to tackle? Why did Eric Raymond, in the "Learn How To Program" section of his "How To Become A Hacker" essay, talk about the order in which you should learn languages (vs. the order in which you should tackle projects). Do beginning carpenters ask "I know how to use a hammer ... should I learn how to use a saw or a level next?" I ask because I'm finding that almost any meaningful project I'm interested in tackling (e.g. a web app, a set of poker analysis tools) requires that I learn **just enough** of a **multitude of languages** (Python, C, HTML, CSS, Javascript, SQL) and frameworks/libraries (wxPython, tkinter, Django) to implement them. Thanks, Mike


title: Is it bad style to redundantly check a condition?

text: I often get to positions in my code where I find myself checking a specific condition over and over again. I want to give you a small example: suppose there is a text file which contains lines starting with "a", lines starting with "b" and other lines and I actually only want to work with the first two sort of lines. My code would look something like this (using python, but read it as pseudocode):               # ...     clear_lines() # removes every other line than those starting with "a" or "b"     for line in lines:         if (line.startsWith("a")):             # do stuff         elif (line.startsWith("b")):             # magic         else:             # this else is redundant, I already made sure there is no else-case             # by using clear_lines()     # ...      You can imagine I won't only check this condition here, but maybe also in other functions and so on. Do you think of it as noise or does it add some value to my code?


title: Javascript tools for branch coverage

text: I'm looking for tools that will help me write test cases to cover all paths through a function in Javascript. Ideally, I'd like something that will spit out a list of combinations of parameter and property values that should be tested. However, if the tool simply told me which parameters and properties have an effect on the function, that would be very useful as well. Thanks! edit: I'm not certain that "branch coverage" is the correct term for what I'm describing. If "code exploration" is a better term (or anything else), please add a comment.


title: Is there a language offering LISP-like macros with a more complex syntax?

text: LISP's macros are extremely powerful constructs, and the inability to introspect and modify the program itself beyond the method signature level has always struck me as a limitation. Yet I favour "complex" syntax because it tends to be closer to natural language. **So far I have failed to find a language which combines a powerful macro mechanism such as LISP's with a naturally looking syntax** (1). Is anyone aware of such a language? Footnote:   1. I would consider python to have a naturally looking syntax as it allows constructs like this: `if 0 < a < 5 and b in list`. The avoidance of braces to structure blocks is irrelevant in this case, though.


title: How to deal with well-meaning open-source contributors?

text: If a programmer contacts you and asks to contribute to your project, how do you handle it?   * You don't know if this guy is any good. Perhaps he'll be more trouble than he's worth.   * He might be trying to attach his name to a successful project just for the kudos.   * He might be trying to take the project in a direction you don't really want, adding features you think aren't worth the extra complexity.   * Or, he might be a very useful contributor. You just don't know. How do you handle such requests from people you don't know (On GitHub, specifically, if that makes any difference)? What's the etiquette here?


title: How to sell logistical procedures that require less time to perform but more finesse?

text: I am working with a group where part of the responsibilities is managing a certain set of configuration files which, of course, have the same skeleton/structure across different environments but different values (like server, user, this setting, that setting etc.). Pretty classic scenario... The problem is that everyone just goes and modifies final, environment- specific files and basically repeats the work for every environment. Personally, I am offended to have to peform repeatable, mundane tasks in this day and age when we have technologies to automate it all. So I devised a very simple procedure of abstracting the files into templates, stubbing env-specific values with parameters and then wrote a simple Perl script that, given a template and an environment matrix with env-specific values for each param, produces the final file. So this is nothing special, cutting-edge or revolutionary -- I am pretty sure that 20 years ago efficient places did their CM like that. However, that requires that changes are made at the template level and then distributed across different environments using the script and not making changes in the final environment-specific files. This is where I am encountering resentment as they feel "comfortable" doing it their old, manual, repeated labor way. Personally, I don't have a problem with them working hard rather than smart but the problem is when I have to build on top of someone else's changes, I have to merge their changes into my template from a specific file, which takes time and is grueling. So my question is how to go about selling my method, which makes it so much faster in an environment that is resentful to change and where most things have to be done at the level of the least competent team member?


title: Why was support for Windows XP dropped in PHP 5.5?

text: In the release notes for PHP 5.5.0 it's announced that Windows XP and Windows 2003 are not supported anymore: > Drop Windows XP and 2003 support. (Pierre) Why is this? Many people in different companies develop applications under Windows XP. So, can anyone tell me what is the sense of dropping Windows XP and 2003 support?


title: Looking for enterprise web application design inspiration

text: I've checked many websites to be inspired about what the look and feel of a serious enterprise web-application should look like. But the whole I saw were designed for being used by single users and not serious corporate users. The designs I saw were mostly happy-colored, and looked like being developed by a small team of eager young passionate developers. But what I'm looking for, are showcases of serious web apps' designs (e.g. web apps developed by large corporations) that are developed for being used by a large number of corporate uses. Can you suggest me sources for this kind of inspiration?


title: Who is the father of CIL?

text: ...formerly known as MSIL, simple question, it is widely known that Anders Hejlsberg is the father of C#, but is there a "father of CIL"?


title: to know how many visitors visit my website, i absolutely have to put some kind of tracking code within the page itself?

text: Is it true that to know how many visitors visit my website, some kind of tracking code had to placed within that page itself, and there is no other way around it? Even if we use something like Google Analytics indirectly they are also placing some kind of tracking script within our pages right? Or is it true that even there are no tracking script within my page, someone (some authority?) will have access to this info?


title: Is it bad practise to create instances from a SQL-query?

text: I'm researching ways to create a OO-model/repository-layer using PHP's PDO. My idea was to create model classes that represent a domain object and a repository class for each model that has the responsibility of:   * Saving to the database by taking a model as argument and mapping the objects properties to the VALUES of the SQL-query.   * Reading from the database by return an instance of a model in a similar fashion. I was inspired from a course in OOP in which we used .NET, EF and LINQ for the Labs. I asked a question on SA about how this could be achived on SA. I got flamed because is is supposedly bad practise. I don't see why this is the case.


title: Scrape Intranet site without a web server

text: I'm trying to rebuild a simple c# time tool that displays certain statistics about time worked for the web, however, I don't have access to a server so I can't use server code like PHP which I would do if I could and this task would be a doddle. The employee's work information is stored on an intranet site that the C# tool could access by scraping that site and grabbing what it needed. How can I do this (scrape the intranet site) without using server code and only client-side things like HTML, JavaScrit/jQuery? **Edit:** Forgot to mention the Windows machines don't have .net installed


title: How to read large XML files efficiently

text: I have a large XML file (about 75,000 lines) where I have to build a catalogue (houses) from. Building the lists works fine, but now I have a problem. The catalogue should have a detailed presentation page of one house. One house (`<item id="123">`) has about 800-1200 lines of data, based on the house type. **Which is the best way, as referring to making the script faster and saving lines of code, to read these data and present them?** Some houses, for example, have a sauna, and when these data are in the XML file, the presentation page should contain a section sauna. I tried before to read the whole XML content with a recursive function into arrays and with a lot of `foreache`s (maximum depth of children is three) with SimpleXML, but it was really ugly slow, and the recursion did not work at all, because my computer could not handle so much input. **Is there any other way to build this data except to query every variable with`if`?**


title: Useful Scripts for CM?

text: I'll be forming a remote team, and I want to be able to use scripts (or something) to make _sure_ that people's code is checked in every night. I currently use some BASH scripts that are kindof wonky and aren't customizable easily. Does anyone have any useful tools, tips, or resources for this?   Are there any pitfalls to doing this that I'm not seeing, or can I do it better another way? (cross-posted to super-user)


title: Do libraries and frameworks swing more on the GPL or MIT side?

text: I like the GPL license but the project I'm working on is a more general purpose one that will be used inside other programs. It doesn't run independently like a CMS or application would. So I'm looking around at other projects to see what they've done.   * JQuery has an interesting MIT/GPL license   * Zend framework has New BSD license   * Symfony framework has MIT license  As developers, is there an established preference that we expect from libraries. I rarely cared because I never build applications that were sold or distributed, which eliminated the possibility that I would be in conflict with the license of a library I'm using, but I want to know what others are thinking. Will you avoid using a library or a framework if it's GPL? I'm a bit torn. I'd like to use GPL and as the only license (unlike JQuery for example) but I also worry that this will scare developers away who want to use the library to build distributable code. The other thing is I'm seeing that many libraries are frameworks are released as MIT, but I find the MIT license, well, a bit too "loose" for my taste.


title: Do you read C or C++ compile errors after the first one?

text: I never understood why C and C++ compilers try to recover from errors and continue parsing. Almost always, the first error generates a stream of bogus errors that will disappear as soon as the first one is fixed. After several years of experience, I simply stopped looking at any error except the first one of every file. I rerun the compiler and then do that again until there is no more errors. Is it a common practice?


title: Browser security and payments

text: I've been finding a lot of blog posts claiming JS encryption is unsafe, here's a couple of detailed ones: http://www.matasano.com/articles/javascript-cryptography/ http://rdist.root.org/2010/11/29/final-post-on-javascript-crypto/ My question is, if browsers truly are inherently unsafe then, by extension, entering any PCI-related info in the browser is unsafe - regardless of JS encryption, HTTPS, or any other security measures? Which would imply that malicious parties should be taking major advantage of this fact, right? Could someone provide specific examples where browser vulnerabilities were leveraged to steal **massive** amounts of PCI-info/PII (by "massive" I mean comparable to the amount that could be obtained by hacking into the hosting servers/DB)? Also, despite all those posts describing security flaws there's a proliferation of payment services and JS crypto libraries - does that indicate that most companies/communities:   1. are unaware of browser vulnerabilities?   2. are simply disregarding the underlying issues and jumping on the bandwagon to make some dough?   3. have weighted the (possibly low) likelihood of someone going through the trouble of exploiting browsers and decided it's still worth to capture payments through browsers? EDIT Using SSL/TLS addresses some of the issues, but definitely not all. Here are a few notable issues that fall outside of the area that SSL/TLS can solve (quoted directly from the Matasano blog post): > The prevalence of content-controlled code. > >   * We mean that pages are built from multiple requests, some of them > conveying Javascript directly, and some of them influencing Javascript using > DOM tag attributes (such as "onmouseover"). > > > The malleability of the Javascript runtime. > >   * There is no reliable way for any piece of Javascript code to verify its > execution environment. Javascript crypto code can't ask, "am I really > dealing with a random number generator, or with some facsimile of one > provided by an attacker?" And it certainly can't assert "nobody is allowed > to do anything with this crypto secret except in ways that I, the author, > approve of". These are two properties that often are provided in other > environments that use crypto, and they're impossible in Javascript. > > > What else is the Javascript runtime lacking for crypto implementors? > >   * Two big ones are secure erase (Javascript is usually garbage collected, > so secrets are lurking in memory potentially long after they're needed) and > functions with known timing characteristics. Real crypto libraries are > carefully studied and vetted to eliminate data-dependant code paths --- > ensuring that one similarly-sized bucket of bits takes as long to process as > any other --- because without that vetting, attackers can extract crypto > keys from timing. > Again, my main point is that, technically, once a credit card number (or some other important piece of info) is entered into a text field of a page there's a chance that it's been compromised - and at that, compromised more easily then if it were entered in the native application.


title: How to name filename parameter to make clear it should contain full path?

text: I'm seeking vital naming of string `filename` parameter in parameter list used in various methods where **filename with full path** is expected. In many cases also UNC path can be actually supplied as full path because many libraries handle it natively. I usually call the parameter just `filename`, but it can be misleading in two ways:   * Beginners tend to think it is only name of file – without path.   * If there is a need of splitting the value into path and filename, term **filename** sticks better with filename part without path which appeared after split. Anyway, it is not easy to give that second part better name than `filename`. Alternative of splitting `filename` to `path` and `filenameOnly` looks weird to me. I think it might be better to use clearly distinguishable term for filename with path than borrowing **filename** which already has stronger meaning for something else. I was thinking about term `absoluteFilePath` or `fullyQualifiedFilename` to stand as argument names. Maybe they are good and I need only some encouragement to start using them, but I would like to understand your best practices. **EDIT:** I would still like to stick with official VB.NET naming and capitalization conventions, so the only thing I need help sharpening is clear self-documenting wording of the term. (Not whether I should use Hungarian notation or not – I cannot.)


title: Java GNOME bindings, are those a good idea?

text: What do you think of Java's GNOME bindings and I was surprised to know that the latest version of the bindings was released this month and they're backed by a company that uses them, which means that there's a considerable amount of activity in the project, and that it's not going to be ditched anytime soon Is this going to be a second chance for Java on the desktop, since GTK+ is cross platform like swing, but less bloated and more responsive Should I be learning how to develop applications using it? or it's not worth the time?


title: Currently in Grad School, itching to get back in the mix

text: I was in the software industry for 3 years before going back and pursuing my masters. I have a year of grad school under my belt with a year left and a 4.0 GPA. I'm really itching to get back into do software dev full-time. I'm doing research and an area I'm interested in, Computer Graphics, but know that I probably won't work in industry using what I've learned. I think the main benefit to finishing my degree is to pad my resume and learn certain things that I wouldn't have learned other wise. Would it be dumb for me to quit grad school and get back into the work force? Is grad school a bad decision for passionate programmers( I consider myself one )?


title: How do you check bugs on your client's PC's?

text: It seems like there are a plethora of methods for dialing in and checking out what's going on on a client's PC. But they seem to boil down to just 2. Dialing in and checking it out with VNC and Remote Desktop. VNC seems abysmal with more graphics laden OS's and it sometimes is too much to ask to get a access to a terminal server (especially when the client doesn't have one). What other methods are out there for connecting with clients to diagnose and fix bugs they they can reproduce, but may not necessarily be able to adequately describe over the phone. Alternatives to VNC and Remote Desktop are appreciated, but really looking for a better way to do it than just to dial in and check it out - or the most effective way to use VNc and Remote Desktop.


title: Session state provider and atomic operations

text: I've been thinking about this and it is blowing my mind... How does a session state provider properly works internally? I mean, I tried to write a custom session state provider based on Azure Tables or Blobs, but quickly I realized that because there is no way to ensure an atomic operation or establish a lock, race conditions are suitable to happen when several web servers do operation on that shared information. I know that there is a SQL Server Session State Provider (SQLS-SSP) and people is happy with it, so I guess that it's using some kind of transaction isolation level in order to accomplish some degree of concurrent safety, like checking is the data is lock (a simple column), locking it if not and returning the data in an atomic operation, but is that so? what does happen if the data is lock? does it returns an error? block the call for a while? returns it in read-only fashion? Cloud computing paradigms could be somehow new, but webfarms have been here for a while, so as I'm pretty new on it... do you recommend any good lecture about the topic? Thanks.


title: DRY code, DRY tests?

text: At some point I had to create some class "Class1" and that class needs a method "method". So I have the following:               Class1MethodTest: A total of N tests that check the behavior of Class1.method     Class1 method: A full implementation of the method      But a bit later I need a different class "Class2" to have a completely similar method "method". Now I have several approaches: ## Approach 1               Class1MethodTest: A total of N tests     Class1 method: Full implementation     Class2MethodTest: Another set of identical tests     Class2 method: Another full implementation      Pros: Stupid simple Cons: not DRY At least that's the first attempt and I might even write this before doing any refactoring, right? ## Approach 2:               _hidden_private_implementation_function: Full implementation of required method     Class1MethodTest: A total of N tests     Class1 method: Call hidden_private_whatever     Class2MethodTest: Another set of identical tests     Class2 method: Also call hidden_private_stuff      Pros: DRY code, still stupid simple Cons: Tests aren't DRY, "Test interface, not implementation" ## Approach 3:               MethodTest: A total of N tests     TotallyPublicCommonMethod: Full implementation of required method     Class1MethodTest: Just one test to verify that Class1 method calls the Public one     Class1 method: Call public common method     Class2MethodTest: One more test     Class2 method: Also call common method      Pros: DRY, stupid simple Cons: .. any other than "You're testing implementation, not interface"? ## Approach 4: This is where it gets a bit exotic. Python allows me to DRY the "Approach 3" directly:               _hidden_private_implementation_function: Full implementation of required method     makeTestForClass(cls): return a total of N tests for class cls     Class1MethodTest = makeTestForClass(Class1)     Class1 method: Call hidden_private_whatever     Class2MethodTest = makeTestForClass(Class2)     Class2 method: Also call hidden_private_stuff      Pros: DRY, "Don't test implementation" Cons: Not that simple. Too hard to modify if I ever decide to change something in Class1.method, but not Class2.method I can think of a couple more approaches but those are not very different from these above. Right now I have some code looking something like "Approach 1" and I am thinking on which way I should go next to make it all cleaner and better.


title: What is the best way to deploy commercial programs on Linux?

text: Due to the diversity of Linux distributions, it is quite common for programs to be distributed in source format together with scripts in order to assist the configure, make, make install sequence. When it comes to commercial programs, however, distributing the source is usually simply not possible. So if anybody wants to sell a program and deploy it to a Linux environment, what should he do? How is this normally done?


title: How to plan for multi-platform application development

text: In my earlier days of programming, I was using Visual Basic for learning. It taught me many concepts, and I was able to make some cool programs (in my opinion, anyways...). I have expanded my horizon to basic C/C++, PHP, and MySQL. One of my most favourite projects, I want to turn into a multi-platfrom (for x86/x64) windowed application, and have it open source. I decided on the license already, but I want to know, before I start developing in a new language, how can I choose which language to use, that is multi-platform, and allows for windows to be created? I do not wish to use web technologies, as the application will work with lots of local files at a time. This is **not** a question about which technology is better, but about which one would be useful for this project. I know something has to be possible, because there are apps that run as Mac OSX binaries, Windows binaries, and even Linux binaries, all in windows (i.e. VLC Media Player, Firefox (Ice Wheazel), etc)


title: Text Classification Implementation

text: I've been trying to implement a text classification system. It needs to read a text file, and extract the words and the word frequency. So far, I've been planning to parse the words, put them in a dictionary and save it to an XML file. I am using C++/CLI. Is this a good implementation or is there a simpler or better implementation? May be related question (some code implementation): http://stackoverflow.com/questions/10631309/save-dictionary-to-xml-file


title: What to do when you're forced to code under bad coding (design) standards

text: This isn't about the typical naming conventions, where to place your comments, should we use regions, etc. This is about a coding standard that discusses specifics on how a programmer should design his applications. Stuff like: (on a .NET app and not in the exact wordings)   * Make as few classes possible   * Classes should do as much as their real world counterparts can   * Modification is better than extension   * One DLL per category (One library for email functions, one library for File related functions) Everyone's had their experience with bad code and possibly bad design, but what if you were placed in a team (leaving is not an option) where they had design standards that just don't feel right. I'm unsure how to respond professionally when I feel like I'm dying inside whenever I'm asked to code this way.


title: How much time should I dedicate to refactoring my code?

text: I don't know if it's just with me, but when I start refactoring some code I waste a lot time doing that and it never ends. Every time I read the code again, I find something that can be improved, code refactoring is like my brain into a infinite loop and the end conditional is reached randomly with no satisfaction. So, how much time should I dedicate to refactoring my code?


title: Is The Free Lunch Over?

text: In his famous The Free Lunch Is Over article from 2005, Herb Sutter predicted a Concurrent Programming Revolution as big as Object-Oriented Revolution. Has this revolution really happend in years 2005 - 2013? * * * Key points in the article:   * Processor manufacturers have run out of room with most of their traditional approaches to boosting CPU performance. Instead of driving clock speeds ever higher, they are instead turning to hyperthreading and multicore architectures.    * Applications will increasingly need to be concurrent if they want to fully exploit CPU throughput gains.   * “Oh, performance doesn’t matter so much, computers just keep getting faster” statement will be wrong.   * Efficiency and performance optimization will get more, not less, important. Those languages that already lend themselves to heavy optimization will find new life; those that don’t will need to find ways to compete and become more efficient and optimizable. Expect long-term increased demand for performance-oriented languages and systems.   * Programming languages and systems will increasingly be forced to deal well with concurrency. We desperately need a higher-level programming model for concurrency than languages offer today.


title: Is it reasonable to expect a new graduate to be able to roll his own blogging software?

text: When deciding whether to hire a new graduate, is it reasonable to expect them to have a software development portfolio, where they have produced at least something equivalent in complexity to a blog software?