Is memory management in programming becoming an irrelevant concern?

**Background**   I revisited an old (but great) site I had not been to for ages - the Alioth Language Shootout (http://benchmarksgame.alioth.debian.org/). I started out programming in C/C++ several years ago, but have since then been working almost exclusively in Java due to language constraints in the projects I have been involved in. Not remembering the figures, I wanted to see, approximately, how well Java fared against C/C++ in terms of resource usage. The **execution times** were still relatively good, with Java at worst performing 4x slower than C/C++, but on average around (or below) 2x. Due to the nature of the implementation of Java itself, this was no surprise, and it's performance time was actually _lower_ than what I expected. The real brick was the **memory allocation** \- at worst, Java allocated:   * a whopping 52x more memory than C   * and 25x more than C++.  52x the memory ... Absolutely nasty, right? ... or is it? Memory is comparatively cheap now. **Question:**   If we do not speak in terms of target platforms with strict limits on working memory (i.e. embedded systems and the like), **should memory usage be a concern when picking a general purpose language today?** I am asking in part because I am considering migrating to Scala as my primary language. I very much like the functional aspects of it, but from what I can see it is even more expensive in terms of memory than Java. However, since memory seems to be getting faster, cheaper and more plentiful by the year (it seems to be increasingly hard to find a consumer laptop without at least 4GB of DDR3 RAM), could it not be argued that resource management is becoming increasingly more irrelevant as compared to (possibly implementation-wise expensive) high-level language features which allow for faster construction of more readable solutions?


Has programming for a living ruined your ability to enjoy technology?

To quote Arthur C. Clarke: > Any sufficiently advanced technology is indistinguishable from magic. Used to be I looked on technology with wonder and amazement. I wanted to take it apart, understand how it worked, figure it all out. Technology was magical. I'm older, I know more and I spend my days creating stuff that, hopefully, fills other people with that kind of wonder. But lately I've found my own awe for technology has been seriously curtailed. More often I'm just annoyed that it isn't as elegant or seamless or as polished or perfectly delivered as it seemed to be in my youth. It all looks broken and awkward, or cobbled together and poorly tested. Has programming ruined your ability to enjoy technology? Have you stopped wondering in awe and just started saying, "They could have done this better" every time you pick up a bit of technology?


Is Visual Studio just an IDE?

For Windows Development I mean. Looking over other questions there are alternatives to VS, but they seem to be web based ones, which is fine, or you could program an entire .net website in notepad, should the urge drive you to. But is there more to it than just an IDE for Windows Development? I.E. Is it possible for me to create an application in just notepad, is the compiler part of Visual Studio, or is it separate, which could be called via command line or something? I don't want to not use VS, I'm happy with it, does what I need etc etc, just more a facet I'm curious about.


SICP - Why use accumulate with cons when filter already passes back a list

In SICP 2nd Edition section 2.2.3, the authors have the following code:               (define (even-fibs n)       (accumulate cons                   nil                   (filter even?                           (map fib                                (enumerate-interval 0 n)))))      My question is why did they use _accumulate_ in this case? Couldn't they have got the same answer from _filter_ without using _accumulate_?


Is using PhoneGap for your first ever mobile app a good idea?

I am a beginner programmer. I've gotten an AS degree in CS which exposed me to the basics of c++, data structures, and algorithms and have light experience with html/css/javascript from just messing around building my own basic websites. I am no where near a proficient professional programmer as of yet. My question is, would using PhoneGap to attempt to develop my first "app" for android/ios/whatever be a good idea or should I start out making native apps first? With all the hype over html5/javascript at the moment, PhoneGap seems too good to be true for a beginner like me. Thoughts? pros/cons?


In many interviews I've been asked this question. What is a Package Diagram? and What is a Sequence Diagram? and difference between Package Diagram and Sequence Diagram. Thanks in Advance. **Edit** Sorry, google give me lot of answer, but i want to practical answer with example.


Hash function classification interview question

In several places on the Internet there's the interview question > Classify the Hashing Functions based on the various methods by which the key > value is found. with answers like   * Direct method   * Subtraction method   * Modulo-Division method   * Digit-Extraction method   * Mid-Square method   * Folding method   * Pseudo-random method which I find strange. I think I know a lot about hashing, but this is plain gibberish to me, could anybody explain?


How to document a dual open source license?

If a project is dual-licensed **GPL** & **BSD** , should there be one `LICENSE` file with the text of both licenses? Or two separate files, one for each license? And I think I should put a copyright/license comment at the top of each source file. How should that comment indicate the dual-licensed status of the project?


Dealing with proj files in multi-platform apps

So I've been doing some cross-platform mobile applications using cocos2d-x. Basically it uses common c++ code, that can easily be compiled to the popular mobile platforms with some small wrapper code that stays constant while working on the common c++ code. Everything works great, but I have a problem keeping all my project files up to date. For example, to compile to windows I have a .csproj file that holds all the c++ code to compile, for iOS I have a .xcodeproj that holds the files, and for android I have a make file that points to the files to compile. This means any time I add a new file to my project, or do anything to alter the file structure I have 3 files I must update in order to continue to build for all platforms, if I add any other platforms the problem continues to get worse. I am wondering, is this a problem that has been solved? I'm sure I'm not the first to have problems like this, keeping up multiple project / make files to update for the different platforms to compile. I was thinking of writing my own wrapper that can easily update these files without having to open an IDE / notepad to manually update any time I add a file. But before I do I thought I'd ask the question if there was a well accepted way to handle this problem, perhaps something that already exists that deals with this exact problem. I was curious about whether to ask this here or stackoverflow, as I'm curious both at the cocos2d-x specific case, but also the general case whenever multiple projects must be updated whenever new code is added. I chose to post it here, but am interested to the answer to both questions (specifically if cocos2d-x has something already widely used to solve the problem, and solving the problem in the general case).


Why is it evil to run selects from a prod server?

I'm basically looking for arguments to persuade the internal "consultants" at work as the following are not working:   * What happens if you do a Cartesian join and crash the server?   * You don't need to do selects from that server. You have other servers for that.   * It's not for you it's for the clients. We're going to be implementing DB wide triggers to stop casual logging on during work hours but with a fail safe so that devs / DBAs can fix issues if they come up but need some more arguments to forstall the screaming that's probably going to happen. **EDIT** To clarify; there are no actual problems. The database will be locked down better no matter what. I'm not looking for technical reasons to do things or advice on how to manage a DB. I'm hoping that some other technical people on here have some advice on how to explain to non-technical people the, possibly only perceived, importance of this particular issue.


We have a number of clients, whose systems share some functionality, but also have quite a degree of diversity. The number of clients is growing - always a healthy thing! - and the diversity between their businesses is also increasing. At present there is a single ASP.Net (Web Forms) Web Site (as opposed to web project), which has sub-folders for each tenant, with that tenant's non- standard pages. There is a separate model project, which deals with database access and business logic. Which is preferable - and most importantly, why - between having (a) 1 database per client, with only the features associated with that client; or (b) a single database shared by all clients, where only a subset of tables are used by any one client. The main concerns within the business are over:   * maintenance of multiple assets - backups, version control and the like   * promoting re-use as much as possible How would you ensure these concerns are addressed, which solution is preferable, and why? (I have been also compiling responses to similar questions) **Edit** : here's the highlights from my research from other sources: Should I use one database per application or share a single database amongst multiple applications Splitting up a single project into libraries Supporting multitenancy Multi-tenancy - single database vs multiple database http://msdn.microsoft.com/en-us/library/aa479086.aspx http://stackoverflow.com/questions/2213006/how-to-create-a-multi-tenant- database-with-shared-table-structures http://cloudcomputing.sys-con.com/node/1610582 http://blogs.msdn.com/b/cbiyikoglu/archive/2011/03/23/moving-to-multi-tenant- model-made-easy-with-sql-azure-federations.aspx http://ask.sqlservercentral.com/questions/3615/one-database-or-multiple.html http://devlicio.us/blogs/anne_epstein/archive/2009/04/24/the-case-for- multiple-dbs-in-multi-tenancy-situations.aspx http://ayende.com/blog/3497/multi-tenancy-the-physical-data-model http://www.codeproject.com/Articles/51334/Multi-Tenants-Database-Architecture http://discuss.joelonsoftware.com/default.asp?design.4.319460.16 http://stackoverflow.com/questions/3479297/multiple-application-using-one- database http://stackoverflow.com/questions/1676552/single-or-multiple-databases http://mikehadlow.blogspot.co.uk/2008/11/multi-tenancy-part-1-strategy.html http://mikehadlow.blogspot.co.uk/2008/11/multi-tenancy-part-2-components- and.html http://www.sqlservercentral.com/Forums/Topic893107-373-1.aspx#bm1047297


Good practice for object instantiation in MVC

In MVC the Domain Models(from Model Layer) should instantiate other Domain Models or all the Domain Models should be instantiate in the controllers and passed down using Dependency Injections? How do you implement this in real applications? If you choose this path isn't the controller getting to fat?


Thoughts on web development architecture through integrating C++ in the future to a web application

I'm looking to build a website (it's actually going to be a commercial startup) I saw this question and it _really_ shed some light on a few things that I was hoping to understand (kudos to the op). After seeing that, it would make sense that, unless the website were required to actually have millions of hits per day, it wouldn't be a viable solution to write a C++ backend on the server side. But this got me thinking. what if it in the (unlikely) events of the future, it _does_ go that route? The problem is that, while I'm thinking of starting this all using .Net (in the beginning) just to get something quick and easy up without a lot of hassle (in terms of learning), and then moving towards something more Open Source (such as Python/Django or RoR) later to save money and to support OSS, I'm wondering IFF the website actually becomes big, will it be a good idea to integrate a C++ backend, and use Python ontop of C++ for a strong foundation, and then mitigate HTML/CSS/AJAX/etc ontop of the backend's foundation? I guess, what I'd like to know is that, given the circumstance, if this _were_ to happen, would it be a proper approach in terms of architecture? I'd definitely be supporting MVC as that seems to be a great way to implement a website. All in all, would one consider this rational, or are there other alternatives? I like .Net, and I'd like to use it in the beginning, because I have _much_ more experience with that than, say, Python or PHP, and I prefer it in general, but I really do want to support OSS in the future. **I suppose the sentence I'm looking for is, "is this pragmatic?"**


