title: How to review code that you do not understand?

text: I have been given the role to improve development in our company. The first thing I wanted to start was code reviews since that has never been done here before. There are 3 programmers in our company. I am a web programmer, my known languages are mainly PHP, ActionScript and JavaScript. The other 2 developers write internal applications in VB.net We have been doing code reviews for a couple weeks now. I find it hard to understand VB code. So when they say what its doing, for the most part I just have to take their word for it. If I do see something that looks wrong, I explain my opinion and I explain how I would address it in one of the languages I know. Sometimes my suggestions are welcomed but many times I am told things like "this is the best way of doing it in _this_ language" or "that doesn't apply to _this_ language" or similar things of that nature. This may be true, but without knowing the language I am not sure how to confirm or refute these claims. I know one possible solution would be to learn vb so I can do better code reviews. I really have no interest in learning vb (especially since I have a list of other technologies I am trying to learn for my own projects) and would like to keep this as a last resort but it is an option. Another idea that came to me is, they both have interest in C# and so do I. Its relative to them because its .net and relative to me because its more similar to the languages I know. Yet it is new to all of us. I thought about the benefits of us all collaborating on a pet C#.net project and reviewing each others code from that. I guess theres also the possibility hiring a consultant to come in and give us some code reviews. What would you recommend I do in this situation.


title: Is there a correlation between code complexity and developer productivity?

text: Is the time spent refactoring a code base worth it in the long run, in terms of developer productivity? It seems pretty clear to me that modifying a clean, well designed system is much simpler and faster than working on a poorly designed one, but I'm after some solid evidence. Are there any studies around this topic?


title: is it considered plagiarism to comment out code I copied from elsewhere?

text: If the plagiarized code is commented out because I found another way to solve the problem, but I forgot to remove the comments, is that considered plagiarism? I used the copied code to help me debug and compare the output between my own code and the copied code. In the final code, I commented out the copied code. Since comments don't affect how the code runs, can comments be considered plagiarism?


title: N queens, X by Y board decision problem interview question

text: I was asked the following question in an interview today and I've been thinking about it ever since. I was not able to answer it and haven't been able to find a solution online. Given a chess board with dimensions X by Y and N queens, determine whether it is possible to arrange these queens on the board such that they cannot attack each other. A 2 x 3 board with 2 queens does have a solution so the algorithm would return true:               Q . .     . . Q      I'm looking for a programming approach to this puzzle, not just ways to solve it on paper, for example.


title: db design: circular references for the-one-of-many case

text: There are many questions about circular references around (if they are bad or not) but this one will be concrete. Consider the following case. There are two models Image and User. Users have associated images and they can pick one of them as their profile image. There are essentially two ways of modelling this (forgive me my pseudo-syntax): 1)               User:        id - primary key        profile_image - nullable foreign key to Image          Image:        id - primary key        user - foreign key to User      2)               User:        id - primary key          Image:        id - primary key        user - foreign key to User        profile - boolean true/false         Both of these approaches have some problems.   **In the first case:**   * well-known chicken-egg problem (e.g. foreign keys must be off when recovering from backup)   * It can happen that profile image points outside of domain of images associated with user   * There is a redundant dependency link (i.e. one more relation when compared to the first solution). That will have some impact on an application code   * What if we later decide to have an ordering on images where the first one is the profile one? **The second case:**   * There is slight data redundancy (many times **false** )   * **true** can occur more than once   * slightly less intuitive (at least for me) So my question is, which of these two solutions is better/cleaner? What do you prefer and how to tackle problems they bring.


title: Are these programming "classics" still relevant today and should I read them?

text: I have come across numerous older posts that highly recommend the following language agnostic programming books:   1. **Code Complete** by Steve McConnel   2. **The Pragmatic Programmer** \- Andrew Hunt and Dave Thomas   3. **Programming Pearls** \- Jon Bentley   4. **Refactoring** \- Fowler, Beck, Brant, Opdyke, Roberts   5. **Design Patterns** \- Gamma, Helm, Johnson, Vlissides   6. **Don't Make Me Think: A Common Sense Approach to Web Usability** \- Steve Frug I found these recommendations on Jeff Atwood's Coding Horror and Scott Hanselman's Blog and mostly the same recommendations on other sites as well. If I read these book today, are they still relevant and will they improve my code, expand my mind, thinking abilities and generally make me a better programmer? Are some timeless, while others are not? Are there other brilliant books, I have missed, that will be useful today?


title: Does DDD make sense for apps which mostly present data?

text: I'm responsible for designing a dashboard and data manipulation front-end for a sale transaction database and am not quite sure what type of architecture to use. The database is populated by an external ETL system. The required functionality for my app is very simple; it must display a few alerts of exception conditions it detects in the database, present a few charts and tables, and some basic CRUD operations on a few tables. There is very little _behaviour_ required; the business will use the app to find out about things, rather than do things. Given this lack of behaviour, does a DDD approach make sense? My current thinking is to create database views to encapsulate the queries my app will need, wrap these views up with an ORM, and have the web controller query the repository layer to get an ORM object with the data it needs. This ORM object would then be passed into the presentation layer. This does of course create strong coupling between the database, the ORM framework, the presentation layer, and my logic. A reasonable amount of what logic there is would wind up in the database views. Can I make a DDD approach work for this kind of app, or is there a more suitable way of doing it?


title: Identity matrix using Fortran 95

text: The following code give the identity matrix of any size the user wish it to be:               program identitymatrix            real, dimension(:, :), allocatable :: I       character:: fmt*8       integer :: ms, j           print*,'the size of the matrix is?'      read*,ms            allocate(I(ms,ms))       I = 0                           ! Initialize the array.       forall(j = 1:ms) I(j,j) = 1     ! Set the diagonal.            ! I is the identity matrix, let's show it:            write (fmt, '(A,I2,A)') '(', ms, 'F6.2)'       ! if you consider to have used the (row, col) convention,        ! the following will print the transposed matrix (col, row)       ! but I' = I, so it's not important here         write (*, fmt) I(:,:)            deallocate(I)          end program identitymatrix     (the end of the code )      I am a bit confused about these two code pieces ?               write (fmt, '(A,I2,A)') '(', ms, 'F6.2)'          write (*, fmt) I(:,:)      What does `(A,I2,A)` do exactly?


title: What arguments are there in favor of weak typing?

text: This came up in a discussion with a friend, and I found myself hard-pressed to think up an any good arguments. What benefits do weak typing confer?


title: The distributed office, is it viable?

text: I've played with the thought of how I would construct my dream company and how one could make it highly attractive to great programmers. If one could employ a few "superstar" programmers instead of many "good" ones. One thing I personally would enjoy is the freedom to work from whenever I wanted. So I could travel around different cities if I felt like it and work remotely, or I could simply sit at home when there was crunch mode. In my experience however you do want some kind of office with peers where you can discuss things and have company "culture" So say you wanted to hire a bunch of top talent programmers, possibly from different countries and cities. How would one set it up to compete with campuses? Having a completely office-less company seems a bit sub-optimal, you probably want some office space where people can meet and chose to work from. I guess what one could do is have small offices in different countries and let people work from the ones they chose. Programmer's could take off for "crunch- modes" when warranted but also work from location when teamwork and face to face was needed Another model would be to instead of having offices of your own hire seats in offices where other programmers work. That way even if there's only one or two employees in your city you could still get some company if you felt "lonely" from working remotely. Another idea is that like one week every other month you take the whole team to the same location. Which might not be an office but could be just some interesting city or attractice resort and work together from there. People with spouses might have a problem with things like that though. You might also have a network of company apartments in different cities (for 2-3 people) , both where you have offices and also in some other locations so programmers or teams or programmers could roam around and "clump" together as they wish. If it was legal (I'm not sure how it differs from country to country) you could even swat two flies in one go and have combined office/apartments in different cities. "Hack Pad: London" "Hack Pad:Berlin" etc a) So I guess my questions are, would a setup like this be viable? How could one improve the concept? b) Would you find a company which gives you this kind of freedom attractive or would you prefer one with a big office you go into every day? So basically, what would make a "superstar" programmer chose working with a company setup like this instead at the google, facebook or microsoft campus where you get the fun and company of lots of talented individuals.


title: Code ownership with multiple Scrum teams

text: If two Scrum teams use the same software component, who is responsible for providing a clear architectural vision of that component and maintain/develop this vision as the code base evolves? In Scrum you are supposed to have a collective code ownership, so how to make sure that development done by Team A doesn't interfere with development done by Team B?


title: AngularJS: directives and controllers: resolve, loading, reloading

