instruction stringlengths 34 19.9k |
|---|
I'm developing a complex environment which involves a web application, a mobile app and a real time middleware system which accesses the DB for on-site tag readings. Currently, the web application exposes some services over a REST API, which are accessed by the mobile app to let it perform its business work (in this ca... |
Normally semaphores are implemented as integer variables. The value of a semaphore represents initially the number of processes that are allowed to access the shared resource at the same time, which means one single semaphore is enough for regulating the access to one shared resource. But I have seen a lot of concurren... |
In my opinion it just inverses the inversion and could make new users (including myself) make incorrect assumptions about using IoC containers.
It can be used for the Service Locator (anti-)pattern of course, but it doesn't sound like a strong reason to me (can be a separate class in the end of the day).
There probably... |
Most of the time, when I comment a method, I'll follow this structure.
/**
* Short description of what the method does
*
* @param {Type} name. Description of the variable.
*
* @return {Type}. What the return is.
*/
Now if I have a method called uploadData, which takes one parameter, data, is it still necessary t... |
I'm currently reading Robert Martin's Clean Code book. So far I'm enjoying it.
Martin talks a lot about separating long functions into short functions, each doing exactly one thing at one level of abstraction.
Generally I like the idea and I understand the concept and the benefits. But I have a simple question to ask:
... |
Can anyone describe to me what Onshore / Offshore team is and what Onshore / Offshore testing is? Because i am studying this article and I can't find anywhere the specific meanings about the above phrases.
|
I was thinking of using Angular UI, and specifically its $StateProvider, which makes it easy to create nested views, in my next application. Until now, I have been using vanilla Angular's ngInclude directive with a URL as a variable passed in from some controller. This is easy enough, but, as you can imagine, it can ge... |
We have a program that combines the simulation of an aircraft system and predefined pedagogical scenarios for trainee pilots to learn how to use this system.
When we follow the normal scenario, chapter after chapter, everything goes smoothly.
Now, when the trainee skips the chapter N and goes directly to the chapter N+... |
I have a following class
class Student{
int rollNumber;
int marks;
public void setResult(int rollNumber, int marks){
this.rollNumber=rollNumber;
this.marks=marks;
}
public void displayResult(){
System.out.println("Roll Number= "+this.rollNumber+" Marks= "+this.marks);
}
}
Now I create two object... |
I'm looking for a way to synchronize a users database between a piece of software and a ldap directory. Currently I'm thinking of three possibilities to keep the track of a specific user :
Guid : it seems to be AD-specific but I guess other directories have an equivalent unique identifier. I can use a LDAP query (&(ob... |
After developing several Haskell applications I've found myself rigorously segregating impure code and failable (partial) functions from their pure & total counterparts. These efforts have noticeably reduced maintenance cost associated with the applications. I have found myself over time relying on the same high level ... |
I think pair programming can be incredibly effective, and I don't mind doing it every now and then, but a company I've interviewed with states they pair program "95% of the time" (they're a consulting shop, so they do this on client sites).
This worries me because it sounds very demanding/exhausting. I realize it incre... |
I am working on a WCF application that supports 4 different applications.
lets call those 4 application: App1, App2, App3, and App4.
this WCF Application has 4 services. one for each application. 4 services are very similar, thats why I want to combine them together into 1 wcf application. Here's the problem, if I ne... |
What is the purpose of IOC Containers? The combined reasons for it can be simplified to the following:
When using OOP/SOLID Development principles, Dependency Injection gets messy. Either you have the top-level entry points managing dependencies for multiple levels below themselves and passing dependencies recursivel... |
Trying to clear my HTML code, is it correct if in my web page I declare many blocks of <script> .
Like this:
<script type="text/javascript">
...
...
</script>
<script type="text/javascript">
...
...
</script>
<script type="text/javascript">
...
...
</script>
I mean, I do this in order to group jquery ... |
For my current project, I need to create a database table to store a recursive association. I've done a lot of searching and have read answers on questions, such as Naming convention for associative entity and How do you name your many-to-many relationship tables?, but they don't discuss the case of a recursive relati... |
I apologize if this seems like yet another repeat of the question, but every time I find an article regarding the topic, it mostly just talks about what DI is. So, I get DI, but I'm trying to understand the need for an IoC container, which everyone seems to be getting into. Is the point of an IoC container really just ... |
I'm looking for a way to store a large quantity of individual data values, with the following constraints.
Assume that the types are bool, int32, double, decimal, string and blob (byte array).
The type of each value will not be known at compile time (but the set of possible types is).
The type of each value will be k... |
I am new to python and functional/integration tests as a whole. I know how to write unit tests, but in this case i do not need isolation for specific functions, rather i need my python script to be run with some command line parameters and then tested for output(for example if the program is successful, a specific REST... |
This is my solution's structure:
Storage.csproj
> FileDownloader.cs
> GitHubProvider.cs (implements IStorageProvider)
> IStorageProvider.cs
Storage.Test.csproj
> FileDownloaderFixture.cs
The idea is that I can use the class FileDownloader, inject it with a IStorageProvider, call myFileDownloader.Download(... |
I'm trying to improve another abstraction of the serial port. The project involved often needs to check one of the single control signals CTS and DSR. This is currently done by a call to GetCommModemStatus, that's very wordy: a variable is needed and a binary AND operation, GetComModemStatus can also fail (this is more... |
CRUD operations, by definition are...
interfaces that permit users to create, remove, modify or retrieve data
Implementations of CRUD interfaces can come in various shapes and sometimes they are even extended to SCRUD. What most CRUD interfaces have in common is that they refer to all major functions of e.g. a relati... |
Having recently discovered python, I attempted to write a simple logger. Data is read from a device, processes, displayed and stored on disc. Those different tasks belong to different modules, of course.
What appeared to be cool at the time, was to provide command-line interface to each module, as explained here: https... |
I am a web developer and I am wondering if I should put my company's name in the footer of my client's websites.
I am doing this since I began and never had anyone asking if I would remove it. So I saw no problem, until...
on Webmasters.SE I saw someone saying that 'only amateuristic web developers put their company na... |
The content below is from the Android developer site:
According to the phrase it is expecting the developer to store this info in his head. Shouldn't this be simple if they kept only setDataAndType and let user to set both, either or none, in which we don't have to remember this caveat since it is taken care by desi... |
Suppose I have a class that evaluates some computationally intensive function:
class Value
{
private:
int eval()
{
mCached = ExpensiveOperation();
return mCached;
}
static int mCached;
};
Now suppose that Value is actually some template expression, like Plus<1, Multiply<2, 3>> or something to that effe... |
When an SSL certificate is installed on a website, but the page also calls content from another website without an SSL certificate, the SSL certificate icon will turn grey instead of green:
instead of:
Their site Google Images is also protected with an SSL certificate, but it stays green:
even though they call conte... |
I'm new to HMVC and whilst tutorials are great about dealing with the overall details of keeping modules separate and only letting controllers communicate, they aren't so great at explaining the little details of what should go where.
This is an example I'm currently faced with. I'm using Kohana as my framework, and bu... |
I am trying to design a managed library to implement -what appear to be- unmanaged VST3 plugins. The VST3 plugin interface is a C/C++ interface-based API that is compatible with COM (ref-counting, HRESULT etc.) - but is not COM (no reg, CLSID etc). The entry point into the plugin is an exported (on windows) function th... |
I had a strange-feeling pattern come up in some code I was writing. In a project with user accounts, there was a lot of code that needed to do common things such as creating accounts, deleting them, logging them in and out, extending their logged-in session, etc. etc. etc. Now when I was first writing this, I just thre... |
When designing an interface for passing objects which are meant to be stored for later use and which should not be 'null', I am always a bit uncertain if the argument should be passed by reference or as a pointer.
This is an example of what I mean:
class Foo
{
private:
Bar* m_bar;
public:
Foo() : m_bar(nullptr... |
Most of it was written 4-5 years ago. Our teams long term objectives are to use Entity Framework. Though we aren't gonna do it right away as our deadlines aren't allowing us to do so.
Now we have our own framework. I want to be able to segregate the Business logic layer in such a way that it need not be re-written whe... |
By reading the traditional Taligent paper, I can't find a definite answer to what they mean by Selection. The selection could be just a set of indices referring to entries in the Model, so that a Command can act on the proper Model subset, but what is not clear from the Paper is how they represent this selection in the... |
Is there any situation where it makes sense to define a python property, where getting (not setting) it would raise an exception? I don't think this ever happens for fields in classes, hence the question.
Or is always better in these cases to use a method instead?
|
When using depending injection, you generally pass everything around as an interface (perhaps with the exception of primitives and strings). That allows you to easily chance the behavior, without changing the implementation.
Is there ever a case where I should not be passing some complex object through an interface tho... |
I have what I would call a philosophical question about λ-calculus.
When you explore λ-calculus you will be surprised to see all the things that you can do there. You can define integers, arithmetic operations, booleans, if-then-else statements, loops, recursive functions, etc. I believe it has been proven computatio... |
The context
I'm modeling a database for a small ERP system. However I've recently hit a difficult spot that I'm having a hard time wrapping my head around. The logic of it involves a few special cases, I'm hoping someone with DB design background might help (this is my first large DB model project).
Contact is a table... |
I am considering using a class hierarchy with more than a single level of inheritance, where virtual member functions form a "chain", for example:
struct Base
{ virtual void foo(); };
struct D1 : Base
{ virtual void foo(); };
struct D2 : D1
{ void foo(); };
However I would like to know before using similar code in p... |
I am creating a data serialization/deserialization mechanism for essentially a persistent storage object. Due to the variety of systems this mechanism could run on, there needs to be a a variable number of "drivers" that could be used to serialize or deserialize the data.
I am having trouble figuring out the appropriat... |
My goal is to build a command parser that has basic syntax and multiple possible branches at each point. These commands come from users of the system and are text input (no GUI). The basic syntax is base_command [sub_command [optional_parameters]], where optional_parameters is a space seperated list of parameters.
Exam... |
If you've ever made a custom email you'll know that there are significant limitations in you need to be aware of.
The most obvious limitations being:
No support for Javascript in emails
No support for internal CSS (CSS placed in the HTML file header). Its rather understandable that external CSS is still not supported... |
One disadvantage to pull requests (aka merge requests) is lots and lots of merge commits.
It's not the worst thing, but it does clutter the commit logs, and make for lots of unnecessary non-sequential history.
A - C - E - G
/ / /
B D F
What I think would be better is to cherry-pick the commits.
A - B' - D... |
Are there stable well tested SDKs (as opposed to simple language converters) that allow you to develop your application in some decent language (I believe it is widely accepted that PHP is not a well designed platform) and then give PHP code as an output, so you can host your application on a server that only accepts P... |
Which design pattern should I use when I have a class representing a data structure (aka C-style struct) and I wish to have only a single class to be able to access it.
I was thinking of simply declaring the class that represents a data structure as an inner class but wanted to know if there is a better way to design t... |
My background:
I am new to programming. Python is my only programming knowledge. I program as a hobby, and I'm teaching myself by reading copious amounts of books.
I understand enough about OOP to write OO software. However, I keep feeling uneasy about the things I write... The design seems messy, etc. And I'm unsure a... |
I'm running into issues with an approach I am taking and am now wondering if I just started down the wrong path and should rethink my approach. Here is what I attempting.
I would like to use an Enum to represent different possible Account Statuses (there are other finite data sets that I will be setting up using a dup... |
$inumber1 = 10;
$inumber2 = 20;
function add($number1, $number2) {
echo $number1 + $number2;
}
add($inumber1, $inumber2);
I'm learning PHP coding for the first time and I'm following tutorials online.
The tutorial fails to explain why the above works and adds the numbers even if the vars don'... |
I need help with the workflow that is best suitable for our needs. We are a 3-4 person team and are working on 4 different projects.
We have three main branches:
master - deployable production branch
staging - features under QA on live data
dev - features under QA on test data
Then for each feature, we create a featu... |
I'm sure it's not about laziness or anything like that but I fail to understand why developers of even mainly consumer facing apps don't make any sort of installation wizard where you go next-next-finish. The same apps usually have installers for Windows and Mac OS so why not Linux?
Is there any technical reason for th... |
I have bought Jira for my hobby project and I am currently creating epics, user stories and tasks. I have a question regarding organization and registration of tasks.
1)
I have a user story that is: "As a candidate I want to see which services I have access to". Tasks belonging to this user story is:
Create service fo... |
How do you express what to do when error occurs in a user story? Should the response to what happen on errors be in a task of the original user story, or should I create another user story that is concerned with what happens on errors?
E.g.
This says nothing about what to do on errors such as credit card is invalid, n... |
This is the inverse to "Why don't developers make installation wizards on linux?", which is interesting, but made me think "Automatic installation is the natural way. Why do they use wizards?".
So here is the inverse question:
I'm sure it's not about laziness, or anything like that, but I fail to understand why develo... |
I currently have made a multithreaded server in c++ for windows, where each connected client gets a thread to themselves which stays running until the client's socket is closed.
When a client connects, they can run commands (fetch motd, get current version of the client) or can login to get access to other commands (fe... |
How can one move development / test code into production, and not end up breaking the functionality in Production environment? I am working with a small sized company, so they don't have a budget for a Test environment.
My goal is to move code to production and not compromise the user experience. Given that in a pro... |
I am trying to understand how to create user stories and tasks. I have read articles stating that you should create small user stories and they should be a "vertical slice" of functionality instead of a "horizontal slice".
I have a user story:
As a buyer I want to add items to the shopping cart so that I later can bu... |
Consider an application that relies heavily on the internet. It constantly talks to a remote server. However it's UI is a desktop program that doesn't live in a browser.
Would you consider such a thing - a 'desktop application' (or a native mobile one, etc.) that relies heavily on the internet - a web app?
Wikipedia sa... |
My question came from this question
It seems to be actual developing code for a real application. What If your contract says that all code you made for app of your employer is a secret? Isn't it risky to copy code fragments like that online (if you read carefully, it gives information about the database)? Wouldn't it b... |
I would like to run Node.js/Express as a backend server mainly for handling WebRTC features in my app. I was just discussing this with my hosting provider and they rejected this request saying that Node.js is heavy and requires Java thus making it impossible to run on Apache so I need to upgrade my account to VPS.
Goo... |
Not sure Programmers Stack Exchange is the place to ask this question, but thought I'd give it a go.
Our team had a near miss recently with a nasty error where a method call had been added to the wrong area of code,such that it deleted the an order immediately after the user had been through the checkout. There was no... |
In a situation where all communication (including logging in) between a client (web browser) and server is done over a persistent TLS encrypted websocket, would there be anything inadvisable about having the server attach the client's log-in state to the connection itself as custom properties?
ie,
WSconnection.loggedIn... |
I've only really seen this on Java's wrapper classes (String, Integer, etc.), but never in open-source projects, and I was never taught about it in any books or classes. I know it means the class can't be extended, but I don't know when that would be useful for any class outside the aforementioned JVM-low classes. So, ... |
I am dealing with very complex objects in .NET (in my case a finite element model that can consist of thousands of other objects say a Model instance have a large list of Element instance). I would like to add log feature per Model and its only for showing the log to user, not storing it. A very simple way is to add a ... |
Below is a sample code i captured from android doc
Per service instance onCreate will be called only once. Ref: here and here
The synchronization and singleton doesn't make any sense to me in this circumstance. Very recently i asked another question on google document here
If this is again wrong, probably i need to lim... |
I would like to create a WebAPI application that can serve some of my web sites. My goal is to abstract some common task such as email sending, address resolving etc by providing an API to all of my web sites.
I have created a WebAPI application that implements most of the above APIs but without any authorization. I wo... |
The .NET type SortedDictionary<TKey, TValue> does not implement the interface IReadOnlyDictionary<TKey, TValue>, although Dictionary<TKey, TValue> does.
It is trivial to make SortedDictionary implement IReadOnlyDictionary by subclassing it (< 10 LOCs).
But I guess there are good reasons why the framework developers did... |
Does a compiler look for recurrent expressions to convert it into 'function' to reduce binary size and improve performance?
Of course, the obvious answer might be "some do it, some don't", so I ask for compiler of mainstream language, let's take for example : Java SDK compiler, GCC compiler and Clang.
If "yes, they do ... |
I have a ASP.NET MVC application where in all my Models have an Errors Property used to store non-validation errors which I than display in my Views. Where is the right place to populate the error list according to MVC? Inside the model or inside the controller?
First Option
public class MyModel
{
public DataOperation... |
I don't really understand the concept of testers. I just graduated and before I joined into workplace I thought I'd be pair programming with testers and using TDD where they will be writing tests and I will be passing them or something similar. However that's not the case. Apparently none of them that I have seen knows... |
I am dealing with a distributed application which is going to mange a network of Linux-based servers spread among different places. Having the SSH credentials (as the most supported connection mechanism on these servers) we need to deploy our application seamlessly on these servers and run it there to become an new nod... |
I want to manually antialias the output of GDI drawing functions on Windows. Each drawing function is rendered onto its own image and then blitted back (so alpha blending can work, as GDI doesn't do that natively), so the image has only two colors: transparent and the drawing color.
My question is simple: is there a wa... |
I'm writing a piece of software to generate and print nametags. The issue I'm having is that nametags need to be formatted the same, but have different values (ie. different names, titles), and can be on different sizes of paper.
So I need an efficient way to store a sort of 'template' that has certain formatting info... |
I've learned from a textbook how to implement binary search trees recursively in Java, and am working on implementing them nonrecursively. I've found a simple and elegant way to implement an insert method in C/C++ by traversing the tree using a pointer of type Node**, but can't find an elegant way to do this in Java.
M... |
I've mainly done application development, but have also worked on simple web projects (where the HTML and CSS were created by the web dev guys).
Recently I tried creating a website for myself, and found it extremely annoying trying to get the placement of div's and other elements on the page right. Totally unpredicta... |
I was writing a webpage today with a comment after the start of every major section. Instead of using a comment, which comes with the bulgy <!-- --> syntax, could I instead put this in a data-* attribute? This would be more for me than anything else, so I don't want to put it in an id or class, but it would also leave... |
Suppose you were designing a Java library for other people to use. You compile the library into a JAR that they can import into their projects and use.
Needless to say, you intend for the library to be used in certain ways and through certain interfaces. For example, you might create several Facade classes to control t... |
I'm trying to develop a generic data validation engine for web forms. Basically, the idea is to write a library that loads a JSON "validation schema", and then generates the appropriate server-side and client-side validation rules for various data validation libraries.
It seems like everyone has their own set of valid... |
I'm using ReSharper and CodeMaid, both have their own "organize" code option but the problem is that i have no idea how to tell them what is an event and what is a method/function that i coded.
If i reorganize code (i want regions) it groups every control event and method together.
Is there a way to tell them what is... |
I am learning about quicksort and want to illustrate different arrays that quicksort would have a hard time on. The quicksort I have in mind does not have an initial random shuffling, does 2 partition, and does not compute the median.
I thought up of three examples so far:
[1,2,3,4,5,6,7,8,9,10] - when the array is s... |
In my web application I have to provide a form for creating and editing. The forms for creating and for editing have minor differences, so I am thinking of doing something like this in my view:
<form>
// a lot of htnl goes here
@if (editing)
{
// some more fields shown in edit mode
}
@if(!editing)
{
// some stuff s... |
This probably seems as an example of opinion-based question, but I'm actually looking for rationale on how to decide correctly, I believe there is a correct solution that can be backed by solid arguments (that's why I chose SO and hope is really not only opinion based, but I can be wrong; if you'd feel so, please leave... |
This question is not about a specific program. This is about design - the UML phase of the project.
I am supervising a Java project. It will contain a lot of modal popup dialogs. From a C/C++ standpoint, I have a reference to the main window maintained throughout the program so every dialog may, as necessary, block int... |
I’m working on an application where the client-side interface and backend server are completely separate applications. The backend is written in Ruby and only serves JSON via HTTP. The client is a completely “static” single-page browser application that communicates with the JSON API. I now need to build an administrat... |
I 've been thinking a lot on auto-updating, but wanted to check with you guys if you see any anti-patterns in my proposal:
Context
I'm coding a game in C++ and SDL, compiled in an Ubuntu (host) for a Windows (target) with mingw32.
Technically, if you copy the needed DLLs + assets into the exe folder, it just works. But... |
Subversion offers the svn cat command which retrieves a file as it existed in a particular revision number and displays it.
Sample usage:
$ svn cat -r 3 http://svn.red-bean.com/repos/test/readme.txt
This is a README file.
INSTRUCTIONS
============
Step 1: Do this.
Step 2: Do that.
$
I understand what it is doing ... |
I'm accustomed to relatively rigid defect reporting, something like this.
Steps to reproduce:
1. Access customer manager for user Test01
2. Check "User must change password" and click Apply
3. Access login page
4. Enter user name and password
5. Click Login
Expected results:
6. Site displays user profile page (see use... |
Is there a way to pass Events between Systems in a multi-threaded Entity-Component-System that realizes the benefits of saving on system resources?
I've read a german article about the Entity-Component-System design-pattern. In this article, the author wrote, that it would be good to let the systems communicate via Eve... |
A common problem for me - and it's not really a problem, but somehow I again and again ask myself, what is the normal way to handle this - is that there is a method and within this method a couple of variables are created, used and finally are supposed to be retained as instance variables.
Somehow I want to avoid dot ... |
There are people who prefer to do use cases first and then do the classes, but there are also some who prefer to do class diagram first and then use cases. So is it personal choice for convenience? What are the pros and cons of the above ways?
|
I am working on a project where I would like to encapsulate a directive library and distribute it to other developers to use. I would like to keep the changes to the model within this encapsulated code, so I don't really want the dev's changing the scope variables outside of the lib.
In my code, I have 2 different app... |
Haskell supports overloaded values, where a single overloaded value can behave
sort of like a superposition of values each with a different type. For example, here's a simple type class:
class Truthy t where
truthy :: Integer -> t
instance Truthy Integer where
truthy x = x -- some computation that results in... |
At some point code is complicated less if you introduce a new abstract than if you continue as it was.
Some trigger should fire in a head of a programmer. Like, I was coding fine, but now I've added a few lines of code so I need to stop introducing that much complexity and incapsulate those into a new method. Programme... |
In a conventional MDI WinForms application, one would go like this:
public partial MainMdiForm : Form {
public MainMdiForm() { InitializeComponent(); }
private void manageCustomersToolStripMenuItem_Click(object sender, EventArgs e) {
var cmf = new CustomerManagementForm();
cmf.MdiParent = this;... |
In eager languages like Scheme and Python, you can use a lambda expression without parameters to delay evaluation, e.g. in Scheme (Chicken Scheme):
#;1> (define (make-thunk x) (lambda () (+ x 1)))
#;2> (define t (make-thunk 1))
#;3> (t)
2
In line 2, t is bound to the unevaluated expression (lambda () (+ 1 1)), which i... |
Suppose you are to create a single, global e-commerce application to support multiple markets in different regions of the world using ASP.NET MVC.
Although most of the business logic for the application is reusable for different markets, some markets want to implement their own views and client side validation logic de... |
I have built myself a PHP MVC framework to meet my needs. As pretty much all of the core classes are static, I just stumbled upon the idea of having static controllers. I know that for some reason static classes are not perceived well by programmers, however if a class makes no sense to have an instance I really can't... |
I would like to find or create a syntax to express business contracts programmatically, and I am looking for a robust, flexible, future-resistant way to do this.
A client should be able to add a negotiation points of varying types to the contract.
An example of a boolean negotiation point:
"There is a pre-payment pena... |
Is it common to have a constructor with 7 elements for example? or is it better to use many setters instead?
|
I'm messing around with binary trees, and I'm trying to get a very rough benchmark of a few functions using GHCi. I only want to get the time required to evaluate the test functions; not how long it takes to fold the tree. If I have:
"ghci>" let tR = tFromListR [1..1000000] --I want to force this to evaluate
"ghci>" tM... |
When I began implementing a class in my system (let's call it A), I realized I needed some kind of object that does something. So I needed a new class (let's call it B), but I made it a private static class of A.
Now, B is still only ever used by A, but A grew much bigger. Including the code for B, it's 320 LoC long.
T... |
So, there are some good answers to this question, namely:
Why is Global State so Evil?
I have a specific question about the alternatives Mikera proposed as the answer with the second most up-votes. All of them seem like they would be good ways to avoid using global state, but I want to know which of these alternatives ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.