Sharing programming fees with a fellow software developer

My question relates to how I should share the fees paid by clients to me and a fellow programmer, both of whom are freelancers. I've thought of a few options, but I'm in a dilemma as to which one would be the most motivating for both of us. 1) The first option I've thought is a fifty-fifty share. However, more brainwork is going to be done by my colleague, while initially at least, I will be handling the communication with customers. 2) The second option is a 60-40 share, where the colleague exerting more efforts gets a bigger share. This is the option I feel most inclined to adopt, but I'm not sure how it's going to feel in the long run. 3) The third option is calculating each one's contribution in terms of the number of hours spent, and sharing the revenue accordingly. It will be wonderful to hear everybody's thoughts on this!


XAML - Like/Dislike?

After bashing my head against the brick wall that is XAML, I've decided to come here and ask other people if they are as frustrated as I am. So,   * Do you like XAML? Please justify.   * Is XAML the problem, or the lack of good tools? My issue could be resolved if the binding system gave me a file-line number location of the binding that's failing. This isn't a XAML issue so-much-as a debugger issue. Apart from the issues with tooling, I find that XML does not make a suitable programming language, and that XAML has workarounds to fix things that wouldn't have been a problem in any other "real" programming language. For example, string formatting on a binding. XAML also breaks when you need to step outside the hierarchical structure for things like context menus. Because they are defined within the xaml hierarchy people assume that they are part of the visual hierarchy too, which is not the case. This can lead to subtle binding issues, which are difficult to debug etc. As a comparison, HTML-CSS-Javascript works well because each part handles a specific part of displaying a web page. HTML for data and layout, CSS for style, and Javascript for execution. In contrast, XAML is trying to do everything and fails. Please note, I love WPF, so don't take this as a critisism of WPF, Silverlight or any particular WPF/Silverlight control. I'm only interested in a discussion about the XAML language.


Case convention- Why the variation between languages?

Coming from a Java background, I'm very used to camelCase. When writing C, using the underscore wasn't a big adjustment, since it was only used sparingly when writing simple Unix apps. In the meantime, I stuck with camelCase as my style, as did most of the class. However, now that I'm teaching myself C# in preparation for my upcoming Usability Design class in the fall, the PascalCase convention of the language is really tripping me up and I'm having to rely on intellisense a great deal in order to make sure the correct API method is being used. To be honest, switching to the PascalCase layout hasn't quite sunk in the muscle memory just yet, and that is frustrating from my point of view. Since C# and Java are considered to be brother languages, as both are descended from C++, why the variation in the language conventions? Was it a personal decision by the creators based on their comfort level, or was it just to play mindgames with new introductees to the language?


How to model optional use cases in UML

Let's say, I want to model an application which allows users to model class diagrams. The high level use case can be modelled as UC1:Model Class Diagram, which refines itself into UC11: Model Class, UC12: Model Connection, UC13: Model Composition, etc. Since UC11, 12, 13 are part of UC 1, I used the include-Association. Unfortunately, the UML specification says that included use cases are essential parts and if you would leave one of them out the high level behavior could not be achieved any more. But in this example a valid class diagram can be created without modelling a connection or a composition, so these use cases are optional. To boil it down to an essence: How can optional use cases be modelled in UML while providing a mechanism for reuse (like the include association)?


PHP Open Source Tools for Agile Development

Hello Everyone, There are so many Questions on Stackoverflow about Agile tools, but I haven't seen a tool which can be installed on a PHP Server. I'm just looking for an _**Open Source Scrum Tool**_ or just an _**Open Source Scrum Dashboard**_ for my Team, which can be installed on my webspace( **php** ). Thank you for Help!


What is occurring in the world of server-side technologies in regards to the mobile app boom?