text: I have a philosophy question about AngularJS and directives but correct implementation of the next problem solves it. So,   1. I need an AngularJS directive,   2. It loads some data via _several_ (not one!) `$http` requests,   3. It shows it,   4. It updates data (and re-shows it) every second,   5. The view has to be unchanged while data is loading/reloading. How should I do it in a correct way? And what about if I need a controller but not directive? (Difference is that controllers have `resolve` options but directives don't.) P.S.: I need a concrete scheme or a code! I know which components (`$http`, `$q`, etc.) I have to use. I don't know how to do it in a **right way**!


title: How to best implement K-nearest neighbours in C# for large number of dimensions?

text: I'm implementing the K-nearest neighbours classification algorithm in C# for a training and testing set of about 20,000 samples and 25 dimensions. There are only two classes, represented by '0' and '1' in my implementation. For now, I have the following simple implementation :               // testSamples and trainSamples consists of about 20k vectors each with 25 dimensions     // trainClasses contains 0 or 1 signifying the corresponding class for each sample in trainSamples     static int[] TestKnnCase(IList<double[]> trainSamples, IList<double[]> testSamples, IList<int[]> trainClasses, int K)     {         Console.WriteLine("Performing KNN with K = "+K);              var testResults = new int[testSamples.Count()];               var testNumber = testSamples.Count();         var trainNumber = trainSamples.Count();         // Declaring these here so that I don't have to 'new' them over and over again in the main loop,          // just to save some overhead         var distances = new double[trainNumber][];          for (var i = 0; i < trainNumber; i++)         {            distances[i] = new double[2]; // Will store both distance and index in here         }              // Performing KNN ...         for (var tst = 0; tst < testNumber; tst++)         {             // For every test sample, calculate distance from every training sample             Parallel.For(0, trainNumber, trn =>             {                 var dist = GetDistance(testSamples[tst], trainSamples[trn]);                 // Storing distance as well as index                  distances[trn][0] = dist;                 distances[trn][1] = trn;             });                  // Sort distances and take top K (?What happens in case of multiple points at the same distance?)             var votingDistances = distances.AsParallel().OrderBy(t => t[0]).Take(K);                  // Do a 'majority vote' to classify test sample             var yea = 0.0;             var nay = 0.0;                  foreach (var voter in votingDistances)             {                 if (trainClasses[(int)voter[1]] == 1)                      yea++;                 else                    nay++;             }             if (yea > nay)                 testResults[tst] = 1;             else                 testResults[tst] = 0;              }              return testResults;     }          // Calculates and returns square of Euclidean distance between two vectors     static double GetDistance(IList<double> sample1, IList<double> sample2)     {         var distance = 0.0;         // assume sample1 and sample2 are valid i.e. same length               for (var i = 0; i < sample1.Count; i++)         {                var temp = sample1[i] - sample2[i];             distance += temp * temp;         }         return distance;     }      This takes quite a bit of time to execute. On my system it takes about 80 seconds to complete. How can I optimize this, while ensuring that it would also scale to larger number of data samples? As you can see, I've tried using PLINQ and parallel for loops, which did help (without these, it was taking about 120 seconds). What else can I do? I've read about KD-trees being efficient for KNN in general, but every source I read stated that they're not efficient for higher dimensions. I also found this stackoverflow discussion about this, but it seems like this is 3 years old, and I was hoping that someone would know about better solutions to this problem by now. I've looked at machine learning libraries in C#, but for various reasons I don't want to call R or C code from my C# program, and some other libraries I saw were no more efficient than the code I've written. Now I'm just trying to figure out how I could write the most optimized code for this myself. I cannot reduce the number of dimensions using PCA or something. For this particular model, 25 dimensions are required.


title: Meet the deadline or less bugs?

text: In an ideal world it is preferrable to meet the deadline with less bugs. But from your experience which is more preferrable/acceptable:   1. Meet the deadline but has a number of bugs because developer rush into things   2. Less bugs but not quite meet the deadline because the developer is very rigorous in writing the code


title: Slight extension for SQL prepared statements syntax. Need advice

text: In my database abstraction library I am extending SQL prepared statements syntax to hint a parser with expected literal type. I take it as a very essential improvement, my reasoning you can read here. If you want to question the idea itself, please let me know in the comments - I'd like to start another question instead of mixing it here. The advice I want is on the syntax. I am quite ignorant of all the languages and dialects beside php and mysql, and may be there already a general purpose solution I am unaware of. If not - then I want to know your personal opinion or suggestion. At the moment, only positional placeholders supported. Yet I was asked many times to add support for the named ones. However, I cannot decide which syntax to choose for that. At the moment I mark a conventional question mark with single letter, i.e. `?s` \- string, `?i` \- int, `?n` \- name (identifier) and so forth. Yet for the named placeholder (`:name` style) the only sane option to me is               i:name      or, if I decide to add more verbose modifiers, even               int:name      so, the query would look like               SELECT * FROM ident:table WHERE id IN (int:id)      The question is: do you see any drawbacks for such a syntax? Do you have a suggestion for any other style? Do you think it's readable at all? Another question is on repeating things. At the moment I have two placeholders for the arrays - `?a` for the comma separated string list and `?u` for the `?n=?s` pairs. It bugs me a long time already, that such a syntax is superfluous, yet insufficient. What if I need a set of comma-separated identifiers? Or even a complex statement like whole VALUES clause? With some sort of repetition operator I can make SQL query building dramatically better. Here are examples of what I am thinking of:               SELECT * FROM table WHERE id IN([?i])     SELECT [?n] FROM table     INSERT INTO table VALUES [(?i,?s,?s,?s)]     UPDATE table SET [?n=?s]      As you can see, I use square brackets to designate a repetition. However, I am still not sure if I should use them. First objection is that they will collide with SQL server identifier syntax. Next is rather philosophical one - it is another syntax element and I want to introduce as less changes to the syntax as possible. Also, this syntax will require much more complicated parsing logic, which I am trying to avoid too. So - another option is just to extend the set of types, either with distinct placeholders like `?k` for the list of numbers, `?o` for the list of identifiers, of with adding a single=letter modifier to the existing type like `?as` (or `?astr` or `astr:name`) is an array of strings, `?an` and the like. There is another option - to detect repetitions automatically. If we have a scalar - format it as a single value. If it's array coming - format as a comma-separated list. However, many people find this approach unacceptable, as it can lead to unpredictable results and erroneous (however still safe) query. I am still in doubts if I may choose this way.


title: Accessing a private array when I have an extension method

text: I'm trying to make a number of data classes for my C#/XNA game, which would essentially be a wrapper around `T[,]`:               public interface IGrid<T>         where T : struct     {         Point Size { get; }         T this[int x, int y] { get; set; }     }      For example, I might have a Heightmap object which is essentially an `IGrid<float>`, or I might have a Level.TileData object which is an `IGrid<byte>` or `IGrid<int>`. These could be entirely separate classes with specific helper methods, etc. I also made a small extension library that operates specifically on any 2-dimensional array:               public static class Transformations     {         static T[,] Transpose(this T[,] value);         static T[,] FlipHorizontal(this T[,] value);         static T[,] FlipVertical(this T[,] value);         static T[,] RotateClockwise(this T[,] value);         static T[,] RotateCounterClockwise(this T[,] value);     }      However, when I actually implement `IGrid<T>`, I encounter a small design issue. Because the backing array would be private/protected, any client code that actually uses `IGrid<T>` would be unable to use my extension library. According to CA1819 and Eric's blog, publicly exposing an array (even via properties!) is a bad idea, as it would be fully mutable. The suggested workaround is to clone the array, then expose it as an immutable type (which means I still don't have an array to use the library on). Am I overthinking things, or is there an elegant solution here? I really like the idea of using indexers to read/write data on the object, but in some situations I _might_ want to work with the entire array at once.


title: ACM membership vs ACM online free articles (Association of Computer Machinery)

text: I am a software developer. I consider joining ACM. However, I find that there are free articles on ACM Ditial Library, e.g. http://portal.acm.org/citation.cfm?doid=1953122.1953141 In addition to that, there are free RSS feeds I can subscribe to, e.g. http://cacm.acm.org/blogs/blog-cacm/109710-new-sql-an-alternative-to-nosql- and-old-sql-for-new-oltp-apps/fulltext The memberhsip type I consider joining is ACM Professional Membership PLUS ACM Digital Library $198 USD https://campus.acm.org/public/qj/ProfQJ/qjprof_control.cfm?form_type=Professional&promo=QJPUB **What are things available for ACM paid members ONLY**?, below is the list I know **1)** free safari, 24x7 ebook library Please contribute your opinions? Should I join ACM or use its free online document? My interest is in advanced topics in web app, database app.


title: Software/Tool used in some presentations (TechEd, PluralSight, etc)

text: Does anybody know what application is used in some presentations in TechEd, PluralSight, etc? It looks like the following: ![enter image description here](http://i.stack.imgur.com/qGtHe.jpg) but it also allows drawing arrows to emphasize on something, rectangles, etc?


title: Finding out which version of a file a line was added/changed

text: Is it generally possible while using source code management to figure out in what version of a file a specific line was added? If so, what SCM systems support this?


title: Better way to read XML

text: We are storing config files as XML. With that being said, when reading the XML file, is it better to use LINQ to query the XML file or would using the `XMLDocument` and/or `XMLNode` classes better to use? To me, it would seem that in this instance, LINQ is not necessary. But then I tried to think of any value of one over the other down the road if the structure of the XML were to change. So my question is, is one method of reading XML better or more accepted way of doing it over the other?


title: What are arguments against using articles in method name?

text: I want to use articles in method names sometimes. Like some service method 'getStudentsOfATeacher()'. What are arguments against that?


title: How can one guarantee unique identifiers, even in the case of system collapse and restoration from backup

text: In the manufacturing of a device each one has to get a unique identifier. So far so good, one can have a file containing the last used ID on a shared drive, or a network-based service managing and assigning IDs so that the uploading of the ID into the device will not be limited to a single workstation. However, in the case of a total system crash and restoration from backup, one can have a few devices with the same ID, if some devices were manufactured after the backup was made. One could have each workstation save the biggest used ID, and check whether it's not larger than the one they got from the network, but it might happen that the workstation with the last produced device is not turned on after the crash. One might require workers to write down the last used ID after their shifts, but this doesn't sound to be fool- proof either. Is there a best practice besides having multiple services managing the IDs, with at least one of them off-site? The IDs are large enough (32 bits) compared to the number of devices to be produced to allow for small gaps, but not large enough to go the true RNG way. This way, one can increase the largest ID by a number significantly larger than the amount being produced per day, but how can one keep this "company practice" enforced for possibly decades?


title: Domain driven design and WCF services architecture

text: I am trying to figure out how to architecture my project in the DDD paradigm (a complete beginner in DDD) and stumbled upon a problem about the implementation of the web services... These are some options that I see: **Fat client, Fat server (option 1):**   * Server:      * Repository layer: talks to database and can return domain objects.     * Domain layer: contains domain objects with business logic and validations.     * Service layer: acts like a façade to the domain layer.     * WCF layer: exposes the service layer to web methods. It maps domain objects to appropriate DTO objects.   * Client:      * Infrastructure layer: talks to server through WCF services. It maps DTO objects back to domain objects.     * Domain layer: contains domain objects with business logic and validations.     * Service layer: acts like a façade to the domain layer.     * UI layer (WinForms): uses service layer to communicate with domain objects. Good: because the domain layer is both on client and on server, the validations happens on both (good for clients - reduces number of calls to the server, good for server - because of 'never trust the user data'). Bad: validation happens twice, a lot of mapping needed (for example a simple query to the database: domain (returned by repository) -> DTO (needed for WCF) -> domain (needed by domain layer on client) -> DTO (for WinForms). Any change in the domain should be deployed to server and client at the same time. Complicated? **Fat client, thin server (option 2):**   * Server:     * Repository: talks to database and returns DTO objects.     * WCF layer: exposes the database calls to web methods.   * Client: Exactly the same as in option 1. Good: on the client I can treat WCF services as a regular repository which returns DTO objects. Simpler as option nr. 1. Bad: is it OK that the repository works on DTO-s instead of domain objects? Also - server doesn't perform any validation so it has to trust clients about the data. **Thin client, fat server (option 3):**   * Server: Exactly the same as in option 1.   * Client:     * Infrastructure layer: talks to server through WCF services.     * UI layer (WinForms): uses presenters to communicate with the server via WCF calls in infrastructure layer. Good: all domain logic is on the server. Bad: the client doesn't contain any validation, so it can make a lot of unnecessary calls to the server. * * * I am leaning toward my first option, but it looks like I am overcomplicating things... Any advice or other options?


Why does Python use hash table to implement dict, but not Red-Black Tree? What is the key? Performance?


title: Asking my employer if I can open source a project I'm working on for the company

text: I'm an intern working for a company for the summer. I've been warmly received and I manage to impress my manager a lot (I guess I'm more experienced than the other people he interviewed). Recently I've been developing a kiosk type application which will generate a simple GUI menu from a text config file a 4 year old could write. I love the project and it has become my baby. However, in the corporate world, whatever you develop for your employer...becomes theirs (or so I've heard). I would really love to be able to keep on working on the project after the summer and I would also want to open source it. How would I go about asking for this? The code doesn't have any company secrets and most of the people here advocate open sourced software.


title: Should I throw guard exceptions that will be thrown by internal methods anyway?

text: I have some fairly simple code (C#):                   /// <summary>         /// Truncates a string to a maximum length.          /// </summary>         /// <param name="value">     The string to truncate. </param>         /// <param name="maxLength"> The maximum length of the string. </param>         /// <returns>         /// The original string if its length is less than or equal to max length, else a truncated         /// string of length maxLength.         /// </returns>         public static string Truncate(string value, int maxLength)         {             if(maxLength <= 0) throw new ArgumentOutOfRangeException("maxLength");                  if (string.IsNullOrEmpty(value)) return value;                  return value.Length <= maxLength ? value : value.Substring(0, maxLength);         }      It's clear that if `maxLength` is less than 0, I can't use it as a string length, and so I am currently using a guard statement to prevent invalid `maxLength` values. My question is: is it good or bad practice to use this guard statement, when `value.Substring` will throw the same exception anyway? Is it just wasted code?


title: Is there a canonical book on general abstractions and modeling?

text: I've been trying to understand the fundamentals of general abstractions and modeling: there are quite a lot of books when you search for abstractions, but most of those seem to be about learning object-oriented programming in a given language. Is there a book out there that's the de-facto standard for describing best practices, design methodologies, and other helpful information about general abstractions and modeling? What about that book makes it special?


title: Database is performing slow, even all the tables are having normalization

text: One of the interviewers asked me this question: > Tables are created with appropriate normalization rules, However the > database is performing slow. [Ie.: The select, insert statements are taking > time to do his operation.] What are areas we need to look to improve the > database performance. I understood this will be a vague question. Please provide some suggestions. And also what are the areas we need to look in Query Execution plan?


title: experience: coding on netbooks

text: HI, i want to buy a netbook for doing some stuff in the train. Can someone report how it is to code simple stuff on a netbook? 10/12". I wanted to buy a very cheap one. like 1gb ram 1,6ghz blabla. and run linux on it with apache. i will code with JS/PHP. and as IDE i'll be using notepad++. so nothing big like eclispe or something else. maybe later on eclipse for java, but that doesn't really matter. so first, would this setup work fine on such a netbook and, is it okay for coding? I don't style any homepages on the netbook, I just want to code. would be nice if someone can share his experience in that. thanks :)


title: Difference between trigger, handler and callback

text: It's current to see the terms `callback`, `trigger` and `handler` in some API documentations. It is just synonymous or each term correspond to a specific concept? I used to think that this terms are just synonymous, but I must be wrong ... Thanks !


title: Should I encrypt files saved by my program

text: I'm trying to decide on what format I should save data in, and hopefully this question will help me come to a decision. The program I'm writing uses 'databases' in which `word=meaning` (not a dictionary, that was just an example). I don't really want people to be able to manually edit these 'databases' without my program easily, but at the same time I'm looking for interoperability between programming langauges (namely C#, PHP, Java and Objective C) At the minute, the main contenders are SQLite, XML and SQL Server CE (although PHP doesn't have support for Server CE, but that doesn't have to be too much of an issue). Really, my question is, should I use encryption because I have read that it is often just as easy to decrypt? And if you support encryption, how do you deal with the encryption key - do I just generate a long, complicated string? Or is binary enough? Nothing in the database is too critical, however I would like to have an `isEditable` 'key' so my program knows whether to allow edits or not. And I'd also like to use my own file extension.


title: What is the typical Pythonic view on re-using python modules outside of their initial intent?

text: **Short Question**   Does it fly in the face of the Pythonic view to reuse / repurpose python modules for projects out side of their intent? **Background**   Over the past several months I have been working on a project that uses the Python unittest module to run manual system tests. Please see questions 1 2 and 3 for greater detail on my project and some of the hurdles I have had to overcome. I would like to know, in general, if it acceptable to reuse modules for other purposes? Most of the comments I have received have been along the lines of "this is not a unittest", or "you should write your own testrunner". My push back on that, is if a module does 90% of what you need it to do with litte to no modification and contains additional (knowingly unneeded) functionality why on earth would you write your own module?


title: What programming magazines pay for articles from guest writers?

text: Do any programming magazines accept contributions and pay the authors for them? If so, what magazines are these, or how can I go about finding them?


title: Do I have to write a lot of boilerplate code if I keep working using Java?

text: I'm working for a company writing ERP applications. My problem is that I have to write tons of boilerplate code. I came up with ideas to automatize/prevent the drudgery but only some of them were accepted. I have been told by the lead developer that my ideas tend to be go far afield and I should write code everyone can understand. I had a discussion about this lately and it seems to me that this kind of code ramp is within java's philosophy. I have to write lots of code to achiveve simple things not because it is necessary but because this is the way most of the people at the company think. Is this universally applicable to most of the companies out there using java or this is just my company's view? Do I have to get used to the drudgery if I keep working for java-based firms?


title: How do you avoid looping mistakes? Mistakes that are not detected by systems

text: I had this crazy initialisation -- `documentList = new ArrayList<Map<String,Integer>>();` which I intended to store a new map everytime in a loop but unfortunately put itself inside the loop. And you know the havoc. How do you detect such mistakes? I might be looking for suggestions on 'recommended debugging techniques' but am also looking for more expert advice


title: Why isn't there a culture of paying for frameworks?

text: One of the side effects of the recent trend of "Lean" startups, and the app store era, is that consumers are more acclimatised to paying small prices for small games / products. Eg.:   * Online SAAS that charges ~$5 / month (the basecamp style of product)   * Games which are short, fun, and cheap ($0.99 from the app store This market has been defined by "doing one thing well, and charging people for it." DHH of Rails / 37 Signals fame argues that if your website isn't going to make money, don't bother making it. Why doesn't the same rule apply to frameworks? There are lots of software framework projects out there - many which are mature and feature-rich, which offer developers significant value, yet there doesn't seem to be a market or culture of paying for these. It seems that the projects which do charge money are often things like UI component toolsets, and are often marginalized in favour of free alternatives. Why is this? Surely programmers / businesses see the value in contributing back to projects such as Ruby, Rails, Hibernate, Spring, Ant, Groovy, Gradle, (the list goes on). I'm not suggesting that these frameworks should start charging for anyone who wants to use them, but that there must be a meaningful business model that would allow the developers to earn money from the time they invest developing the framework. Any thoughts as to why this model hasn't emerged / succeeded? **Edit** To be clear: This isn't a post about down playing the importance of free, open source software. This is a post about asking why a culture of paying for frameworks doesn't exist.


title: What sort of Design Patterns do you use in Android Development?

text: I have been developing on Android for a couple months now, and building upon one in house program I found the scalability to be lacking. I have that gut feeling that if I applied some OO Design Patterns I would get an overall better program in speed, scalability, and readability. Do any of you SOdians have some ways you applied a/many design pattern(s) that just seem to fit extremely well with the way Android works?


title: How to cross-reference many character encodings with ASCII OR UTFx?

text: I'm working with a binary structure, the goal of which is to index the significance of specific bits for any character encoding so that we may trigger events while doing specific checks against the profile. Each character encoding scheme has an associated system record. This record's leading value will be a C++ `unsigned long long` binary value and signifies the length, in bits, of encoded characters. Following the length are three values, each is a bit field of that length.   * offset_mask - defines the occurrence of non-printable characters within the min,max of print_mask   * range_mask - defines the occurrence of the most popular 50% of printable characters   * print_mask - defines the occurrence value of printable characters The structure of profiles has changed from the op of this question. Most likely I will try to factorize or compress these values in the long-term instead of starting out with ranges after reading more. I have to write some of the core functionality for these main reasons.   * It has to fit into a particular event architecture we are using,    * Better understanding of character encoding. I'm about to need it.   * Integrating into non-linear design is excluding many libraries without special hooks. I'm unsure if there is a standard, cross-encoding mechanism for communicating such data already. I'm just starting to look into how chardet might do profiling as suggested by @amon. The Unicode BOM would be easily enough (for my current project) if all encodings were Unicode. Of course ideally, one would like to support all encodings, but I'm not asking about implementation - only the general case. How can these profiles be efficiently populated, to produce a set of bitmasks which we can use to match strings with common characters in multiple languages? If you have any editing suggestions please feel free, I am a lightweight when it comes to localization, which is why I'm trying to reach out to the more experienced. Any caveats you may be able to help with will be appreciated.


title: Hosting long-running worker inside IIS

text: Is it possible to host a long-running worker inside ASP.NET application? The worker (for it's a windows service) is reading from a queue sending messages to a WCF service. Would it be possible to run this "light long-running worker" inside an ASP.NET application? I read about setting pool start mode to "always running" and then using an AppStart class, which starts the worker. I would like to get rid of the windows service (deployments and debugging problems) and embed this work inside IIS. Any suggestion?


title: Is there any difference between return n and exit(n) in C?

text: Is there any difference between `return n` (in the `main` function) and `exit(n)` in C? Is it defined by C or POSIX standards or it depends on OS or compiler?


title: Logging in JSON Effect on Performance

text: I see more and more articles about logging in JSON. You can also find one on NodeJS blog. Why does everyone like it so much? I can only see more operations getting involved:   * A couple new objects being created.   * Stringifying objects, which either involves calculating string length or multiple string allocations.   * GCing all the crap that was created. Is there any test on performance when using JSON logging and regular string logging? Do people use JSON (for logging) in enterprise projects?


title: How to mark unit/integration tests when they do not apply for the current test configuration - Inconclusive or Passed?

text: In my test environment we are running the same set of integration (and sometimes unit) tests against different systems that have different capabilities.   Some of the tests cannot be executed against some of the systems because a feature that enables this scenario is missing or we need completely different behavior.   Currently we are using MSTest and have tests with this pattern:               [TestMethod]     public void TestMethod1()     {         if(targetSystem.SupportsFeatureX == false)             Assert.Inconclusive("Not supported by underlying system");         // the code for the actual test follows     }      Should we mark the test as `Inconclusive` or just let it `Pass` if the feature check is not satisfied?   Please note that `targetSystem` is a third party system that we have no control over so we just live with features that are present.


title: Sharing classes or interfaces between different projects

text: I was looking for some answers in SO or here, but without any results, that's why I would ask you. Let's assume I have a two different projects - for example server part and client part of an app. I'm developing my own part, while my friend is making the second one. But both of us should use some common interfaces like `User` or `AccountInfo` or `ChangableAccount`... whatever in order to ensure a compatibility. For example if a clients send a User data to server, then the server should operate on the same class. The same with interfaces etc. Moreover, if there are any changes in a common interface, both projects should adjust its code to the new situation. The only solution I can see now is, to create a one extra project in which all common things are defined. We, me and my friend, should add this project as a dependency to a main project (client or server). Shared project can be managed by some version control system, so we have always the most up-to-date state. What other solution would you suggest? How such problems are solved in professional apps?


title: Freelancing and GPL?

text: Is it possible for a freelance programmer to use Open Source products under GNU Public License and make money given that he cannot stop his customers from freely distributing his products?


title: Undefined behaviours in C

text: Recently I came across a number of undefined features in C, one of them being the following: http://stackoverflow.com/questions/8698048/behaviour-of-non-const-int-pointer- on-a-const-int Could someone tell me what should I answer when such a question is asked during online exams ( and **_None of These_** / **_Undefined_** option is not available ) ? Also, could you point me to a document specifying the most commonly encountered undefined behaviours in C ? Thanks.


title: Unit testing methods with indeterminate output

text: I have a class that is meant to generate a random password of a length that's also random, but limited to be between a defined min and max length. I'm constructing unit tests, and ran into an interesting little snag with this class. The whole idea behind a unit test is that it should be repeatable. If you run the test a hundred times, it should give the same results a hundred times. If you're depending on some resource that may or may not be there or may or may not be in the initial state you expect then you're meant to mock the resource in question to ensure that your test really is always repeatable. But what about in cases where the SUT is supposed to generate indeterminate output? If I fix the min and max length to the same value then I can easily check that the generated password is of the expected length. But if I specify a range of acceptable lengths (say 15 - 20 chars), then you now have the problem that you could run the test a hundred times and get 100 passes but on the 101st run you might get a 9 character string back. In the case of the password class, which is fairly simple at its core, it shouldn't prove a huge problem. But it got me thinking about the general case. What is the strategy that's usually accepted as the best one to take when dealing with SUTs that are generating indeterminate output by design?


title: How does a script download a Youtube Video?

text: Knowing that Youtube uses Adobe Flash which is compiled server side to deliver its video content, I am wondering how its possible to find a video's file name & location on the server? This is a general question about the security of Adobe Flash and swf files on a server. If google can't protect the video files from offsite download using Flash, why is it so widely used?


title: C# Classes instance members vs. enum

text: What is the difference between private variables in a clsClass type and using enumeration enum to instantiate the variable. This question arose when I was looking at some C# Class code for serial ports. example: private int SomeClassMember; and private enum TransmissionType{TEXT,HEX} ? Where do the enum statements appear in a Class definition?


title: Do-It-Yourself project suggestions to sharpen programming skills or learn a new language

text: Since the best way to learn is to work on projects, what are some good software to try making yourself with a purpose of sharpening certain programming skills or learning a new language?


title: Can one become good programmer by self learning or a mentor is needed?

text: I am a self taught programmer. I have only 1+ year of experience in development. Majority of my knowledge is gained by reading books and from little bit from the engineering degree. Currently I have no go to guy or person to discuss ideas / solution. I am their go to guy and they are not interested in the idea of the solution they just want it to work. So can people who are already there have they done it on there on i.e using internet and books or they have been cultured into the role?


title: Writing proprietary and possibly closed source software while avoiding license infractions

text: I am starting a software project that I want to have the option to keep it proprietary. However, since I generally use a Linux environment, I want to know: How do people write proprietary software in Linux and not violate the GPL/LGPL/etc licenses that seem to restrict uses of libraries needed to build the project? Also, does using an unmodified LGPL library in my code require releasing it as open-source (I understand that open-source and proprietary are different beasts)? And I know I'm going to be branded a heathen for asking, but can I use unmodified open-source libraries in my project but still keep the code that is mine closed-source?


title: What to do if the interviewer does not give you enough time to answer?

text: I had an interview with a well known company. After completing the first round of interview, I was confident that I would be short-listed for the second round. But little did I know that my second round would be a disaster. The second round started and the interviewer asked me to tell him about my profile. Once this was done he told me that he was going to get a pen and a paper (unfortunately I only had a pen) and he returned only after 15 minutes. Once he came back he started shooting questions at me without giving me a chance to think about the question and answer. I really mean it, 5 seconds after the first question he would shoot me another question, irrespective of whether I was answering the first question or not. I also told him politely in between to give me a chance to answer, but no luck. After the interview was over, I felt like, he took a 15 minute break to memorise these questions and was emitting it in front of me before he forgot and ran out of questions. What can be done in such a case?


title: Is there a good way to team develop using different MySQL Instances?

text: This may be a noob question but a colleague and I are working on a project. Some background about our situation is:   * We control versions using a centralized git server inside our office.   * We code in PHP, so we try our code offline in a local apache instance.   * We use local MySQL instances at work. Our client is a bit of a demanding person, and has changed the requirements more than twice. The main problem is that if we need to change something in the database, we have to make clean dumps on other servers (the other teammate's computer, the central server..., and the client's server of course) to make other instances work, too. **My question is, is there a way to synchronize our local databases** (I don't care about the client's one at this moment) **with git or another utility to make my colleague, the git server and my database be up to date when we push changes?** If that is not possible, do you know of any better way to work with MySQL databases stored locally? Thanks in advance. PS: Using only one central database is not a valid solution for us, as we test different features and have different elements stored there.


title: Why SQL is not so widespread in large desktop applications?

text: As a software developer, I've worked on projects ranging from tiny home-made apps to medium-size enterprise applications. **In nearly every project I used a database** or regretted choosing not to use it from the beginning. Now, I am wondering a few things about the databases and their usage in general applications:   * Why Windows itself doesn't use any "central" SQL database? For example:      * Errors Reporting data is stored in a bunch of files,     * Windows Update stores everything in flat files,     * Icons cache is stored in a very strange single file which doesn't seem to be accessed through SQL, etc.   * Why so many large applications avoid using databases? For example, wouldn't Microsoft Outlook gain by using a real database instead of reinventing the wheel by having its own format for .pst files and storing some data in registry? If database adds an additional layer of an overall complexity and a tiny performance loss, it is a price of a huge advantage of making the code simpler in most circumstances, especially when it comes to the storage of small organized chunks of data instead of large binary streams. So why so few products are actually using databases? Probably the only application I know which actually uses Sqlite database is Firefox, and maybe Microsoft Exchange (but the last one is not a desktop application)? Also, wouldn't _a set_ of applications, like Microsoft Office or Microsoft Expression, benefit from having an _unified SQL database_ , making it easier to deploy the applications, to update/upgrade the data, to share data between those applications, to make backups, etc.?


title: Sub routing in a SPA site

text: I have a SPA site that I'm working on, I have a requirement that you can have subroutes for a page view model. Im currently using this 'pattern' for the site               MyApp.FooViewModel = MyApp.define({         meta: {             query: MyApp.Core.Contracts.Queries.FooQuery,             title: "Foo"         },         init: function (queryResult) {              },         prototype: {                        }     });      In the master view model I have a route table               this.navigation(new MyApp.RoutesViewModel({         Home: {             model: MyApp.HomeViewModel,             route: String.empty         },         Foo: {             model: MyApp.FooViewModel         }     }));      The meta object defines which query should populate the top level view model when its invoked through sammyjs, this is all fine but it does not support sub routing My plan is to change the meta object so that it can (optional offcourse) look like this               meta: {         query: MyApp.Core.Contracts.Queries.FooQuery,         title: "Foo",         route: {             barId: MyApp.BarViewModel         }     }      When sammyjs detects a barId in the query string the Barmodel will be executed and populated through its own meta object. Is this a good design? **edit:** Hmm, just noticed that above design is not always enough, the parent view model might need to do some processing when the subRoute triggers, so I added a object to the definition sent into MyApp.define like               meta: {         query: MyApp.Core.Contracts.Queries.FooQuery,         title: "Foo",         route: {             barId: MyApp.BarViewModel         }     },     onRoute: {        barId: function(barViewModel) {           //act on bar route        }     }


title: github team workflow - to fork or not?

text: We're a small team of web developers currently using subversion but soon we're making a switch to github. I'm looking at different types of github workflows, and we're not sure if the whole forking concept in github for each developer is such a good idea for us. If we use forks, I understand each developer will have his own private remote & local repositories. I'm worried it will make pushing changesets hard and too complex. Also, my biggest concern is that it will force each developer to have 2 remotes: origin (which is the remote fork) and an upstream (which is used to "sync" changes from the main repository). Not sure if it's such a easy way to do things. This is similar to the workflow explained here: https://github.com/usm-data- analysis/usm-data-analysis.github.com/wiki/Git-workflow If we don't use forks, we can probably get by fine by using a central repo creating a branch for each task we're working on, and merge them into the development branch on the same repository. It means we won't be able to restrict merging of branches and might be a little messy to have many branches on the central repository. Any suggestions from teams who tried both workflow?


title: Buy vs. Build - FTP Service

text: We have a need to FTP files that are generated by our system, so we're trying to decide whether we should spend the time to build something that meets our criteria (relatively easy, .NET has FTP functionality built in, among other more advanced libs from 3rd parties). Or if we should buy something off the shelf. Our requirements are roughly:   * Must be able to trigger a file send programmatically   * Needs to retry _N_ number of times (configurable)   * Queryable status of FTP requests   * Callback on completion or fail of an FTP request I don't need to be sold on the relative simplicity of building something like that for myself. However I do want to do the due diligence of seeing what products are available ... because if something does exist that matches the requirements above, I wouldn't mind paying for it :-) Any thoughts or links would be greatly appreciated. Thanks!


title: Should I create a new database for a public website when the data already exists?

text: I am looking for advice on how to create my data schema for a public web site. Currently, we have an Intranet website where our agents create the data needed for reservations. The data includes tables like Establishments, products, prices per periods, and a typical Users table. This intranet is already in production. I've been tasked to create a public web site, where anonymous Joe and Jane will be able to book a reservation without calling one of our agent. The site will offer registration and will display the data available from the Intranet, albeit as read-only. The public site itself will have some data of its own. I am a bit reluctant to combine the data from the public site into the same database than our intranet, but most of the information that will be displayed on the public site will come from the pre-entered data from the intranet. Are there any best practices concerning the separation and sharing of information between a public and a private website?


title: How should we develop the project with different members with different skill level?

text: We are developing a project with three members. I am the permanent member, we hired a contractor from a company to be a team lead and one very junior coder. Now the contractor is doing the server side coding with classes and modules while the junior member and I are doing front client. The problem we face is that the junior member and I are finding it very hard to understand the contractor's code. Our skills are not at his level and he is using all sorts of advanced function and write very concise code with very little documentation. When we ask for help, he gets angry and says that we don't know that. I have raised this issue, but it comes out every now and then. I can understand only 50% of his code and the junior understands only 10% of it. What should be done int his scenario? We can't force him because we need him, but its difficult for us to proceed. What should we do? And also every time we do our part of coding he can always pick errors and tell how to do it better. It is good, but it also means that do we have to check every line of code with him. I was confused that if we have genius coder in team of 5 then that genius will always write better code. So does it mean that   1. he needs to check code for every junior member and change it   2. he leave some loopholes and ignore them because the senior member will always have better way to do the job?


title: In general, is it ethical to make a copy of work source code and take it home as reference?

text: Is it ethical to make a copy of my work's source code, for the sole purpose of my own reference? By reference, I mean as reference where I can refer to it about how I (and my teammates) implemented various design patterns, architecture, etc. It does not contain any trade secret, product, secret algorithm or anything like that. Note that I wrote many parts of the source code, and also the added value from me studying the code will also indirectly benefit the company I am working on.


title: Computer Graphics: Principles and Practice in C ( in Python? )

text: I am attending a Computer graphics course after the summer. I have read lots of good things about the book "Computer Graphics: Principles and Practice in C" for people who are willing to put in some work. My school does not focus on C/C++ until next year, so I have decided to learn Python this summer and get good at Python this following year. How language dependent is this book? Can I work through it in Python?


title: Software Patents: can I license the use of an existing patent?

text: I know the software patent is a hot topic and is very frustrating. But as I live in the US I don't think I have any choice but to deal with it. What I'm wondering is if there are actually companies or a site where I can look up what patents might apply to my idea. Then, be able to license the appropriate use of the idea even if the patent is vague and ambiguous. Then, if a troll comes after me I can argue that I'm protected under the use of patent#XYX.


title: How to manage and improve web application with 50 customers?

text: First of all, sorry for my English. We've developed a Web Application using ASP.NET and Sql Server. We've started selling it and of course are still continually improving and developing it. The question is, how do we go about updating each client's version of the site? We have, maybe, 50 customers. 50 different folders and 50 different db's sounds like a bad idea. Is there any known method for solving this kind of scenario? `For Explain:` We are developing a Crm, for 50 companies. They will have 10 users maybe. It makes 500 users and their customers and products.


title: Do you think F# and Python might rule the future market?

text: I am seeing that Microsoft is concentrating too much on F#. What type of language it is going to be and will it replace the C# user base? In the last few months I am noticing Ruby posts in some forums going down whereas Python forums are going up. If Microsoft had not stepped back from IronPython, do you think Python would have ruled C#?


title: How to provide value?

text: Before I became a consultant all I cared about was becoming a highly skilled programmer. Now I believe that what my clients need is not a great hacker, coder, architect... or whatever. I am more and more convinced every day that there is something of greater value. Everywhere I go I discover practices where I used to roll my eyes in despair. I saw the software industry with pink glasses and laughed or cried at them depending on my mood. I was so convinced everything could be done better. Now I believe that what my clients desperately need is finding a balance between good engineering practices and desperate project execution. Although a great design can make a project cheap to maintain thought many years, usually it is more important to produce quick fast and cheap, just to see if the project can succeed. Before that, it does not really matters that much if the design is cheap to maintain, after that, it might be too late to improve things. They need people who get involved, who do some clandestine improvements into the project without their manager approval/consent/knowledge... because they are never given time for some tasks we all know are important. Not all good things can be done, some of them must come out of freewill, and some of them must be discussed in order to educate colleagues, managers, clients and ourselves. Now my big question is. What exactly are the skills and practices aside from great coding that can provide real value to the economical success of software projects? (and not the software architecture alone)


title: Programming beginner: Options for small program interfaces?

text: I have been a Rails developer for a year now, and I really want to start diving in to Ruby and pure programming without using a framework. However I am having trouble conceptualizing little programs I can build on my own. I guess it's because I'm so used to having a GUI (the web browser) to interact with the classes that I write that I don't really get how I would interact with classes without clicking, going to different pages, etc. In terms of pure Ruby (without Rails), I've only built a blackjack game you play through the console through typing Y/N for hitting and staying. I would like to know what types of interfaces you guys use for your small programs? Are they all just ran once from your console using something like `ruby myclass.rb`? I have the motivation but I don't know what I would do after writing a few classes. All I do is have a separate file that requires all my other classes, instantiate my classes like so:               myclass = MyClass.new     myclass.part = ClassPart.new(1,2,3)     myclass.do_something # puts "value of instance_variable = #{@instance_variable}"      And then what? The program finishes. It's not interactive. It doesn't do much. I don't see myself building anything cool/powerful like that. Can anyone enlighten me?


title: How important is it to learn makefiles?

text: I work in c++ mostly as a hobby (I'm still in school and therefor don't have a real job). The IDEs generate the makefile for me and so I'm wondering if it's worth learning how to make them myself. By "worth learning" I mean, should I drop everything and learn how to write them before continuing to learn c++? Is learning them going to be really necessary? If so, should I learn about them (general syntax and understanding how they work etc.) or really learn how to write them?


title: Can we use `a <= x <= b` to check if `x` is between `a` and `b`?

text: How to give conditions for geographical directions based on degrees? for COMPASS API Reference... I have tried this...but not working                if((0 <= a <= 22.4) || (337.6 <= a <= 360)){                  alert("YOU ARE IN NORTH DIRECTION");             }             else if((22.5 <= a <= 44.9) || (45 <= a <= 67.4)){                 alert("NORTH-NORTHEAST");             }             else if((67.5 <= a <= 89.9) || (90 <= a <= 112.4)){                 alert("East");             }             else if((112.5 <= a <= 134.9) || (135 <= a <= 157.4)){             alert("SouthEast");             }             else if((157.5 <=a <= 179.9) || (180 <= a <= 202.4)){             alert("South");             }             else if((202.5 <= a <= 224.9) || (225 <= a <= 247.4)){             alert("SouthWest");             }             else if((247.5 <= a <= 269.9) || (270 <= a <= 292.4)){             alert("West");             }             else if((292.5 <= a <= 314.9) || (315 <= a <= 337.4)){             alert("NorthEast");             }             else if(337.5 <= a <= 360){             alert("North");             }             else{}      Is this Correct?


title: Inventory management system design problem

text: What are the conventions for item batch identifiers in inventory management systems? For example: A retail supermarket can order '`Item X`' from either 'Supplier A' or 'Supplier B'. When it completes an order for the item from either supplier, it needs to store the record of the receipt. Inventory quantity for the item is increased upon receipt of the order. However it is also required to store some record of the supplier. Thus some sort of batch identifier is required. This batch identifier will uniquely identify the item received and the supplier from whom it is received. A new batch is created each time items are received in stock (for example, after an order). Hence, for purposes of accounting / auditing, information available to identify an item after it was sold comprises of `ITEM_CODE`, `ITEM_NAME`, `BATCH_CODE`. The `BATCH_CODE` is unique and is associated with `DATE_RECEIVED`, `SUPPLIER_CODE`, `QTY_RECEIVED`. Is this a complete system specification for the above scenario or has anything significant been left out?


title: The role of monitor screen size for a software engineer / developer / programmer

text: > **Possible Duplicate:**   >  Monitor screen size and programming ease Is the screen size of a laptop/desktop is directly proportional to the productivity of a developer? How? Is it the real estate of the screen (less scrolling, multiple apps side by side, or something else). Similar Question


title: What are some patterns and anti-patterns of application logging?

text: I recently had to investigate a field issue for our large enterprise application. **I was horrified by the logs** that I had to comb through in an attempt to find the problem and at the end of the day the logs did not help at all identifying/isolating the bug. _Note: I understand not all bugs are discoverable through logs. This does not change the fact that the logs are horrible._ There are some obvious problems with our logging that we can already attempt to fix. I do not want to list those here and I cannot simply show you our log files so you can give advice on what to do. Instead, in order to assess how bad we are doing on the logging front, I would like to know:   1. **What are some guidelines** , if any, **when it comes to logging** for an application, especially large application.    2. **Are there any patterns** we should follow **or anti-patterns** we should be aware of?    3. **Is this an important thing to fix** or **can it even be fixed** or all log files are simply huge and you need supplemental scripts to analyze them?  _Side note: we use log4j._


title: See remote repository differences with a graphical tool

text: My GIT repo is stored on a remote Linux server that I'm accessing from my Windows PC through Netbeans. Once my changes are done I would like to review them quickly before committing. The server has no graphical components so I can't launch "gitk" from there. I'm not very comfortable with a text diff on the server with "git diff" command. It is not readable enough for me. msysgit is installed on my Windows PC. I would like to launch a kind of remote "gitk" command from my PC but couldn't find a way to do it. Didn't find anything on the web related to this. Any other "graphical" way to do this would be convenient. Any idea how to do this? Thanks in advance **EDIT** To clarify my workflow (since my question seems to lack clarity):   1. I work on my code with Netbeans IDE on a local copy of my remote working repository. This copy has no versioning. The synchronization is done through SFTP. Meaning, at project creation Netbeans makes a SFTP GET of the entire repo localy. Then, when I save my changes (on local copy) Netbeans automatically makes a SFTP PUT to the remote repo through SFTP to keep in sync.   2. The working repository on the web server (Linux based) has git versioning. Hence keeping track of the same changes that I made on the Windows copy.   3. For simplicity reasons (I'm working alone on this project so far) I don't want to clone the working repo or create a different branch than master. Hence I'm working on this unique repository and directly with the master branch.   4. Once a development is done and tested ( **my changes are not yet staged for commit** ) I want to have a last look at them **before committing**. To achieve this I would like to use a graphical tool. I have msysgit installed on the windows PC but I didn't find a way to load a remote repository to my local gitk through SSH (I don't think it is possible). Finaly: I'm looking for a way to do this with gitk or any other tool. I didn't find one so far. git-cola for instance doesn't propose anything but loading local repos. I found a solution proposed here: http://stackoverflow.com/questions/6810820/git-gui-when-on-a-remote-server But I'm wondering if a simpler solution exists. **EDIT2** The idea of this question was not to start a debate on which tool is better for my concern. It was: how to do it the best way WHATEVER the tool is. Anyway, here is the workflow I'm finally using for those interested:   1. The working repo is on the Linux server.   2. Netbeans (or whatever the tool is) is editing a local copy of this remote working repo on windows. The "download from" and "upload to" the remote repo are made through a ssh connection. So remote repo and local repo are always synchronized. The simplest way to look at what was done since last commit on the repo is to make the windows local repo a git working repo and launch gitk from there. Only inconvenience is not to forget to commit the local repo when I commit the remote one to get same diffs between last commit and current. Hopefully it will help other persons with same concern.


title: streaming data in memory aggregation

text: We have a stream of data we're aggregating stats over and putting into a python dictionary (sent from kafka). Every X time interval, We update our database with these aggregated metrics. This process works fine, but is not completely fail-safe. What if the python process dies and we lose that time interval's data, for example?   What are recommended methods/tools/etc.. to aggregate streaming data in memory while still having a fallback if the process dies mid time interval?


I really enjoy working with C# however one of its biggest drawbacks is that it is kind of split-brained between MSFT .NET and Mono. In practice its not a big deal most of the time but it is one of those things that makes the language 'stink' a little. It would get a lot more uptake, I suspect, if one could answer " _If I compile it, will it work on every [desktop] platform?_ " with " _Yes._ ". Right now its " _Yes. But you have to compile it under Mono first. And some areas of code may need to be rewritten a little._ ". My question is " **Does the recent open sourcing of MSFT's C# compiler mean it can be made cross-platform?** ". That is to say, could C# .NET be made to work cross platform without Mono with the newly release open source components? Or is there more to this I am not seeing? Further exposition on what the future may hold for C# in light of the open sourced components is not required to answer this question however it is encouraged.


title: Applying commits into another branch without merging

text: I have two git branches with almost the same code, but some minor changes in order to support different platforms. I need to maintain these changes because I need them to run the software on different computers. So there is no master and development branch, both are equally important. Nevertheless, I need to "synchronize" the core code base of the branches. So I would like to somehow apply the commits from one branch in a sort of patch fashion to the other branch and vice versa, without merging them, in order to maintain the different setups. Is this possible with git? If yes, how can I accomplish this? Edit: can I merge only some files and leaves others out, but maintain the two branches?


title: Somewhere to put miscellaneous files

text: We want to be able to offer users of our software the facility of having a miscellaneous folder for each of their clients. All these client folders would be stored together in another folder called 'miscellaneous data' for example It would be accessible via an icon in the client record window in our software and would be a place to just drop files that aren't catered for by us. A really simple solution is just to do a Shell call to explorer.exe with the folder address. All the files would have the correct icons and look familiar and the user would be able to open them with their default programs The problem with this is that this then allows the user to use file explorer to navigate up to the 'miscellaneous data' folder and possibly do something unintentional like delete a bunch of client folders. I'd be very grateful for suggestions for a simple but more secure design


title: Is it bad practice to have FooObject and FooObjectSummary?

text: I have a service where users can upload/download/replace/delete files. These files have about a dozen attributes that are saved to a SQL Database. Periodicaly throughout their session they will have to download a summary (FileName, size0in-KB, and ID) of a subset of files. When working in the service it creates an object of these attributes (FooObject) in the DB. But, when the info is sent to the User, a summary object (FooObjectSummary) is created. FooObjectSummary has 3 attributes, FooObject has 12 or so (none of the attributes are anything but strings or primitive types). I originaliy did this so that as little extra info would be transferred across. None of this extra data in FooObject would be dangerous for the user to have, but it wouldn't be exposed to them anyways? Am I just writing extra code? Or is it good practice to only expose the user to as much info as they need and not a bit more?


title: Best method of communication between your app and your website? PHP, Web service, etc

text: I am creating an application which I would like to have communicate with my website. The app will have to get data for a particular app user from the website's database. I am unclear as to the best way to do this. I have seen one way of doing this for example is creating a login page on the app which then hits a login.php logic on my website. This is convenient because I can use one code base to handle sign in for both the website and the app. Another solution I've seen is using JSON requests to handle the communication between app and website. This is convenient because JSON objects are easy to create and parse. I would basically like to know the best/common way to have this communication occur, what are the pros and cons to having one over the other, and any other security issues to consider. For example, is there a risk of exposing sensitive user data when using one method over the other? If so how can this be prevented? How and where does encryption and user validations come into play here?


title: I'm doing hobby programming; what programming methodologies (e.g. XP, Agile...) do you recommend me to read up on?

text: Most of you would probably just call me a kid (I'm 15). I'm doing hobby programming (I started fiddling around with ActionScript 2.0 in Flash 8 when I was 11, now I do mostly C, Python and Java). As I'm 15, I won't get a job for a long period of time (I'm going to spend years in academia before that) and thus this question is _not_ about which programming methodologies you recommend me to read up on for a software engineering _job_ , but instead **which methodologies should a _hobby_ programmer read about?** What will a hobby developer learn from reading about your recommendation(s)?


title: How do I handle having so many SQL queries?

text: I have an MVC3 project that uses SQL Server. I use data from the SQL database all the time and I often find that I'm reusing/duplicating some SQL queries. I thought I'd solve this problem by creating a few static "helper" classes that just contain a bunch of static methods for retrieving common things.               GetAllUsers(database As MyEntity)     GetAllNonActivatedUsers(database As MyEntity)     GetUser(database As MyEntity, userId As Integer)      The problem is that this made things slightly worse. Now instead of having SQL queries all over my controller actions, there are large numbers of them in these helper classes. The names of these methods are becoming silly.               GetPendingUserApplicationByApplicationId(database as MyEntity,         applicationId As Integer, userId As Integer)      At this stage I'm thinking of scrapping the helper classes and going back to just random SQL queries throughout my controller actions. Where have I gone wrong and how do people manage their SQL queries? Is it ok to duplicate SQL queries?


title: Min cost concatenation alignment

text: I am doing a project on data mining. I have a very large string of size, say `n` and many small strings, `l_1,l_2..` each of size at most `m`. I want to find the sequence of small strings such that their concatenation has the minimum alignment cost (costs can include insertion, deletion and substitution) with my large string of size `n`. I can use one string more than once and it is not mandatory to use all the strings. Note that `m << n` My greedy implementation gives very bad results even for small strings. I can't find an efficient solution to this problem. Can anyone help? It looks like dynamic programming might be able to help but I'm not sure.


title: Beautiful Erlang Code

text: I'm trying to learn more about Erlang than the toy projects I've been playing with. To this end, I'm reading through Programming Erlang and some of the archives from Armstrong on Software. I would also like to read over some example (preferably production) code that showcases the sorts of things you can build with Erlang that would be disproportionately difficult in other languages. Aside from (I assume) Yaws, are there any publicly available examples of beautiful Erlang code that I could read through to gain a better understanding of the language and/or see the idiomatic uses for various language constructs? I'm specifically **not** looking for code that "gets the job done" but uses questionable practices, or examples along the lines of "here's how you write `factorial` in Erlang". In the same vein, can anyone recommend any good literature for learning this language (other than the mentioned "Programming Erlang")? For preference, something you yourself used to learn it, but if there's some community standard books for it, throw those in too.


title: How to avoid giant glue methods?

text: In my current job, I've been tasked with cleaning up old code a few times. Often the code is a labyrinth and the data behind it is even more tangled. I find myself combing out things into nice, neat, modular methods. Each method does one thing and does it well. That's when things start to go south... Invariably, I end up with a clean API and no real way to tie it all together. The solution has been to write a big ugly "glue" method (generally full of conditional statements) that eventually calls all of my "clean" methods. The glue method usually ends up being a terse version of the tangle of code/data that I was attempting to clean up. It's generally more readable, but it's still annoying. How can I avoid such methods? Is this a symptom of the tangled data or a reflection of something that I'm doing wrong?


title: What keymap do you prefer in ReSharper?

text: I am using ReSharper since version 3 and I always used InteliJ Idea/Resharper 2.x keymap schema. Recently I have learned Ilya's Visual Studio keymap. They each have advantages. **What keymap do you use/prefer with ReSharper?**


title: What parts of my computer should I upgrade first to speed up development?

text: I use Eclipse, and the two most noticeable slowdowns caused by my computer are waiting for compiling and waiting for intellisense. I already have a fast SSD drive and 3GB of ram. I'm guessing that upgrading my processor would be the next best thing to do. Would that make a significant impact? Any recommendations for what kind of processor to get? My current processor is an AMD Athlon 64 X2 Dual Core 1.91 GHz.


title: When is it appropriate to not unit test?

text: I work in a small company as a solo developer. I'm the only developer at the company in fact. I have several (relatively) large projects I've written and maintain regularly, and none of them have tests to support them. As I begin new projects I often wonder if I should try a TDD approach. It sounds like a good idea, but I honestly can never justify the extra work involved. I work hard to be forward-thinking in my design. I realize that certainly one day another developer will have to maintain my code, or at least troubleshoot it. I keep things as simple as possible and I comment and document things that would be difficult to grasp. And the fact is these projects aren't so big or complicated that a decent developer would struggle to comprehend them. A lot of the examples I've seen of tests get down to the minutiae, covering all facets of the code. Since I'm the only developer and I'm very close to the code in the entire project, it is much more efficient to follow a write-then- manually-test pattern. I also find requirements and features change frequently enough that maintaining tests would add a considerable amount of drag on a project. Time that could otherwise be spent solving the business needs. So I end up with the same conclusion each time. The return on investment is too low. I have occasionally setup a few tests to ensure I've written an algorithm correctly, like calculating the number of years someone has been at the company based on their hire date. But from a code-coverage standpoint I've covered about 1% of my code. In my situation, would you still find a way to make unit testing a regular practice, or am I justified in avoiding that overhead? **UPDATE:** A few things about my situation that I left out: My projects are all web applications. To cover all my code, I'd have to use automated UI tests, and that is an area where I still don't see a great benefit over manual testing.


title: When is unit testing inappropriate or unnecessary?

text: It seems to be generally assumed (on Stack Overflow at least) that there should always be unit tests, and they should be kept up to date. But I suspect the programmers making these assertions work on different kinds of projects from me - they work on high quality, long-lasting, shipped software where bugs are A Really Bad Thing. If that's the end of the spectrum where unit testing is most valuable, then what's the other end? Where are unit tests least valuable? In what situations would you not bother? Where would the effort of maintaining tests not be worth the cost?


title: What are the disadvantages of test-first programming?

text: It's all the rage nowadays. "Everyone" recommends it. That in and of itself makes me suspicious. What are some disadvantages you have found when doing test-first (test-driven) development? I'm looking for personal experiences from knowledgeable practitioners--I can read the hypothetical musings of a hundred wannabes elsewhere on the internet. I ask not because I am looking to hate TDD, but because it is my job to improve software development process, and the more we can learn about the problems people encounter, the better chance we have of improving the process.


title: When, Where, and How to Unit Test

text: I'm very familiar with xUnit frameworks and I try to implement unit tests on every project I start. Somewhere along the way, I realize that I'm writing the same tests over and over again, and then I run into a really difficult to test method or a test involving remote resources, and then I give up for a while. I end up coming back eagerly whenever I can to test simple things, but as soon as I run into harder things to test, I run for the hills with my tail between my legs. Let's throw in some examples.   1. Long flow of things to do in a method. (How do I test this? Do I just make sure that the code's being called by stubbing things out? How should I rewrite the code to facilitate easier testing?)               public void doSomething() {         Object1 value1 = doSomething1(this.getName());         if (value1.isError()) {             sendError(new Object1Error(value1.getError().getMessage()));             return;         }              Object2 value2 = doSomething2(value1, this.getName());         if (value2.isError()) {             sendError(new Object2Error(value2.getError().getMessage()));             return;         }              /* ad infinitum... */     }        2. Overloaded methods and constructors.              public String toJSON() {         return toJSON(true);     }          public String toJSON(boolean prettyPrint) {         /* do work */         return result;     }           /* test */     @Test public void testToJSON() { ... };          @Test public void testToJSONBoolean() { /* redundant similar test code... */ }        3. Remote resources. How do I test that my upload API is working (ie: right request method, host, request content type, payload, etc.) without actually doing an upload? These uploads go to servers outside of my control.              public void doUpload() throws IOException {         HttpClient client = new HttpClient();         PutMethod putMethod = new PutMethod(...);         putMethod.setRequestHeader(...);         putMethod.setRequestEntity(new FileInputStreamRequestEntity(...));              /* etc. */              final int responseCode = client.executeMethod(putMethod);     }        4. Testing server interactions with clients.              /* before we even get here, other interactions need to take place */     public void updateClientProfile(UserProfile profile) {         // 1. validate the input         // 2. update the user in the db         // 3. generate an email in HTML         // 4. send the email         // 5. serve out a view     }      Testing at first glance seems easy, until I get to these kind of situations. How do I keep my motivation for testing and write my code to be more testable? It seems that the more things that a method needs to do, the exponentially more difficult and frustrating unit tests are to write. Do I test simply that the code is calling the right services and methods? Do I write unit tests simply to prove to myself that my code calls the methods I told it to call, or to determine that the logic is right? Help!


title: When NOT to unit test?

text: I am hitting a stumbling block with TDD flow. We are using PHPUnit+FuelPHP and I am stuck on how to write a unit test for our image upload/cropping feature. FuelPHP is notoriously hard to unit test (see my forum post here and it's difficult (but not impossible) to mock/stub controllers that deal with the FILESYSTEM. I've decided to not write a unit test our this particular feature because I feel that it would not be worth the effort to fake binary files. I'd be writing too much testing code (and not enough application code) to get around FuelPHP. But I am bothered that we won't have 100% code coverage. So I was wondering if I was approaching TDD incorrectly (or not trying hard enough) or if this was a legitimate case of when NOT to write a unit test?


title: Are there any cases when one should not use Test Driven Development?

text: Is it recommended that TDD be always practiced in a project, or are there cases when it should be avoided? Should we all adopt TDD? Is it standard practice in major software companies?


title: Ad-hoc reporting similar to Microstrategy/Pentaho - is OLAP really the only choice (is OLAP even sufficient)?

text: So I'm getting ready to develop an API in Java that will provide all dimensions, metrics, hierarchies, etc to a user such that they can pick and choose what they want (say, e.g., dimensions of Location (a store) and Weekly, and the metric Product Sales $), provide their choices to the api, and have it spit out an object that contains the answer to their question (the object would probably be a set of cells). I don't even believe there will be much drill up/down. The data warehouse the APIwill interface with is in a standard form (FACT tables, dimensions, star schema format). My question is, is an OLAP framework such as Mondrian the only way to achieve something akin to ad-hoc reporting? I can envisage a really large Cube (or VirtualCube) that contains most of the dimensions and metrics the user could ever want, which would give the illusion of ad-hoc reporting. The problem is that there is a ton of setup to do (so much XML) to get the framework to work with the data. Further it requires specific knowledge, such as MDX, and even moreso learning the framework peculiars (Mondrian API). Finally, I am not positive it will scale much better than simply making queries against a SQL database. OLAP to me feels like very old technology. Is performance really an issue anymore? The alternative I can think of would be dynamic SQL. If the existing tables in the data warehouse conform to a naming scheme (FACT_, DIM_, etc), or if a very simple config file/ database table containing config information existed that stored which tables are fact tables, which are dimensions, and what metrics are available, then couldn't the api read from that and assembly the appropriate sql query? Would this necessarily be harder than learning MDX, Mondrian (or another OLAP framework), and creating all the cubes? In general, I feel that OLAP is at the same time too powerful (supports drill up/down, complex functions) and outdated and am reluctant to base my architecture on it. However, I am unsure if the alternative(s), such as rolling my own ad-hoc reporting framework using dynamic SQL would remove any complexity while still fulfilling requirements, both functional and non- functional (e.g., scalability; some FACT tables have many millions of rows). I also wonder about other techniques (e.g., hive). Has anyone here tried to do ad-hoc reporting? Any advice? I expect this project to take a pretty long time (3 months min, but probably longer), so I just do not want to commit to an architecture without being absolutely sure of its pros and cons. Thanks so much.


title: In C++ Good reasons for NOT using symmetrical memory management (i.e. new and delete)

text: _I try to learn C++ and programming in general. Currently I am studying open source with help of UML. Learning is my hobby and great one too._ My understanding of memory allocation in C++ is that it should be symmetrical. A class is responsible for its resources. If memory is allocated using new it should be returned using delete in the same class. It is like in a library you, the class, are responsibility for the books you have borrowed and you return them then you are done. This, in my mind, makes sense. It makes memory management more manageable so to speak. So far so good. The problem is that this is not how it works in the real world. In Qt for instance, you create QtObjects with new and then hand over the ownership of the object to Qt. In other words you create QtObjects and Qt destroys them for you. Thus unsymmetrical memory management. Obviously the people behind Qt must have a good reason for doing this. It must be beneficial in some kind of way, ### My questions is:   * What is the problem with Bjarne Stroustrups idea about a symmetrical memory management contained within a class?    * What do you gain by splitting new and delete so you create an object and destroy it in different classes like you do in Qt.    * Is it common to split new and delete and why in such case, in other projects not involving Qt? **Thanks for any help shedding light on this mystery!**


title: C vs C++ for a Java (and possibly python) Programmer

text: I am a Hobbyist Java programmer and I would like to further my programming skills by learning C or C++ and Python. I have read many C vs C++ articles but none of them contain the information I'm looking for. I would like to know if it is better to learn C or C++. In most articles I read most people recommend C++ saying that it is better because it is OO and is easier to write GUIs in or they don't recommend C saying that you will learn bad FO habits. But I can program in Java which is OO so the FO habits won't stick. As for the GUI, I think python might be better suited at handling that. I would also like to know which is better for python. i.e. which works more well with python or which runs faster with python etc. So do you recommend C and python and java or C++ and Python and Java P.S I do most of my programming on linux.


title: A developer as IT Manager: advice?

text: A week after my boss, the IT Manager of a highly automated manufacturing plant, and I had a conversation about the future plans for the Software Development Unit (me) regarding training, junior dev hiring, etc., he announced his resignation out of the blue, with a 4-day notice, and Management unexpectedly appointed me to take his place at a near-manager level, instead of offering the position to the Infrastructure Engineer (the only other employee in Plant IT). Three months into this role, I have mixed feelings about the position. Being a developer, I feel overwhelmed by the amount of non-programming related technical issues I must oversee, such as network, server and telecommunications infrastructure. Needless to say, the 4-day knowledge transfer was nothing compared to the amount of knowledge required to keep everything running. Add to this that this "manager/quasi-manager" position's responsibilities include about 60% hands-on, high level 7x24x365 application support (i.e. guess which one of the 3000+ corporate-developed applications is not working properly), which I despise to do, and the outlook is not very bright. I've never heard of a Developer being promoted to IT Manager before. Has anyone had a similar experience? Did you ever went back to development, was it difficult to go back? What did you do to ease this transition? Notes, blogs, books you recommend?


title: What's the difference between stateful and stateless?

text: The books and documentation on the MVC just heap on using the Stateful and Stateless terms. To be honest, i am just unable to grab the idea of it, what the books are talking about. They don't give an example to understand any of the either state, rather than just telling that HTTP is stateless and with ASP.NET MVC microsoft is going along with it. Am I missing some fundamental knowledge, as i can't understand what is stateful and why is stateful and same goes for stateless. A simple and short example that talks about a control like button or textbox can be simplify the understanding i suppose.


title: Developing configuration syntax - best practise/rules/methods?

text: I am currently developing a small application, which checks if provided data meets certain requirements. The requirements are actually a long list, and might be changing, so I defined a syntax which allows me to state all of the requirements briefly and in a seperate file. Now the overall requirements for the application have changed, and I need to change my configuration syntax. Which leeds me to wonder if there is methodoloy or best practise for developing such syntaxes. Currently what I do is   * I think about the requirements and come up with an initial syntax,    * start configuring the first few items and see how it works.   * If I come upon something that does not work well or not at all with the current syntax, I change the syntax, if possible in a backward compatible way. This somehow works for me, but it feels a bit like fishing in troubled water. Also I feel it does not nessessarly lead to the most concise and easy to understand/use syntax. So I was wondering what other people do, especially if there is a better approach to this.


title: Employer appeal; OOP use in mainstream; solutions that blossom with OOP

text: I'm currently in the process of what I hope to be a career change into the programming field. Despite my wide range of knowledge in the field and additional exposure to concepts in college (which in the end left a lot to be desired), I feel I might be missing out on what really matters when appealing to employers. I found this post http://stackoverflow.com/a/1991453 to be specific to my predicament. Importantly: > _I've seen a lot of terrible C++ code and it's not just from people who > don't understand the concepts. I've seen a lot of coders who know exactly > what an object is and can explain polymorphism and all those technical OOP > terms perfectly. But if they don't know when to use it, they'll never be > able to take full advantage of it. I know because I was like this myself. I > had read a book on OOP in high school which explained all the concepts, but > I went years before I actually used them because I didn't see when they'd > actually benefit my code._ I am comfortable with OOP concepts but a little rusty with supporting languages like Java, C# (my favorite for OO), and even C++. The reason I can't claim to be at least proficient in this area is because I'm not really sold on OO design; everytime I set out to solve a problem that can be done in OOP, I find myself forcing its use and end up making a procedural solution in C which I believe to be a much more elegant program. I guess this involves three questions: Can I still (honestly) sell myself as being valuable to an employer given my skill-set strengths and weaknesses as explained above? Is there any projects or problems I can tackle solo (for practice) that is just smarter to do with OOP? And given an object strong project, what language should I concentrate on?