instruction stringlengths 34 19.9k |
|---|
I'm developing some code that utilizes generics, and one of my guiding principles was to make it usable for future scenarios, and not just today's. However, several coworkers have expressed that I may have traded off readability for the sake of extensibility. I wanted to gather some feedback about possible ways to reso... |
When you look at the code for the Winforms Designer, you see things like this:
this.label1.Font = new System.Drawing.Font("Microsoft Sans Serif", ... etc.
instead of
using System.Drawing;
label1.Font = new Font("Microsoft Sans Serif", ... etc.
The same is true of tools like Linq to XSD, XSD2Code and, I suspect, of Li... |
After having had endless issues with INI-style configuration files and parsing them correctly (let along getting binary data right), a crazy idea crossed my mind recently:
What if an INI file like
# settings.ini
[Windows]
DirectorySeparator='\\'
PathSeparator=';'
[Linux]
DirectorySeparator='/'
PathSeparator=':'
Would... |
My coworker who is a senior guy is blocking me on a code review because he wants me to name a method 'PerformSqlClient216147Workaround' because it's a workaround for some defect ###. Now, my method name proposal is something like PerformRightExpressionCast which tends to describe what the method actually does. His argu... |
The global interpreter lock (GIL) seems to be often cited as a major reason why threading and the like is a touch tricky in Python - which raises the question "Why was that done in the first place?"
Being Not A Programmer, I've got no clue why that might be - what was the logic behind putting in the GIL?
|
My company wants to purchase new software for our General Ledger. We want to be able to interface it with various other sytems, all purchased. Nothing is custom built. The software our Accountants like does not have any APIs. However it does allow for imports and exports through various file formats.
The imports (... |
I'm the only software developer maintaining a subset of products at a small company. The main product I'm concerned with here is a web app which is installed on various clients' machines, with a database and background processes.
I make changes on a need-to basis for this program. It's not the company's flagship produc... |
Say I have a function.
function foo(){
//do stuff
}
And then I create an object of that function.
var fooObj = new foo();
What is fooObj called? An instance, An object instance, or something else entirely? Pardon the newbie question, but I am rather new to prototype based programming(and all programming really).
|
I am refactoring a large codebase where most of the classes are located in one package. For better modularity, I am creating subpackages for each functionality.
I remember learning somewhere that a package dependency graph should not have loops, but I don't know how to solve the following problem: Figure is in package... |
A page built so that is has server side scripts implemented on the page.
Should indentation of the code be according to the server side logic (making it easier to read while coding) or according to the HTML/ASP.NET markup (making it easier to read while debugging etc.)?
|
I have following piece of code:
int sum = 0;
for (int i = 1; i <= N; i++)
for (int j = 1; j <= N; j++)
for (int k = 1; k <= N; k = k*2)
for (int h = 1; h <= k; h++)
sum++;
So I'v calculated how much does each cycle executes and then whole script, and I think I might be wrong for... |
I'm currently in the middle of refactoring an important method in a legacy-system. There were almost zero test until I've started working on it, and I've added quite a lot to ensure the correct work after my refactorings.
Now I've came across the most crucial part: the algorithm that calculates an indicator. It's some... |
There are instances which cane be seen while testing the application, both by developers and testers, some NullPointerExceptions arriving while clicking on a node in the table, or while doing an action too fast or under a zillion test-cases which do not come under the Test Cases document used in testing the application... |
I have started to separate my unit tests from my integration tests by using Maven Surefire and Failsafe.
Now I'm wondering what good ways there are to deal with separate environments. Take for example these two integration tests scenarios:
Given a customer id, can I get a list of orders belonging to that customer.
Giv... |
I am working on a Selenium + java project where all Web Element in a class are declared as -
public class CheckoutPaymentConfirmpage extends WebPage{
public final Button btnPrintorder = new Button("//input[@id='but_Print']");
public final TextField txtpassword = new TextField("password", "//input[@id='pass']");
... |
We have developed one product for payroll processing. We have 10+ customers who are using this software product.
Our existing and new customers are giving us customization changes w.r.t. their needs, and now we are facing the problem of product management. Please give some guidelines to us.
How to manage single softwar... |
I was reading up on data structures from Code Complete. This is when I stumbled through this piece about arrays:
Think of arrays as sequential structures Some of the brightest people in computer science have suggested that arrays never be
accessed randomly, but only sequentially (Mills and Linger 1986).
Their argu... |
I have been having a debate about what to do with a trailing slash in a RESTful API.
Lets say I have a resource called dogs and subordinate resources for individual dogs. We can therefore do the following:
GET/PUT/POST/DELETE http://example.com/dogs
GET/PUT/POST/DELETE http://example.com/dogs/{id}
But what do we do wi... |
I was reading this blog post: http://kjellkod.wordpress.com/2012/02/25/why-you-should-never-ever-ever-use-linked-list-in-your-code-again/
and I found there a code to run: http://ideone.com/62Emz
I've compiled it using gcc 4.7.2 with g++ -std=c++11 on my old laptop with T5450 cpu with two cores with 32 Kbytes L1 cache e... |
I'd like to know if it's possible to detect the delete error commented below at compile time? Especially, I'd like to hear about g++ compiler.
ClassTypeA *abc_ptr = new ClassTypeA[100];
abc_ptr[10].data_ = 1;
delete abc_ptr; // error, should be delete []
|
I think I can count WebAPI out, but WebForms, WebPages, and MVC are all possibilities.
I want to create an asp.net web site that is primarily static content and links to other sites. The only "fancy" bit will be a Bing map with pushpins that I add - but even these are static. And there will be a photo gallery. Oh, and... |
I want to do the following:
I have a number of computers. On each computer a programm will run. There is no centralized server.
The program can choose by defined criteria to give another computer specified data. While doing so, the other computer should not do the same. (A sort of 2 way synchronize)
Let's make an examp... |
I am making a simplistic in-browser IDE for some very domain-specific coding. Because I like Bret Victor's thoughts on Learnable Programming so much I thought I'd throw in some draggable numbers ala Tangle.js (click here to see what I'm talking about).
My implementation is a much simpler slider input control but the i... |
Use cases are primarily meant for interaction between user and a system. It could be used for interaction between system and another system. The actors are primarily roles.
It is easy to document the use cases for a front end application like a portal where in all the activities and role performing the activity could ... |
I have a scenario where a specific webservice must be consumed based on the state to setup user info. For instance if the state is NY or NJ call service A , if state is WA call service B etc. But specifying what service must be called is I guess is "HOW" to setup a user info and not a "WHAT".
So should I just have sing... |
I have a single page application where everything in the UI is javascript driven so any operation requiring data or updating of data is done via Ajax requests. The way things are setup right now is that my Ajax called are made to one ajax.php file which takes care of routing them to the proper service method. This work... |
I have something like this:
public byte[] EncodeMyObject(MyObject obj)
I've been unit testing like this:
byte[] expectedResults = new byte[3]{ 0x01, 0x02, 0xFF };
Assert.IsEqual(expectedResults, EncodeMyObject(myObject));
EDIT: The two ways I've seen proposed are:
1) Using hardcoded expected values, like the above ex... |
This can apply to many error handling scenarios, but I'm curious about how to do it in a login scenario.
Given this Spring controller method:
@RequestMapping(value = "/account/login", method = RequestMethod.POST)
public String login(@RequestParam("username") String aUsername,
@RequestParam("password") String aP... |
I'm writing a simple chess-related code with intention to write it clearly (performance doesn't matter at all). And this method I have doesn't look clean to me at all:
public static Piece GetClosestPiece(Square squareFrom, Direction direction)
{
//TODO: rework this mess
switch (direction)
{... |
I thought of asking on SO, but it seems this is more of a "concept" type question than a "problem" type question. If it needs to be moved, please do so.
Anyway, I'm having a tough time finding straight info on this. I'm using Unity.Mvc3 to setup dependency injection for controllers and other components the controllers ... |
Friend asked me to develop a software application for him. I did and he paid me.
There was no written contract. I live in UK and he resides in Canada.
My question is: who is the owner of the software now?
Can my friend make and sell copies without my permission? Can I do the same?
I'm asking this because another person... |
I played a bit with WebSockets and started to implement a tiny chat. Last time I did something like this was when there was no such thing as threads and computers had single core. I started to think how to implement it with todays programming patterns but I didn't come to any final conclusion.
How you implement chat's ... |
How can one become better at debugging in general? I do not mean specific tools or tactics that apply to a certain programming language or stack, but simply how to make your mind better at it, hopefully something beyond "just more exercise".
I am fairly good at "blank sheet" type programming problems: I can easily code... |
I remember that in our first programming class with Java, while explaining data types, the following occurred (kinda):
Professor: So, what data type would you choose if your program needs
to store the user's gender?
Someone: How about a boolean? You know, true for male and false for
female.
Professor: Sure, that m... |
We have a system whereby the database connection is get once using a common method, and being pass throughout the relevant class to be used. There are doubts that passing the database connection as a parameter to different classes would cause problem, so i'm checking here to see whether this is actually viable, and are... |
There isn't any cool LINQ sugar for creating unions. The Enumerable.Union() method is usually called like this:
var bigList = list1.Union(list2);
The alternative is to call Enumerable.Union() which can be more readable:
var bigList = Enumerable.Union(list1, list2);
However neither of these methods are very stylish (m... |
I'm a student and I work as an undergrad in an IT department. They are very effective programmers, but as far as documenting what they do and tracking what time is spent on specific tasks - not so much.
I was put in charge of setting up project management software. So far, I've created a satisfactory solution with Tra... |
I have recently been looking at some testscripts which looks a bit like
...
try {
receiveSomething();
// something was received even though it shouldn't
failTest();
} catch (TimeoutException e) {
// nothing should be received
succedTest();
}
The problem I have with these types of tests is
They are not deter... |
I have a bulk emailing service within the system which allows for a template to be used. When the mail is sent the template is parsed or run through a parser to replace tags with actual information. i.e "[Foo] has logged in" is parsed to "Bar has logged in"
Is it better to have 1 service for sending and parsing emails ... |
The main difference between themes/skins and CSS are the HTML & Server Side Controls (SSC) only. We use skin files to format & cosmetics SSC which are not in HTML like <asp:Label>, <asp:TextBox> & </asp:RadioButtonList> etc...
But what if we use the rendered HTML SSC in CSS instead skin files to handle <asp:Label> & <a... |
I have been reading DDD Quickly and wondered about how to avoid naming clashes with technical terms and domain terms. For example, if I commonly used the repository pattern (with classes such as AddressRepository), but a customer also has something called a repository in their domain. How would I best avoid confusing t... |
I've just read two statements that seem to be very different:
Des Weiteren ist mangelnde Kommunikation zwischen Programmierern und Nutzern eine nicht zu vernachlässigende Quelle von unzureichenden Produkten.
Translated:
A lack of communication between programmers and users is a source of poor [software] products.
Sou... |
I was always under the assumption that trial softwares write a registry value of the installation date and then the software makes a comparison of the current date of the system with the remaining days + installation date to verify whether the trial period is still valid or not. If this assumption is to be true, windin... |
I was assigned to fix some issues in a PHP project. Later on, I was asked to implement some new features, which I did. The project neither uses any framework nor does it use OOP. It lacks a proper structure, except for the use of folders (no sub-folders) to organize files. There was no documentation created by the or... |
I think my book (Programming Languages: Principles and Paradigms) is wrong. a is a vector, assume a C-like language:
b = 0;
a[f(3)] = a[f(3)] + 1;
int f(int n) {
if(b == 0) {
b = 1;
return 1;
}
else return 2;
}
It has the effect of assigning the value of a[1] + 1 to a[2] whenever
the e... |
Basically we now have 2 developers for an iOS project, 2 developers for an Android project and 1 designer doing designs for both projects.
Right now, the way we exchange designs and images is through mail...so not very advanced or efficient. We're switching to Dropbox, but I feel like we could go a step further and som... |
TODO indicates "task to be completed", FIXME to be fixed etc. Is there a code tag to indicate "need improvement" on code comments?
|
So, I work in .Net. I make open source projects in .Net. One of my biggest problems with it isn't necessariyl with .Net, but with the community and frameworks around it. It seems everywhere that magical naming schemes and strings is treated as the best way to do everything. Bold statement, but look at it:
ASP.Net MVC:... |
I'm wondering what is better in terms of good OOP desing, clean code, flexibility and avoiding code smells in the future. Image situation, where you have a lot of very similar objects you need to represent as classes. These classes are without any specific functionality, just data classes and are different just by name... |
When thinking about testability and modular code, I recently thought about whether I should split out the synchronization part of a class from the actual behavior part.
By example:
The app "needs" this:
class Mogrifier { // Mogrifier accesses are thread safe
private:
unsigned int m_state;
mutex m_sync;
public:
Mo... |
I currently have the following models and am designing search functionality that searches within these 3 models:
Locations
Users
User_friends
Should I create a search controller or should I put the action in one of the existing locations, users, or user_friends controllers? If so should it be pluralized - searches_con... |
We manage a range of client sites built in Wordpress and Joomla and these require regular updates to the core CMS and extensions. We keep these sites in subversion and place updates in subversion. We try to use a single revision for this.
We face some difficulties in making this process efficient, over time we would li... |
Under which application development scenarios C# dynamics and ExpandoObject can be used or when to consider using c# dynamics and ExpandoObject
|
I would like to develop a bit of functionality for a web site that involves a bit of 3D - the user can move around objects, rotate them and texture them.
So far I've looked into:
WebGL (in particular three.js) and it looks great, but it's not supported in IE nor IOS.
IOS supports the <canvas> tag, but only 2d. It loo... |
if(true/false){
//if condition is true
}else {
// if condition is false
}
Everyone knows about the structure of if-else. But what is if actually? Is it a class method, static method or keyword? I'm little confused about this.
|
I have a client that asked me to develop his Windows Application and use MS Access instead of SQL database. I did and now he asked me that he deployed the Application through several of his offices.
Now he wished to have a "main Server" with all information from the "client applications" for Reporting purposes and also... |
On my filesystem (Windows 7) I have some text files (These are SQL script files, if that matters).
When opened with Notepad++, in the "Encoding" menu some of them are reported to have an encoding of "UCS-2 Little Endian" and some of "UTF-8 without BOM".
What is the difference here? They all seem to be perfectly valid s... |
I'm currently designing a search algorithm for a document, and just got curious about this while designing the algorithm: how do web browsers search a webpage?
For example, in Google Chrome, you can press the keyboard shortcut Ctrl-F to activate the "Find" bar, which will let you search a particular webpage for text. H... |
There are instances where the references to objects, fields, variables etc can be null and there might be a possible occurrence of Null Pointer exception occurring at that point.
Is is a permanent solution to put these code blocks which expect Null ponter exception to be put in a try catch block?
|
In environments where software is built internally by one team and then that software is used by other internal teams, how does one decide what the required quality should be for the produced artefacts? For example:
documentation completeness and accuracy
extensibility/re-usability of artefact (without hacking at sou... |
I'm developing a system which involves 2 Android applications and a Java web application. For my UML class diagrams I have not included third party classes I use e.g. observer type interfaces. Should I include them? If so how can I differentiate between my entities (classes, interfaces, enums etc) and their entities? T... |
For example I have a utility Class which contains a few constants (GCMConstants), this class is used in one method in the application. However as it is not a member of the Class it should not be modeled via an association link. Should I continue as is and not include a link or should I include one?
I've checked my UML ... |
I'm wondering if there is some license which I could put on my website on which I could publish an open-source application that potentially could be used for purposes of cheating in one game for smartphones.
Now, I have to stress that the goal of the application is in no way cheating, so with this license I want to eli... |
I am thinking of managing a product source I am doing using Codeigniter + HMVC.
Right now my folder structure is something like this:
application
|-modules
|-module1
| |--controllers
| |--models
| |--views
|-module2
| |--controllers
| |--models
| |--views
assets
... |
I was reading an article about functional programming where the writer states
(take 25 (squares-of (integers)))
Notice that it has no variables. Indeed, it has nothing more than three functions and one constant. Try writing the squares of integers in Java without using a variable. Oh, there’s probably a way to do it,... |
(Originally asked on StackOverflow - https://stackoverflow.com/questions/14896121/what-is-a-practical-level-of-abstraction-in-a-web-application)
I still consider myself a newcomer to OO programming, especially in php, so forgive me if I have missed some fundamental principle!
Say I have an intranet application with a s... |
Due to test-driven development, one ends up with many classes doing just one thing. It is quite a headache just to see where such classes would be placed inside the folder structure.
First of all, is it considered a bad-pattern, to put related classes in the same file?
Any suggestion on what one uses in actual-produc... |
Writing code that will still run years from now
Programming languages change.
Libraries change.
Some code from 5, 10, or even 20 years ago might still run and produce expected results, whereas some code from 2 years might fail with a syntax error.
This is partly inevitable, since languages evolve (at least, most do).
D... |
I'm starting a project that will have a web front end for the users coupled with a database. There will then be a stand-alone service running that will, on a specified interval, poll an API and update the database with the changes it found.
What I need advice on is how the service should be setup. When a user creates a... |
I am working on a text editor in javascript. I have created the front end and i need to prototype a backend. I need to model the structure of the document using this as hierarchy:
Character
, Word
, Tag
, Document
I am trying to create objects based on this hierarchy.
For example:
Characters are represented a linke... |
I am working on sorting out my Javascript code. Currently I have views implemented without any Model or collection. Now I working on separating Model from View. So for this transformation, I am planning as follows:
View ---> X <--- | ---> Server
< Client side >
Assumptions:
View will not have a... |
I work for an insurance company. They have a contact database that gets pushed to the field agents by Lotus Notes. We're trying to move away from Lotus Notes, but we first have to remove our dependency on it.
It has been suggested that a HTML5 solution could provide offline access to agent contacts and be used to sync ... |
I changed from PHP to ASP.NET, now I’m working with webforms in a somewhat large company. I given some though and research to back my impressions on ASP.NET webforms and I came to the conclusion that Webforms is an attempt to make web applications easier to write for those who came from the "desktop programming" world... |
I have an interesting problem for you all. I have a partial solution but I feel you guys can come up with an efficient solution.
What I have a SQL table with following structure:
StockId <- a unique ID for the share
StockHolderId <- a unique ID for the share holder
StockPrice <- The price of the stock - if this is a r... |
If I wanted to implement my own version of the std::exception for no good reason, are there any special things about implementing this kind of object that I should be aware of? It seems like a fairly simple thing that is mostly a string wrapper...
Here is my implementation so far:
#pragma once;
#include <string>
clas... |
I have a remote procedure call API where the connection parameters need to be stored somewhere that the API code can access. This API is expected to be used mainly to create web services.
I originally planed to store these parameters in a separate xml file, and require users of the API to define the path to that file ... |
i have a scenario where i have to make available a document for viewing and editing to multiple users, the users can edit and view the document at the same time. Now the problem arises here if for example user A and user B are viewing a document at the same time and if both the user change the state of the document and... |
I have been working on a project for several months now to write a web-based tool that will help me at work. I work at a call center and the CRM software that is used is wretched, we basically have to input all of our information into notepad templates and then paste it in to a description box.
My initial goal was to c... |
I am really confused.
The GPL states that if you start with GPL code, and modify that code, that you must release your code with modifications free of charge also under a GPL.
But what if you simply use the existing GPL code without modifications as a library? Can you then write software to interface with that code, un... |
I have developed a protocol for a Client-Server application and developed it in conjunction with another developer. The client application at this moment is written for the mobile phone.
The protocol uses comma separated fields with start and end deliminators. Because some of our fields are free form ASCII text we ... |
In the O'Reilly book on Scala, I read that copy-pasting of code creates:
... creates issues of code-bloat, maintainability and skew,
I can't see any obvious definitions of the word skew in context. I am aware of the problems of copy-pasting, but I can't make them fit with the word 'skew'. Since this is used in an O'R... |
I see now that Racket has types. At first glance it seems to be almost identical to Haskell typing. But is Lisp's CLOS covering some of the space Haskell types cover? Creating a very strict Haskell type and an object in any OO language seems vaguely similar. It's just that I've drunk some of the Haskell kool-aid and I'... |
Today I feel like I finally grokked currying (in Javascript), and of course, like any programmer who has learned a new trick, my mind immediately began racing over how to improve my current codebase using it.
And again, like any programmer, the little voice shouting "[new trick] all the things!" was silenced by another... |
I'm trying to implement a modified version of the Lamport Mutual Exclusion algorithm. The original algorithm assumes FIFO message ordering between connected systems, but I would like to use UDP a protocol which does not guarantee FIFO. Is it possible to modify this algorithm to work without FIFO?
EDIT: Forget UDP. Just... |
Disclaimer: If you're not into parallelization (on clusters), this question is probably not interesting to you and probably not worth a read.
TL;DR: I search for a communication model (preferably compatible with MPI) that efficiently assures that each data line is processed once. Read the next paragraph as well to know... |
In Python (and occasionally PHP) where variables do not have fixed types, I'll frequently perform 'type transformations' on a variable part-way through my code's logic. I'm not (necessarily) talking about simple casts, but about functions that change the type of a variable while leaving it basically representing the sa... |
Currently I'm using something like a master-cron server, which starts the tasks on the slave-worker servers.
But there are so many tasks, that the timing gets lost entirely.
Is there a an algorithm, which eliminates the single master?
|
Given an input device (basically a keyboard) that reports keyup and keydown, how may I most efficiently store and retrieve information about which keys are currently depressed? My first thought was a dynamic array, but maintaining and searching a dynamic array seems like a serious drain on resources.
Many thanks in adv... |
My needs are very simple but I don't know the terms I should be Googling for: I need to occasionally send a SMS to a machine and that machine is going to answer with another SMS to the number that did send the first SMS.
I've got no say as to how that machine works: it's closed and all it does is receive SMS and send S... |
I'm trying to learn some best practices while I ramp up on MVC4. I have a solution with three projects:
Web: MVC stuff
Core: Data Model
Tests: Testing classes
I'm now trying to add:
Services: Business Logic
This will take logic such as "GetFilteredItems()" from my controllers and place them into a Service project, ... |
I don't have any experience working as a programmer - I just code as a hobby so far. Some years ago, I heard a programmer say that I should focus on making my code just work despite being slow (it was for a game, so it was more noticeable if my code was slow or not) and then I would spend my time improving it to make i... |
I'm trying to understand the strategy pattern and asking myself: is the context class must-have or can I leave it out without compromising pattern's purpose ?
I was under the impression I needed some kind of switch for reading different types of files but didn't want to just hack something and later deal with refactori... |
I recently heard of an interview question:
Given a string and a dictionary. Break the string into meaningful words
and I remember solving this before with dynamic programming fairly quickly (maybe O(n) time? ) in one of my old algorithm classes but I can not remember the name of the algorithm. Could someone point me ... |
I am in the early stages of planning for an input device which will consist of some as-yet-to-be determined number pf physical controls. From previous experience with such devices I have found that it would be extremely advantageous to have the device return data about the state of all controls in response to a query f... |
What is controller layer and where we put this in our 3-tier architecture?
1)UI
2)Business Logic Layer
3)Data Access Layer
I search in net but unable to get exact ans.Any links or sample example helps to understand better.Thanks.
|
I have always been using this method:
from sys import argv
and use argv with just argv. But there is a convention of using this:
import sys
and using the argv by sys.argv
The second method makes the code self documented and I (really) adhere to it. But the reason I prefer first method is it is fast because we are imp... |
I don't understand why Fibonacci heaps have marked nodes (picture).
A node is marked when its child is deleted. Quoting from Wikipedia: "[Keeping degree of each node low] is achieved by the rule that we can cut at most one child of each non-root node. When a second child is cut, the node itself needs to be cut from its... |
I have project written in C++ that I am working on which has a parent-child relationship where each child has only one parent. I had previously decided after looking at this post that I would make the children know nothing of their parents.
A little background on my project before I go into my question: The parents in ... |
In my code (Python+numpy or Matlab, but issue can apply to any array programming language), I often need to count the number of elements in an array where the elements are true. Usually, I implement this as sum(x>0.5), but this may be considered improper. See Is it correct to add booleans in order to count the number o... |
I've come across a recurring issue in a few of my recent projects in which I find myself using enums to represent state, or type, or something else, and I need to check against a few conditions. Some of these conditions span multiple enums, so I end up with a load of logic in switch and if blocks, which I don't like. T... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.