With mobile technologies becoming increasingly popular what is happening on the server-side with most of these apps when they need to communicate with a back end? I'm used to the world of technology from 10 years ago when most resources were accessed by requesting a dynamic web page that behind the seen used a server- side language to get the information it needed from a relational database. Is this still the case, and if not, what are the big changes?


On linux, how to get "incompatible" i386 f77 libraries to work with current Fortran compilers, like gfortran?

I would like to run the elf32-i386 library libkernlib.a with a Fortran 77 program on my latest Ubuntu linux machine. From what I've read, `gfortran` is backwards compatible with Fortran 77, but I'm having trouble to get it to work with the library. I've tried -ff2c, -fbackflash, etc. but everything is still giving me               $ gfortran -ff2c -O -o output f77fortran.f -lkernlib          /usr/bin/ld: skipping incompatible //usr/local/lib/libkernlib.a when searching for -lkernlib     /usr/bin/ld: canot find -lkernlib      I have also tried using `fort77`. I cannot find a `f77` that works. **If anyone knows how to run f77 programs and its libraries, whether using`gfortran` or something else, that would be great.** Btw, the libkernlib.a library has older versions from "libraries" links on this page, but the ones I've tried all give the same error and are all i386 (I figured out that by `objdump -f libkernlib.a`). Context: This is part of a Mathematica project that uses old code.


Domain Model vs View Model

I'm in the early stages of my programming career and I've been working with MVC for just about a year now. I've spent much time learning about the pattern and the concepts behind it, but as the projects I'm working with get larger I'm starting to think that maybe I don't have the best understanding of how the model layer is supposed to work. I hear a lot about always having a View Model to protect your Domain Model but how does this work in practice? What does the relationship between the two look like? What if a model doesn't need any extra "view" logic, should I just create a copy of it? Why?


Java for a perfect Media Player?

I am looking forward to build a media player with java, and basically what I found was JMF. But, then again, this API is not upto date and doesn't support latest formats such as `MKV`. On more research, I stumbled upon http://stackoverflow.com/questions/10440152/any-simple-and-up-to-date-java- frameworks-for-embedding-movies-within-a-swing Got all excited, but then digging some more, left me with this http://stackoverflow.com/questions/8153227/adding-other-video-codecs-dvd- support-to-javafx-2-2 Now, I am disappointed and in a fix that how all the good media players (VLC, KMPlayer etc) been able to support all video and audio formats. They must be build using a programming language, IMHO ! So, my question would be, in-order to build a `complete media player` which supports `all kind of media files`:   1. Is `JAVA` incompetent ?   2. Has one ever build a good media player using `JAVA` ?   3. If Java can't, how are their so many media players on `android`, with all video support ?   4. Is it just Java or no modern language can do it ?   5. Do I have rely and choose C, C++ to do this ?


Using a single table for identity and metadata

I'm in the early design phase of a project to provide an e-commerce platform that will require several entities to be modelled, products, customers, orders, CMS pages, etc. They will all have a few things in common (ID, creation timestamp, last modified timestamp, etc). My first thought was the usual one of giving the various tables an ID column that will use the database's mechanism for assigning uniqueness (autoincrement in MySQL, sequences in Postgres, etc) but given they have a few things in common I was considering a design where all that data is kept in a base BusinessObject table and the tables for the other entities use a primary foreign key that references the BusinessObject table. For example (in pseudocode)               CREATE TABLE BusinessObject (         id,         date_created,          date_updated,          is_deleted,         // etc         PRIMARY KEY id AUTOINCREMENT     );          CREATE TABLE Customer (         id,         forename,         surname,         // etc         PRIMARY KEY id         FOREIGN KEY id REFERENCES BusinessObject.id     );          CREATE TABLE Product (         id,         name,         price,         description,         // etc         PRIMARY KEY id         FOREIGN KEY id REFERENCES BusinessObject.id     );      and so on. I can think of a number of advantages to this approach. First, a particular ID always only maps onto one particular object. For example, the id 3 in a system where each table generates its own IDs could refer to a customer, an order or anything else, whereas in the above design, ID 3 will always be an order, because there could never be a customer or product with ID 3. This would make stuff like extrapolating the referenced business object from the URL a lot easier, allowing for simpler routing in the application layer. However, it also means that every table in the system must join against the BusinessObject table, and I'm worried that this would result in some significant drawbacks. For example the fact that one particular table is going to be involved in nearly all queries may result in degraded performance for that table, or that it might be possible for a row in Customer to reference the same row in BusinessObject as a row in Product, resulting in loss of data integrity unless some additional steps are taken to prevent that. So basically, what are the pros and cons of a design where a single table provides the identity data for most of the rest of the database? Are such designs fairly common or is it better to just have each table have its own identity source and rely on cleverer application logic to determine the object being referenced?


Data structure: sort and search effectively

I need to have a data structure with say 4 keys . I can sort on any of these keys. What data structure can I opt for? Sorting time should be very little. I thought of a tree, but it will be only help searching on one key. For other keys I'll have to remake the tree on that particular key and then find it. Is there any data structure that can take care of all 4 keys at the same time? these 4 fields [source ip, destination ip, source port, destination] are of total 12 bytes and total size for each record - 40 bytes.. have memory constraints too... around one lac records operations are : insertion, deletion, sorting on different keys. For printing , sorting the records on any of one keys should not take more than 5 seconds.


Is "3 or more use a for" a good rule of thumb?

When do repetitive operations become a code smell? I read this article by Charles Petzold where he suggested this and was wondering what people thought.


Refactoring the shipping application code to use DDD factories

I was trying to find examples for using DDD factories and I came across the shipping application from Eric Evans' book. However when I checked the BookingService the code to create a `Cargo` had this comment at line **37** :               34    public TrackingId bookNewCargo(final UnLocode originUnLocode,     35                                   final UnLocode destinationUnLocode,     36                                   final Date arrivalDeadline) {     37      // TODO modeling this as a cargo factory might be suitable     38      final TrackingId trackingId = cargoRepository.nextTrackingId();     39      final Location origin = locationRepository.find(originUnLocode);     40      final Location destination = locationRepository.find(destinationUnLocode);     41      final RouteSpecification routeSpecification = new RouteSpecification(origin, destination, arrivalDeadline);     42       43      final Cargo cargo = new Cargo(trackingId, routeSpecification);     44       45      cargoRepository.store(cargo);     46      logger.info("Booked new cargo with tracking id " + cargo.trackingId().idString());     47       48      return cargo.trackingId();     49    }      How should the DDD factory be used here? Which parts exactly should be refactored to use the factory in these piece of code?


**The debate:** Should all development, including refactoring work, be accompanied by a tracking issue? (in our case, Jira) **The common ground:** Our primary goal is quality. A working product, every release, is more important than anything else. Our codebase is old and automated tests are lacking; we are working on this but it's a long-term project, we need interim processes. **Position 1:** Refactoring work must be tracked in Jira. If it is not obviously related to the change you are making then you must raise another issue. If you don't then the work bypasses review and testing and there is a risk to our primary goal. The argument has been made that PCI compliance (a near-future goal of the business) requires this level of tracking; I'm not in a position to say that is true or false with any level of certainty. **Position 2:** Code quality is vastly important. The better it gets (to a point; a point we are nowhere near), the more likely we are to keep releasing a working product. Anything which puts a barrier, no matter how small, in the way of refactoring is a risk to our primary goal. Often, the IDE does the work for you, so it isn't likely to go wrong anyway. **The following cases have been made:** Would it satisfy both positions if a developer writes "Refactor" and the relevant revision numbers on a card? Honestly, this feels like it's going to make everyone equally unhappy. It still puts a level of resistance on doing the refactoring, but doesn't offer sufficient tracking. What about having all-encompassing Jira issues that cover the refactoring work for an iteration? Yes, this removes the developer resistance layer, but I fear it also removes the tracking benefits of having a Jira issue. How do QA get a clear idea what to test? This seems to be a political solution, keeping everyone calm by adding in a light-weight but ultimately pointless process. It seems to me that, given that both sides of the debate ultimately want the same thing, there should be a solution that makes everyone genuinely happy. We can't have been the first people to ask this question, so what experiences have others had in similar situations?


What are the main practices and design patterns every .NET guy should know?

In my brief time as a professional programmer I've seen lots of applications written by programmers who's entire education appears to have been reading the first couple of chapters in a .NET 2.0 book. Heck when I started I wrote most of those applications! What are the biggest design patterns crucial for writing AWESOME .NET applications? By awesome I mean on the inside too!


Which applications have driven the mass spread of floating point units?

Floating point units are standard on CPUs today, and even desktops might use them today (3D effects). However, I wonder which applications have initially driven the development and mass adoption of floating point units in history. Ten years ago, I think most uses of floating point arithmetics constituted in either   1. Engineering and Science applications   2. 3D graphics in computer games I think for any application where decimal numbers might have appeared at those times, fixed point arithmetic has been sufficient (2D graphics) or even desirable (finance). Usage of integers would have been sufficient then. I think these two applications have been the major motivation to establish floating point arithmetic in hardware as a standard. Can you name others, or is there a compelling reason to disagree?


Main class passes dbConn obj to all its services, I need to change the dbConn for one of its services. - suggestion for design pattern

There is this main class and there are several services ( which uses db connection to retrieve data ) These services are initialized in the main class db properties are obtained from the property file and then dbconnection is opened by calling a method dbOpen() written in the main class and the resultant connection object is set to the service objects by iterating through the list of services and by calling setConnection method on the service `note: that the services are instantiated in the main class and the main class is not a superclass for services.` I also need to mention that there is this `recycle db connection` scenario only main class is aware of.               /** connects to DB, optionally recycling existing connection),           * throws RuntimeException if unable to connect */          private void connectDb(boolean recycle) {             try {                 if (recycle) {                     log.status( log.getSB().append("Recycling DB Connection") );                     closeDb();                 }                 openDb();                        for ( int i = 0 ; i < service.length ; i++ )                 {                     service[i].setConnection(db);                 }             }      One of the service needs to use a different database, what is the best design pattern to use?


In WPF, should I base my converters on types or use-cases?

I'm looking for some advice on how to write my WPF value converters. The way I'm currently writing them, they are very specific, like (bool?,bool) => Brush, i.e. I'm writing each converter for a specific use case, in this case, the Brush is bound to an indicator showing equality information between the bool? and the bool. This obviously makes re-use very hard and I end up with a quite large list of converters. Should I strive to write my converters in a more general way? Can I?


Technique for multiple users on same datasets

This is more a learning question than coding, but I'm certain it's a common issue for anyone developing administration systems or applications in php/mysql/js etc. I've developed quite a complex application that lets users upload images, and define hotspots in them with associated actions. The images are stored in a table, and the actions in another, with json data for every action in a text field. However, like I say, the problem is generic. Basically, my fear is that if someone is editing the same image and set of actions at the same time, and they both submit changes, or if it was edited by someone else then there's a whole series of structures that potentially will fail on submission. I don't want to implement a locking system, as the system is very wide ranging (links to other images, etc), and I think it's a bit ugly. I saw this link (MSDN Multi-tenant architecture article) in another question, but it seems a little overwhelming and specialised for sql server. So - what are the terms for data and system architecture here that I can investigate, or are there some good articles to do with this topic that people can recommend? Specifically for php/web world would be great!


using trademarked/copyrighted images in my public web application

Consider a public web application that wants to 'look' better by including the use of corporate images. The imagery would be used to give the website visitor a choice: Coke or Pepsi, Starbucks or Dunkin, Yankees or Red Sox, etc. It's a service that wants to enhancing the user experience by having those logos in place in the relevant spots. The web application would not be selling those images, or anything with the images. The site would be generating revenue via ads or paid services. Is there a general accepted practice on the web regarding trademarked images or logos? Has this been legally tested in any jurisdiction?


When can I say I know how to program in C?

Let's see. I've seen in several places, including Advice for Computer Science College Students, by Joel Spolsky, that a graduated Computer Science student must know C. **How do I know if I know C or not?** I have developed a few projects in C (an implementation of the _ext2_ filesystem with FUSE, and a few others), but I suppose it means more than just knowing pointers, free, etc.


Scaling yourself up against a better programmer/role model?

After having watched this video I have to ask how a programmer can go about measuring themselves against other, better programmers much as a chess player would. How would you decide who is a role model to start with? I mean James Gosling is known by every Java programmer but he invented the language and there is almost certainly an expert out there who could show him a few tricks. Now say you have you found that role model. This could be, say, StackOverflow's own superstar Jon Skeet. It's possible to read his answers on StackExchange, visit his blog and read his books but what about actual programming skill? How could you go about fixing challenges and determining where you are in the programming skill spectrum?


Review my class hierarchy

I have created a class hierarchy for an inventory system for a book/magazine. Here's the picture: ![enter image description here](http://i.stack.imgur.com/3WGKd.jpg) Will it do? I know there's no magazine class yet but I was wondering if anyone could suggest a better idea.


Selling an open source project: some issues

I am the creator / main developer of a small sized open source (PHP) project (GPL3). Currently there is a development team of 3 people (me included). This team has been quite active for some time, but since almost 2 years not much has happened. I myself have decided I want to stop working on the project, but I can't just leave the project because I care about it and I know if I abandon it, it will just be a matter of time before the project completely dies. At this moment, there are still some users and the project is only slightly out- of-date. So I'm thinking about selling the whole project. Of course I'd need to get consent of the other developers, but for now I'm assuming that's not a big problem. So at this moment I have 2 questions: 1) If the project would be sold to a commercial party, would it be possible for them to convert the project to closed source? I would prefer to sell the project to a company/organization that would continue the development under an open source license. 2) Does anyone have any tips to find interested parties? I don't know if I just want to put up a "For Sale" sign on the website of the project. Maybe someone has experience with a comparable situation. Ok guys, thanks in advance!


Where is the M in MVC?

I'm trying to refactor my application into MVC, but I'm stuck on the M part. In a database-backed app, the model is implemented in the app code, right? But then, **what is in the database -- is that not also the model?** _(I'm not using the database as a simple object store -- the data in the DB is an enterprise asset)._


How to support multiple firmware versions?

I'm working on an app which talks to a bluetooth low energy (BLE) device and exchanges customized data with it. Our team has defined the data models and there's a method that will parse the data payload and assign values to the corresponding characteristics. It works all fine until we have introduced a new firmware. In this new firmware some values in the data payload have been re-defined or the offset of a specific value has been changed. So the parsing method will need to be updated/re-written according to the new payload definition. Then here comes the problem: both two versions of the firmware need to be supported! Of course I could write a lot of if/else in the parsing method right now, but what happend if 3 other firmware updates arrive one after other? I can imagine the code will become hard to read and lose it's simplicity. I'm wondering if there's an elegant way to manage the co-existence of firmware versions. Maybe a design pattern that can be adopted here? **To make it more specific:** In my model class `Temperature` I've the following properties:               @property (nonatomic, readonly) float temp_outside;     @property (nonatomic, readonly) float temp_inside;      The library has to support 3 different firmware versions:   * **V1** does only support `temp_outside`   * **V2** does support `temp_outside` and `temp_inside`   * **V3** does support `temp_outside` and `temp_inside`, but `temp_inside` has to be obtained differently compared to **V1 & V2** Assuming the firmware provides their information within the `manufacturer data` of the advertisings as raw data:   * **V1 firmware:** 00 42 0a      * (byte 1: sw id, byte 2: protocol id, byte 3: temp_outside)   * **V2 firmware:** 00 43 0a 10      * (byte 1: sw id, byte 2: protocol id, byte 3: temp_outside, byte 4: temp_inside)   * **V3 firmware:** 00 44 10 0a      * (byte 1: sw id, byte 2: protocol id, byte 3: temp_inside, byte 4: temp_outside) What is the best way to implement this? There are several things to consider:   1. The model has values which might not be filled by a specific firmware; should I have separate models per firmware or how can I make sure that only supported properties will be accessed?   2. The method responsible for parsing the bytes into the model has to support all firmwares. Should there be one method / parser with several conditions based on the protocol id or several parser classes?   3. The usage of the library within view controllers should be as convenient as possible.


What sort of information can I extract out of a dll file?

I was dealing with a virus earlier today which was a .dll file disguised as RUNDLL.dll which is regularly seen in the task manager and launches on startup. I would like to know how much information I could have extracted from that dll before deleting it. I used .NET reflector, and the file was unrecognized (meaning it was not c# code from what I understand.) I used visual studio and attempted to reference it but was greeted by another error. Visual studio handles all of the .net languages so I was surprised to say the least. I expected to find atleast the function names in the object browser if not anything else. Decompiling it was probably a waste of time if it was c++/c since that would just be assembly code. In what ways could a .dll file like this one prevent revealing information (function names, number of functions, etc.)? Are c++/c .dll files basically impossible to investigate for further information? Thanks.


How can a manager ensure developers are pushing up to the origin every day?

Our team has been using Git for a couple of years. I love it, after previously using Visual Source Safe, SVN and TFS. However, my manager has been getting increasingly agitated about it and is threatening to go back to SVN or TFS. The problem is human nature: Developers forgetting to push up to the origin every day, then going sick or taking a holiday, and someone else having to pick up the project, and not knowing whether the latest code is in the origin, or whether it is sitting on the absent developer's machine. There is no visibility of which developer was the last to work on which file, as there is with a centralized source control system. I really want to avoid going back to SVN of TFS. So my question is: How can a team use Git successfully in a way that takes into account human nature (forgetfulness, laziness, etc)? How can I ensure that at the end of every day the latest code has been pushed to the origin so that someone else can step in and take over the next day, if need be? Is the answer continuous integration? I've read about workflows that include having to push to a CI branch on the origin to build the project.


Use Google Analytics to track visitor/download stats for a Google Code Project?

Can you use Google Analytics to track visitors/downloaders for a Google Code project? I've searched google for an answer but I get results about Google Analytics as a Google Code project itself and not for applying it to a Google Code project for visitor/download data.


Morse Code - Binary Tree

How is the Morse Code representation of a letter determined? "E" = "." "T" = "-" Why is it not alphabetic? As in let "A" = ".", "B" = "-", "C" =".-", etc. I'm trying to develop an algorithm for a traversing Binary Tree filled with these letter. My main aim is to search for a letter, like "A", but I don't know what conditions to use that determines when to branch to the right or left node.


Amazon Cloud (EC2) w/SQL Server. Pay for SQL instance, or use an AMI w/SQL Server Express?

I have been considering using the Amazon cloud (EC2) for a small workflow application. In terms of power and storage, a SQL Server Express database will more than meet my needs. I have been cautioned against paying for just a Windows server instance and installing SQL Server Express due to mainly security issues. Is it reasonable to think that there is an Amazon Machine Image (preconfigured images that you can load onto your instance) with SQL Server Express installed where most of the server "hardening" has been taken care of? The wise course may be to just pay for the Windows + SQL Server instance so it is already configured for me, but it is quite a cost difference.


SQL problems and answers book for a functioning SQL programmer

It was pointed out to me yesterday that I need to get a book on SQL and learn about it properly. That is probably a fair assessment; I'm a functioning SQL programmer who can in general extract from the database the information that is needed, but as soon as extracting the data needs more than a couple of `joins` and a `where` clause the query that I come up with is probably not as good as it could be. Previously I was working at an Oracle shop where there were a few very good SQL programmers who would generally design the more complex queries and would be on hand to answer questions, but now I'm at a SQL Server shop where no one really has much of a clue about SQL and so I feel like I need to get my skills up. What I'm looking for is a book that is fairly short and very practical that I can work through in the evenings with a series of difficult SQL problems and then well explained solutions along with a few pieces of sage advice that is aimed at a programmer who can "do SQL" who wants to become more of a "SQL programmer". I appreciate that many things about SQL are platform dependent, so since I'm currently in a SQL Server shop then my preference would be for a book aimed at TSQL. Any suggestions?


How advanced are author-recognition methods?

From a written text by an author if a computer program analyses the text, how much can a computer program tell today about the author of some (long enough to be statistically significant) texts? Can the computer program even tell with "certainty" whether a man or a woman wrote this text based solely on the contents of the text and not an investigation such as ip numbers etc? I'm interested to know if there are algorithms in use for instance to automatically know whether an author was male or female or similar characteristics of an author that a computer program can decide based on analyses of the written text by an author. It could be useful to know before you read a message what a computer analyses says about the author, do you agree? If I for instance get a longer message from my wife that she has had an accident in Nigeria and the computer program says that with 99 % probability the message was written by a male author in his sixties of non-caucasian origin or likewise, or by somebody who is not my wife, then the computer program could help me investigate why a certain message differs in characteristics. There can also be other uses for instance just detecting outliers in a geographically or demographically bounded larger data set. Scam detection is the obvious use I'm thinking of but there could also be other uses. Are there already such programs that analyse a written text to tell something about the author based on word choice, use of pronouns, unusual language usage, or likewise?


Algorithms for Data Redundancy and Failover for distributed storage system?

I'm building a distributed storage system that works with different storage sizes. For instance, my storage devices have sizes of 50GB, 70GB, 150GB, 250GB, 1000GB, 5 storage systems in one system. My application will store any files to the storage system. Question: How can I build a distributed storage with the idea of data redundancy and fail-over to store documents, videos, any type of files at the same time ensuring that should one of any storage devices fail, there would be another copy of these files on another storage device. However, the concern is, 50GB of storage can only store this maximum number of files as compared to 70GB, 150GB etc. With one storage in mind, bringing 5 storage systems like a cloud storage, is there any logical way to distribute or store the files through my application? How do I ensure data redundancy through different storage sizes? Is there any algorithm to collate multiple blob files into a single file archive? What is the best solution for one cloud storage with multiple different storage sizes? I open this topic with the objective of discussing the best way to implement this idea, assuming simplicity, what are the issues of this implementation, performance measurements and discussion of the limitations.


Uses of persistent data structures in non-functional languages

Languages that are purely functional or near-purely functional benefit from persistent data structures because they are immutable and fit well with the stateless style of functional programming. But from time to time we see libraries of persistent data structures for (state-based, OOP) languages like Java. A claim often heard in favor of persistent data structures is that because they are immutable, they are _thread-safe_. However, the reason that persistent data structures are thread-safe is that if one thread were to "add" an element to a persistent collection, the operation returns a _new_ collection like the original but with the element added. Other threads therefore see the original collection. The two collections share a lot of internal state, of course -- that's why these persistent structures are efficient. But since different threads see different states of data, it would seem that persistent data structures are _not_ in themselves sufficient to handle scenarios where one thread makes a change that is visible to other threads. For this, it seems we must use devices such as atoms, references, software transactional memory, or even classic locks and synchronization mechanisms. Why then, is the immutability of PDSs touted as something beneficial for "thread safety"? Are there any real examples where PDSs help in synchronization, or solving concurrency problems? Or are PDSs simply a way to provide a stateless interface to an object in support of a functional programming style?


Security Risks of Unsigned ClickOnce Manifests

Using signed manifests in ClickOnce deployments, it is not possible to modify files after the deployment package has been published - installation will fail as hash information in the manifest won't match up with the modified files. I recently stumbled upon a situation where this was problematic - customers need to be able to set things like connection strings in app.config before deploying the software to their users. I got round the problem by un-checking the option to "Sign the ClickOnce manifests" in VS2010 and explicitly excluding the app.config file from the list of files to have hashes generated during the publish process. From a related page on MSDN > "Unsigned manifests can simplify development and testing of your > application. However, unsigned manifests introduce substantial security > risks in a production environment. Only consider using unsigned manifests if > your ClickOnce application runs on computers within an intranet that is > completely isolated from the internet or other sources of malicious code." In my situation, this isn't an immediate problem - the deployment won't be internet-facing. However, I'm curious to learn what the "substantial security risks" of what I've done would be if it was internet-facing (or if things changed and it needed to be in the future). Thanks in advance! * * * **Edit / follow-up:** Does _not signing_ the ClickOnce manifest constitute an unsigned manifest (as per MSDN's definition)? The application manifest contains a hash of the files in the deployment package. Any changes to the files within it results in a validation failure during installation. Does this negate the above security risks, at all?


Solutions for floating point rounding errors

In building an application that deals with a lot of mathematical calculations, I have encountered the problem that certain numbers cause rounding errors. While I understand that floating point is not exact, the problem is _how_ do I deal with exact numbers to make sure that when calculations are preformed on them floating point rounding doesn't cause any issues?


Automatically create or update object in database

I have a database class with the following interface:               public Database {         //returns false if p (its ID) is already available         //otherwise adds p the the list and returns true         public boolean create(Person p);              //returns false if p (its ID) was not found in the list         //replaces the available Person q (q.ID == p.ID) with p and returns true         public boolean update(Person p);              //returns false if p (its ID) was not found in the list         //marks the available Person q (q.ID == p.ID) as inactive returns true         public boolean remove(Person p);     }      The `Person` is immutable and can be identified by a unique id. I have a `EditDialog` which looks like this: ![Editing a Person and the available Save/Chancel/Remove functionalities](http://i.stack.imgur.com/H7l0E.png) I wanted to reuse my code and so the `EditDialog` is used for create a `Person` or update it. So this dialog is initialized either by a available `Person` instance (Edit-Operation) or by a new one (Create-Operation). Because I learned that there is always an evil user I wanted to avoid the following scenario:   * Click "Create Person" button      * New `Person` is created in Database     * `EditDialog` for new `Person` is displayed   * Click "Chancel" button      * `Person` has to be removed (= marked inactive) from `Database`     * `EditDialog` is disposed   * repeat Which would lead to many inactive `Person`s in the `Database`. So I decided to only create the `Person` in the `Database`, if the user clicks the "Save" button. Which leads to two possible scenarios for the `Listener` of the "Save" button:   1. New `Person` should be created in `Database`   2. `Person` should be updaated in `Database` So the code of the Listener looks like the following:               if(!database.create(p) {         database.update(p);     }      Which is not so pretty in my opinion. The Long and the short of it is, **should the Database automatically**   * **update a`Person` if it's availabe at invokation of `create(Person)`?**   * **create a`Person` if it's not yet available at invokation of `update(Person)`?** **Or is there another solution/practice I didn't think about?**


How to Model a simple file-system by UML class diagram

I want to model a file system which contains both files and directories, and directories can contain either files or other directories. This is what I have reached so far: ![My simple file system class diagram](http://i.stack.imgur.com/6URV9.png) In OOSE book, however, a similar model is presented: ![class diagram for file system presented](http://i.stack.imgur.com/GonyF.png) Now I have two questions:   1. I wonder why the author did not use an _Interface_ to represent the abstract type **FileSystemElement**? Isn't using an interface for this type correct?   2. As we know, files and directories must have names with similar constraint (e.g. maximum length of 256 characters). Therefore, it would be nice if I model this in the **FileSystemElement**. But an **interface** cannot have a _abstract attribute_ , so I have to repeat **name** attribute in both **Directory** and **File** classes. Is there any better workaround for this problem?


What an architect should do?

It seems that the role of architect varies in between software companies. What does the role of a standard architect include? E.g...   1. Draw high level diagrams and explain to the team why this is a reasonable architecture.   2. Write documents for managers or customers.   3. Write the infrastructure of a software upon to which others add more features.   4. Write various prototypes and run performance tests.   5. Conceive additional features and improvement to existing features and guide the team towards them.   6. Other responsibilities.


What is the difference between requirements and acceptance criteria?

I am trying to understand the difference a little better as it seem like they are the same thing. I have work in projects with no use of the requirements and everything is an acceptance criteria, and on projects that have both.


New and old technologies coexist in legacy system

New technologies can accomplish existing tasks in more efficient and powerful way. But sometimes old technologies cannot be discarded unfortunately, so more numbers of technologies in one system make maintain difficult. Is it worth to introduce new technologies? For instance, a legacy system uses SOAP internally and JSON is new technology to replace the SOAP. The problem is JSON can only replace **some** of SOAP, because the rest of SOAP is too complex to replace. As a result, the system will use both SOAP and JSON at same time. The maintain is even more difficult than before. Is it reasonable to introduce new technologies to replace **part** of old ones?


Web app design: Local caching vs demanding

I'm writing a web application in javascript that will be served to the clients' browser. The intent is for the app to appear to the client as a monolithic application, not a series of interlinked refreshing web pages. My question deals with common architecture. In order to relate the question I'll mention a specific feature of the web app is a "tour"; when the client clicks a button labeled "tour" the web app will load a div with a bit about the app itself, and what it can do for the user. There are two ways this could be handled, the client browser could fetch the tour markup from the server when the user clicks the button, or the server could download it (and all other such features) when the app is initially downloaded. If I fetch the tour on demand, then I possibly save network bandwidth as not everyone will take the tour, the app will be smaller too. But this means that in order for someone to fully use the app there will be more network congestion as there will be another hit on the network for loading the tour. If I just serve all the features initially, the app is larger, but there is less congestion on the network because, once downloaded, there is less need to access the network (unless a fresh copy of the app is required (ie if- modified-since). This 'tour' feature isn't really the issue itself, it's just an example to explain my question. How to balance caching vs demanding in web app design?


Should one Consider Periods in "Year of Experience" while actually not Coding on regular basis

Sorry if the title sounds a bit clumsy. The scenario I am trying to describe is during my academic years I have mostly coded in C/C++. Few small projects were done but no large scale work was done. From there on, after entering industry, I rarely code in C++ but whenever I do, I use its features as deep as my understanding. Now, should I even consider myself a C++ programmer and count every year since I first started coding as my number of years in C++.


Is the following example a strategy pattern?

In my problem I had lots of objects with slightly different behaviour, but identical attributes and methodes with identical interfaces. The objects variants were quite big in number, and I didn't want to create a class for each of them, with lots of repeting code. I circumvented creating a lot of derived classed by the following construct (pseudocode for abbrevation)               #aTP = all the parameters     def _function_version_1(aTP):         ...          ...          def _function_version_BIG(aTP):         ...          class BaseClass(object):         _typesOfImplementation = {'ONE' : _function_version_1,                                    ...                                   'BIG' : _function_version_BIG,                                  }              def __init__(self, type, ...)             ...             if type not in _typesOfImplementation:                 raise Exception('Unknown type')             # respective function for this object             self.function = lambda aTP:BaseClass._typesOfImplementation[type](self, aTP)      Is this still an implementation of the strategy pattern, although I didn't use classes for the respective function version (which would have been an awful bunch of classes again)?


What is the most effective work rhythm for a programmer?

I was wondering what is the best work rhythm for the job a programmer does? I am coding all day long and sometimes I get stuck in a problem and it keeps me occupied a few hours before I realize that maybe I need a break. Some say frequent and short brakes help you but sometimes when I am focused on a problem I feel like a break would not help, but rather loose my focus. So how often should a break be taken, and how long? The more basic question regarding this issue is comes from the fact that, you can get tons of "good ideas" ('promodo' for instance) on the net, that promise you will be more effective in whatever you do. Are these principles good or, this is something everybody should decide for himself? I wonder if any of them can accomplish what it promises! I mean what they promise is that (if the conditions are met) it works for **everybody**. Are there really such principles? And if there are, what are these and how can we find them?


Why do most sites require email activation

Most popular applications nowadays require account activation by email. I've never done it with apps that I've developed so am I missing some crucial security feature? By email activation I mean when you register to a site they send you an email that contains a link that you have to click before your account gets activated.


programming an expert system

I need to program an expert system that, according to a series of complex possibilities, returns a well defined result, together with some kind of diagnostic of what that results means. What is the general process to define the behavior of an expert system, from the initial assessment of the conditions to the actual code ?


How to POST CSV with XMLHttpRequest

I would like to send a CSV file via POST in a XMLHttpRequest, but I am unsure of two things. First is there anything to distinguish a CSV file from a string split up by comma's? And what sort of Content-Type am I supposed to put in to the `setRequestHeader`?


Calculating combinations from categories

I'm trying to calculate every possible selection from different categories. 1 choice must be made from every category and the categories are always in the same order. I save a string where each character is the number of that choice from that category. I have solved this with recursion and it works well when there are thousands of possibilities but is too slow when there are millions. I'd like to change it to looping to hopefully speed it up. Here is my recursive function (C#):               private void GetPartNumberPermutations(IList<int> choices, string partNumber)     {         for (int i = 0; i < choices[0]; i++)         {             if (choices.Count > 1)                 GetPartNumberPermutations(choices.Skip(1).ToList(), partNumber + i.ToString());             else             {                 //add partNumber to the list             }         }     }      Choices is a list of the number of choices for each category and might look like { 2, 4, 5, 8, 2, 4 }. Let's ignore the problem when one of the entries is > 9. My final list of partNumbers comes out to: 000000   000001   000002   000003   000010   000011   000012   000013   000100   000101   etc


How to tackle massive Linux/makefile projects effectively?

I have been developing Windows applications in C++ for like 10 years now. And recently I've started digging into some Linux projects, and I can't stand how unproductive I am... I'm a fast learner, and I've been using Linux as a primary platform for some time now. And I do feel very comfortable with shell, OS principles and GUI. But when it comes to development, it feels like I'm back to school. As soon as I open some larger project, I'm stuck. Most of them are makefile based, so basically when I try to navigate them with QT or CodeBlocks, at best, I can use intellisense on a per-file basis. And most of the time variables leak from scope. Then there is a go-to-definition stuff, which seems nonexistent, try to join some larger project from sourceforge, and you're stuck for days, because navigating to definitions is so hard... `grep -r "this_def" . --include "*.cpp" --include "*.h"` seems so slow and clumsy. And then, the debugging, gdb does work, but no matter what I do, it seems like it's light years behind WinDbg or VisualStudio debugger. And these things are making me desperate, I want to write code, but it just goes so slow... I'm starting to think that Linux developers learn function definitions by heart and analyze code by eyes, but I can't believe it's so. Has anyone gone through this? Is there something that I'm missing that could make me more productive?


Alias variable vs multiple use of getter

Would you rather:               $this->getDoctrine()->getManager()->persist($currency);     $this->getDoctrine()->getManager()->persist($user);     $this->getDoctrine()->getManager()->flush();      or               $em = $this->getDoctrine()->getManager();     $em->persist($currency);     $em->persist($user);     $em->flush();      Is using a aliasing variable for faster coding a smart choice, or should the programmer rather use variables only if they are really variables.


What is the reason behind methods with return values and methods with void?

I want to uderstand why there is a method in C# that could reurn a value, for example:               public int Accelerate()     {        Speed++;        return Speed;     }      and a method that does not reurn a value (void)? What is the difference in the following example of the above one:               public void Accelerate()     {       Speed++;       Console.WriteLine(Speed);     }      I see that last one will save us a time rather than defining a variable to hold this field in when creating a new object! I'm beginner, so could anyone explain?


Reading input all together or in steps?

For many programming quizzes we are given a bunch of input lines and we have to process each input , do some computation and output the result. My question is what is the best way to optimize the runtime of the solution ?   1. Read all input, store it (in array or something) ,compute result for all of them, finally output it all together. or 2\. Read one input, compute the result, output the result and so on for each input given. UPDATE Since no answer was specific I would ask which approach is the best for problems like this: > ### Quadrant Queries (30 points) > > There are N points in the plane. The ith point has coordinates (xi, yi). > Perform the following queries: > > 1) Reflect all points between point i and j both including along the X axis. > This query is represented as "X i j"   >  2) Reflect all points between point i and j both including along the Y > axis. This query is represented as "Y i j"   >  3) Count how many points between point i and j both including lie in each > of the 4 quadrants. This query is represented as "C i j" > > ### Input: > > The first line contains N, the number of points. N lines follow.   >  The `i`th line contains xi and yi separated by a space.   >  The next line contains Q the number of queries. The next Q lines contain > one query each, of one of the above forms.   >  All indices are 1 indexed. > > ### Output: > > Output one line for each query of the type "C i j". The corresponding line > contains 4 integers; the number of points having indices in the range [i..j] > in the 1st,2nd,3rd and 4th quadrants respectively. > > ### Constraints: >   >   >     1 <= N <= 100000 >     1 <= Q <= 1000000 >   > > You may assume that no point lies on the X or the Y axis.   >  All (xi,yi) will fit in a 32-bit signed integer   >  ...


New senior developer tasks

I've got a senior developer with eight years of .NET experience starting tomorrow to work on a 11,000-lines-of-code application. In the team there's myself and another programmer. We've both got about three years experience each. It's my first project as a manager (I'm also a developer on the project) and this is the first time I've ever had to introduce someone to an already established code base. Obviously I'll be going over each module, the deployment process, etc., and handing them the location of the source control repository, documentation (which isn't the best), etc. How long should I give them before they're ready to start writing new features and fixing bugs?


Why store a function inside a python dictionary?

I'm a python beginner, and I just learned a technique involving dictionaries and functions. The syntax is easy and it seems like a trivial thing, but my python senses are tingling. Something tells me this is a deep and very pythonic concept and I'm not quite grasping its importance. **Can someone put a name to this technique and explain how/why it's useful?** * * * The technique is when you have a python dictionary and a function that you intend to use on it. You insert an extra element into the dict, whose value is the name of the function. When you're ready to call the function you issue the call _indirectly_ by referring to the dict element, not the function by name. The example I'm working from is from Learn Python the Hard Way, 2nd Ed. (This is the version available when you sign up through Udemy.com; sadly the live free HTML version is currently Ed 3, and no longer includes this example). To paraphrase:               # make a dictionary of US states and major cities     cities = {'CA':'San Diego', 'NY':'New York', 'MI':'Detroit'}          # define a function to use on such a dictionary     def find_city (map, city):         # does something, returns some value         if city in map:             return map[city]         else:             return "Not found"          # then add a final dict element that refers to the function     cities['_found'] = find_city      Then the following expressions are equivalent. You can call the function directly, or by referencing the dict element whose value is the function.               >>> find_city (cities, 'New York')     NY          >>> cities['_found'](cities, 'New York')     NY      Can someone explain what language feature this is, and maybe where it comes to play in "real" programming? This toy exercise was enough to teach me the syntax, but didn't take me all the way there.


How should I represent an enumerated type in a relational database?

I am working on developing a relational database that tracks transactions that occur on a device I'm working on for my company. There are different types of transactions that could occur on the device, so we have a "trans_type" field in one of our main record tables. My group has decided to make the type of this field an integer and treating it as an enumerated type. My intuition tells me that it would be a better idea to make this field a string so that our database data would be more readable and usable. My co-workers seem to be worried that this would cause more trouble than it is worth. That string comparisons are too costly and the possibility of typos is too great of a barrier. So, in your opinion, when dealing with a field in a relational database that is essentially an enumerated value, is it a better design decision to make this field an integer or a string? Or is there some other alternative I've overlooked? Note: explicit enumerated types are not supported by the database we are using. And the software we are developing that will interface with this database is written in C++.


When programmers talk about "data structures", what are they referring to?

When programmers talk about "data structures", are they only talking about abstract data types like lists, trees, hashes, graphs, etc.? Or does that term include any structure that holds data, such as composite types (class objects, structs, enums, etc.) and primitive types (boolean, int, char, etc.)? I've only ever heard programmers use the term to reference complex data structures or abstract data types, however the Wikipedia article that provides a list of data structures includes both composite types and primitive types in the definition, which is not what I expected (even though it does make sense). When looking around online I see other places that refer to the term "data structure" in the programming sense as only referring to abstract data types, such as this lecture from Stony Brook University's Department of Computer Science which states > A data structure is an actual implementation of a particular abstract data > type. or this wikibook on data structures, which uses the term in sentences like this: > Because data structures are higher-level abstractions, they present to us > operations on groups of data, such as adding an item to a list, or looking > up the highest-priority item in a queue So why do I only ever hear programmers referring to complex data structures or abstract data types when they use the term "data structure"? Do programmers have a different definition for the term than the dictionary definition?


How does database connection pooling improve application performance?

I can't understand why connection pooling improves application performance. I suppose connection establishment would cause latency. But reusing an established connection requires more complex error handling. Application server need track state of every connection to set connection to initial state before reusing (such as discarding all transactions, switching to the default isolation level), which also costs time.


Why doesn't Git daemon start in the background?

Just as in the title, why doesn't `git daemon` start the service in the background, since it's a "daemon", being a background process? I know that I can start it in the background using `git daemon &`, but I'm just wondering about the philosophical reason for this decision.


Is recursive code slower than non-recursive code?

Now I'm only a novice programmer, but what my friends that are studying programming tell me is that recursive code is a good thing, it leads to less code duplication and it looks more elegant. Now it may be so, but everytime I've tried my hand with recursive code I've always found it to be significantly slower than non-recursive code, I'm not sure if it's something about the ways I've used it but I highly doubt it, I've used it for fairly simply thing's like Collatz Conjecture and Fibonacci number generation but whenever I've compared it against normal iterative code the recursive approach will consistently clock at around twice the time of the iterative solutions.


Organizing large Javascript applications - The view layer

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


Using lookahead assertions in regular expressions

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


Python simulation-scripts architecture

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


Designing controller for modular Java architecture

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


what does composition example vs aggregation

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


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

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


Pointer access and cache coherency

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


Relevance of search results

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


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

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


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

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


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

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


Does Microsoft really offer "support"?

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


Pythonic version of Java interfaces

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


My coworker created a 96 columns SQL table

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


How a freelancer can learn industry standards?

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


Apple eating problem

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


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

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


Sell a web app with limit per client?

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


Pragma Mark in Cocoa

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


Can a freelancer use agile development?

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


GPL copyright notice

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


Cpu-heavy web server

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


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

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


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

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


Why doesn't Python need a compiler?

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


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

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


Duck typing, data validation and assertive programming in Python

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


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

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