instruction stringlengths 34 36.1k |
|---|
I'm developing an Android app whose architecture is based on the well known Uncle's Bob Clean Architecture.
I have the following Use Case:
Validate User Subscription
It's based on this use case descryption( main success scenario)
Check if validation warning was already shown
Yes -> Go to step 6
No -> Go to step 2
Ch... |
In the game I am working on there is a Match object and a Player object.
The game is divided into different Matches (basically a lobby). Every Player needs to be in a Match but cannot be in several Matches at once.
Match contains the method List<Player> getPlayers() (list of players connected to the match). Player cont... |
I'm trying to improve my understanding and ability to write code that uses recommended principles and practices, such as the SOLID principles. To do this, I am implementing the fireworks card game Hanabi.
Hanabi has two deck types, Standard and Advanced (which has an extra set of MultiColour cards). Each card in a deck... |
I want to license my Minecraft mod with WTFPL. However, I have a small section of code which I incorporated from other mod, licensed under GPL, in the first release of my mod.
In the recent version (see dev branch of my mod) I refactored and rewrote it from scratch. I also got permission (see README of my mod) from th... |
I am trying to draw a sequence diagram for "post a job" use case.
The description is as follow:
Basic flow:
This use case begins when the employer selects the “Post a new Job” option.
System displays the job form.
The employer fills the form with the following information:
Job title,
type and category (selected from ... |
I am making a game. In this game people can modify a value of an object. Let's picture it like so.
House is the object
price is the value
Mold is the modifier
Should I reflect changes to the price of the house in the database by directly altering a size column.
UPDATE house SET price = price - 2 WHERE id = 1;
Or shoul... |
Could you explain how parsers search for token patterns like in markdown?
I probably could come up with something matching only the braces pattern []() as soon as nested patterns are involved it blows my mind.
For example in something like this
foo [**baz**](baz) qux
the tokenizer probably explodes the string into the... |
Say I have the following ER diagram:
Enforcing the mandatory participation constraint at the one end is easy, I simply make the foreign key (school_id) in Student NOT NULL.
But how can I enforce the mandatory participation constraint at the many end (each School must at least have one Student), that is, how can I prev... |
I have a class called Canvas that acts as the container for a number of Rectangle.
The Rectangles have the following behavior:
They can be moved within the Canvas.
They can be resized.
They may not overlap, move over each other, or move past the boundaries of the Canvas.
The side of a rectangle can be attached to the ... |
Languages like C, Java, and C++ all require parenthesis around an entire expression when used in an if, while, or switch.
if (true) {
// Do something
}
as opposed to
if true {
// Do something
}
This seems odd to me because the parenthesis are redundant. In this example, true is a single expression on its own.... |
When trying to learn about proper comment practices, I found a lot of conflicting opinions, and it's obviously a very subjective topic. So I'm not going to ask "Should I comment, or should I not?"
The question I'd like to pose is, for me, as a self taught developer interested in applying for programming jobs in the fut... |
I have a legacy MySQL Database (A), and a new reviewed structure for MySQL data base (B).
Problem number one is that Database has to be alive and keeps receiving data from legacy apps.
What I need is to constantly move data from old data structure to the new one. Moving is not 1:1 but it is subject to data transformati... |
I have a piece of software which has different users (admin/user) In the admin version you are able to upload the changes straight away. Whereas a user doesn't have this ability have to save it to get authorisation. To display the options I wrote my code like this.
actionMode = ActionBarMode.SaveCancel;
... |
I am working on an embedded C project where there is a function used to initialise a module's (foo) context object handle. Thus when testing using the Ceedling I have used this initialising function in the set up:
#include "unity.h"
#include "mock_bar.h"
#include "foo.h"
static foo_handle s = NULL;
void setUp(void)
{... |
I'd like to decompose a number of Java REST services (WAR files) into individual container-ised "MicroServices" - so that I can scale services ondemand, insulate the applications, have loose couplings, facilitate cloud deployments, etc, etc (roughly ~100 services currently being used in an ESB/running in the same JVM)
... |
I want to wrap every next web application with A top menu and right menu like this :
Every new application should be integrated in this master wrapper.
I thought to create a master page for the wrapper but i will have to create a similar master page for every new application.
My question :
What's the suitable patter... |
If I have "Object" as the top level class, then I have various interfaces, ISomething, ISomethingB, ISomethingC, then I have Class x,y,z, all ultimately deriving from the class Object (these subclasses don't have to derive from each other), wouldn't me having one class at the top like "Object" in .NET lead to, or possi... |
In order to develop an Information system, my system will contain web, mobile and desktop applications. My idea is to make one web services , because for mobile phone apps it will be better to use a web service to manage database and do the heavy width processing also to reuse code in other apps.
In other hand for the ... |
I'm working on a TCP HTTP proxy: need to turn it in a priority proxy.
The standard proxy used to deal every connection with a fork and the child process handles the connection. Now I've implemented a priority queueing mechanism where packets coming from both sides of connections are queued and dequeued: packets coming ... |
In quite a few object oriented languages, especially the ones without free standing functions, it's now best practice to have one class per file, with the file name being the same as the class name. E.g. MyClass.cs storing class MyClass - this kind of makes the concept of a file pointless.
Is it known what the reasons ... |
I'm creating a Node app.
I have JavaScript files that include custom functions that make calls to external APIs (in this case Google APIs)
I have JavaScript files in my node app that are related to setting up the web app and using these custom functions described above
What would be a good name for these JavaScript f... |
I've been thinking about how to design my WPF application, which receives data from a WCF duplex service, but I'm afraid of over engineering.
I thought about abstracting away the WCF communication completely from the WPF client by creating a "proxy client" library that implements the service and callback interfaces int... |
Consider a module with a 'public' function which looks something like this:
def func(arg):
val = _generate_something(arg)
_do_something(val)
As you can see this is a 'void function'. Its core logic is in _generate_something.
I want to write unit tests for this function. I can think of several approaches to do ... |
Which programming languages support type inference from variable names?
By 'type inference', I mean, for example, in Swift, how if you let x = 39 then the compiler knows x is an Integer, because 39 is an integer.
Now, it's conventional in Swift to use the keyword is at the beginning of Boolean variables. For example l... |
When I was reading about microservices on this site, I came across the below statement. What is meant by a canonical schema? Isn't it same as domain model?
The Microservices Architecture pattern also rejects other parts of
SOA, such as the concept of a canonical schema.
|
Disclaimer: Although I mention my use in matlab I think this is is more of a programming pattern question so I put it here. If I am incorrect I will be happy to go over to stackoverflow.
I have a variable comprising of strings array which acts like a database I need to refer to in several functions in my program. It ge... |
I'm trying to design a database for my POS application and have stumbled when trying to create an address table. I'm confused whether to have city and country tables with predefined values and link the pk to the address table (city_code/country_code) OR just have city and country columns as string and ask user to enter... |
I have a class called Heading that does a few things, but it should also be a able to return the opposite of the current heading value, which finally has to be used via creating a new instance of the Heading class itself.
I can have a simple property called reciprocal to return the opposite heading of the current value... |
We are trying to improve our continuous integration pipeline and moreover improve how quickly we can get code through from inception to production.
We have tests at different levels that verify what our software is supposed to do functionally e.g. if there were 20 primary use cases, we have those 20 primary use cases ... |
I've encountered a problem which I think is rather suited to be solved using a Constraint Satisfaction Problem algorithm.
I am however, not entirely certain that this is the best approach, as the specifics seem to deviate a bit from the classical CSP problems.
The problem:
I've got a list of entities that I need to ma... |
I'm working with Swagger to generate the API of my application. Swagger is an API specification language that can be used by a code generator to generate code stubs for your application. Obviously you have to complete these stubs with some business/controller logic.
Given that the code generation is an iterative proces... |
I have a Category and Product tables in database and classes on project.
Category class has {id, Name} properties
Product class has {id, Name, CategoryId} and other relations.
And I have repository and service layer.
So if I need to get products of a category, where can I put this logic?
Category repository => GetProdu... |
Background
I have recently taken up a new job as a developer at a company where I have inherited an in-house CMS built approximately 5 years ago. The CMS constructs pages in XML which are then output to the page as HTML. Some of the markup is generated within the back-end PHP, whereas some is exposed to the user in the... |
Introduction
I am working on MyProject which is windows (desktop) application being developed in C#.NET and DotNet Framework 4 in WPF. Project is layered as DataAccessLayer (DAL) --> BusinessLogicLayer (BLL) --> ApplicationLayer (UI).
This project has a module called MyModule which needs to be reused in other multiple ... |
We've a table which has a bunch of columns. Let's say it represents humans. Every human has a specific type: archer-human, car-human and so on. Everytime we create a row nearly all of the fields are empty since we create a human of one type only.
For example:
| ID | Forenamne | Surname | Arrows | Bow | Car-Manuf... |
The project I am working on has deep parent/child relationships that needs to enforce availability.
Imagine we are a large Worldwide Electronic Seller (Best Buy) and selling mobile phones
We have Regions (Asia,Europe,North America..), Countries within Regions, Warehouses within Countries,Stores which are working with W... |
Is it weird to have an identifier such as (_id) on a request which you send to the API, which "enriches" the request and sends back a response with the same identifier (but obviously more enriched data)?
For example - you send request {_id: 1111} and get back a response {_id: 1111, occurence: new, etc}.
The reason why ... |
We use SVN for our version control and have a trunk for minor changes and a branch for more significant changes and also for the devs to be able to work off the same code base.
We regularly do trunk merges so our branch code-base stays up to date. When we work on a given bug / issue we do so generally on the branch and... |
When doing (possibly heavy) pixel processing on a large image, multithreading becomes a must. The standard practice is to initiate a loop whose indices are partitioned into multiple threads within a thread pool. The performance benefits become immediately apparent after taking the appropriate thread-safety measures to ... |
I recently got into website development and am in the process of making my first website using Angular 2 right now. I already created websites in the past using basic HTML and PHP but that was nothing special and the quality of code was pretty low. "Back in the days" I just created different files for different tasks, ... |
I have seen lots of advice about git branching models and the most common opinion seems to be that making changes directly on the master branch is a bad idea.
One of our co-workers is quite happy making changes directly on the master branch, and despite several conversations, they seem not likely to change this.
At thi... |
I have a system where a set of Operations needs to be done every day. Each Operation has the following metadata: Type, Entity and a Date (independent of current date). It reads something from the database, computes stuff and saves results to the database. An Operation is a combination of: [Entity, Type, Date]. I need t... |
We overestimated our project and are going to finish two weeks early.
Rather than fill in the extra time with additional features, management has directed the development team to use the extra time to ensure the highest possible quality code (Note: The QA team is not yet engaged.)
In what structured activities could th... |
I was reading about gzip program and I found the official website of the gzip software.
First of all the site looks very bad, it is very hard to find useful information on it and it was not updated since several years ago.
Also, only www.gzip.org is working, but simply gzip.org is not working.
It would not be hard for... |
I work for a franchise and we want to provide some web applications that host internal & proprietary information & functionality that should only be available to active franchise employees. Each franchise is independently owned and operated. They provide their own desktop computers (we require specs, like Windows OS) t... |
TL;DR: My question is about how to use in conjunction:
the dependency injection design pattern
with global / immutable objects (ex: a session that references a customer object)
I get the idea of dependency injection and immutable objects. They are great concepts and help implement good development practices. Is there... |
I have used a lot of JavaFX and am familiar with the technical aspects. Now, as I foray into a very large application with hundreds of views, I want to make sure I start strong with a solid design. This is purely a client application, backend is elsewhere.
I should also mention this is an MDI (Multiple document interfa... |
I'm designing and developing a learning system based on flashcards and leitner system. The system have many features such as creating flashcards, studying the flashcards, doing tests and etc. The activity diagram of studying the cards is attached below. It goes through all decks of the box, studies the cards, which are... |
During the design stage, I usually come up with a class diagram that looks something like this
However, during coding stage, I would never create a class like Librarian with issueStatus() or searchBook() method.
100% of the time, class Librarian, will be a plain-old-object with only getter and setter method, and issu... |
I'm working with Laravel queues lately.
I've all set up and running fine.
What I see is that I perform a http request to my system, the controllers manage the request issuing a Model having request details as parameters.
The model is the injected in the Job, then job+data(model) are serialized in my queue. (I'm using D... |
I've got an API endpoint which looks like this: http://foo.bar/rest-method/{identifier}.
This API returns an object that looks like that:
{
name: "Example",
version: "1.0.5.3937"
}
Now I know that the entry with the identifier 2923711253 has got version 1.0.5.3937 while the entry with the identifier 29238230... |
I've already an offline updater as a download but I want to make it automatically. It's a client/server software and a ms sql database.
3 parts have to be updated:
update of a proprietary software (setup.exe with next, next, type login/password for server service, finish) which delivers a WinClient and a Service for t... |
This question is on program architecture and relationship between DAL, Security and BLL in case, when simultaneous write in several storage objects is needed. I address it to Microsoft SQL Server functionality, but it is more common question and in general does not depend on used (R)DBMS.
I have read this Q&A:
https:... |
I just read an article by Luca Cardelli and he explained types of polymorphism which are:
The article is named On Understanding Types, Data Abstraction, and Polymorphism.
Types of Polymorphism
Cardelli defines several types of polymorphism in this article:
Universal
parametric
inclusion
Ad-hoc
oveloading
coercion... |
I have a function to generate n random string with the same length, making sure there isn't any duplicates, and then saves them to the database. Right now, to speed things up, first I get all the saved string from the database, convert them to a dictionary, and then check against them for duplicate every time it genera... |
Sometimes private functions of a module or class are simply yet-to-be-extracted internal units of functionality, which might deserve their own tests. So why not test them? We will write tests for them later on if/when they're extracted. So why not write the tests now, when they're still part of the same file?
To demons... |
I have a question regarding the design of an application where the database system has a rollover. To clarify the context :
the database system (a cloudant instance) is fed with sensor data by an iot platform
the iot platform performs a database rollover each day, week or month (configurable but fixed once it's config... |
A client has requested that we build a platform for integrating data from partner to their central data store. This will not be "Big Data" scale.
The data from each partner will be accessible through RESTful APIs. Since RESTful APIs are not standards based (at least not currently), I divide the problem into three parts... |
Here is the situation:
There is a Mongo database A and there is Mongo database B.
There is a business concept/Mongo object that is called someModel which exists on one of database B's collections.
Here is the question. The way we generate this someModel is based on other object's data from database A. And there are tim... |
I'm unclear how TDD, the methodology, handles the following case. Suppose I want to implement the mergesort algorithm, in Python. I begin by writing
assert mergesort([]) === []
and the test fails with
NameError: name 'mergesort' is not defined
I then add
def mergesort(a):
return []
and my test passes. Next I ad... |
I'm writing a ray tracer and wish to add concurrency for the obvious (though likely small) performance gains.
In my code I iterate over all the middle points in the grid of pixels that forms my final image to trace them. My idea for making this in parallel is to write some kind of monitor that returns atomically the ne... |
I am writing a system of callbacks for BitBucket and GitHub which should modify our site on certain events in BitBucket or GitHub.
It is reasonable to make a base class like GitIntegration to handle both BitBucket (BitBucket class) and GitHub (GitHub class) as its inheritors. Note that these three classes are agnostic ... |
I have an existing git environment set up like this:
In order to deploy my changes to the production server, currently I:
run git commit on the dev copy
run git push to send my changes to project.git, the central repository
ssh into the production server
run git pull on the live copy
I would like to eliminate steps ... |
I have been searching and reading recently about DDD and, so far, I think I understood its fundations.
If I understood well, the architecture is similar to this:
Database <--SQL--> DAO/ORM <--CRUD--> Repository/Aggreagtes <--Business--> **¿?** <-- Controller --> Internet/Client/UI
My doubt turns around the ¿? gap. I u... |
Setup: I have a number of biometric devices, each of which records 24hr-48hr chunks of data that need to be correctly time-stamped with start date of each recording. Each device needs to be connected to a PC from time to time, at which point they function as removable storage media, allowing collected data to be downlo... |
I'm having a difficult time conceptualizing the purpose of a multi-claims-based authorization system. For example, ASP.NET MVC Identity allows for key-value pairs called claims that you can store on a given user. However, each user already comes with a unique ID (if you use the default setup). So say I wanted to author... |
1) What is total order? Does total order mean the consecutive numbers must be strictly less than "<" or it can less than or equal to "<="?
2) how can generate and maintain total order among the proposers in paxos?
Can each proposer generate a pair independently from disjoint sets as (seq_number, ip_address) ? and if we... |
I'm writing some code that needs to deal with many potential JavaScript values including so-called non-values . I'm realizing it would be very helpful to know if there are some general rules about which native JavaScript functions can return null and which can return undefined. Thus this question.
Of course, any variab... |
I was interested in how the following should be approached from both a pragmatic and pattern oriented design. I'd rather a real world answer over "pattern correct".
Simple Example:
Say I want an event logging system where developers just call the log method and provide a custom tag just so it prints out as a prefix to ... |
The current trend seems to be to use lambda type function in languages that can take that syntax. Is this just a trendy thing or is actually more efficient? eg in javascript, you can get stuff like
var x = ((aa,bb) => {
....
aa((xyz) => {...}
}).then((aa, bb) => {
...
}).doit
Is it actually more ... |
I made a small program using several MVC-patterns. So far I havnt got to much stuff to put in the model so I havnt got any model yet.
My idea is to make one MVC pattern for each panel. And looping through it in the mainloop in the MainController. Then I communicate (starting and stoping) with the MainLoop in the MainC... |
I'm in the progress of creating a REST API and currently, I'm encountering the following problem:
Foo is the first resource. CRUD operations can be applied via the /foo/ URI.
Bar is the second resource. CRUD operations can be applied via the /bar/ URI.
Every Foo is associated with zero or one Bar. The reason why I d... |
I'm developing a program which does communication to different types of devices (with respective protocols). It should concurrently acquire messages from devices and write them to a file with specific format. Timing is very strict, therefore it's decided to be implemented as 2 threads - one getting messages from device... |
I have the following class representing an XML configuration stored in the DB:
using System.IO;
using System.Xml;
using System.Xml.Serialization;
[XmlRoot("ModalConfiguration")]
public class XmlConfiguration
{
[XmlElement("Field1")]
public XmlConfigurationField Field1 { get; set; }
[XmlElement("Field2")]
... |
I have in mind several deterministic functions that I'd like to put together, but I'm struggling with the full impllications of doing:
Static class with static methods
Instance of a class that can be injected into consumers
In both cases, the implementation would be the same, and as they are deterministic with no dep... |
I have read a book called Clean Code by Robert C. Martin. In this book I've seen many methods to clean up code like writing small functions, choosing names carefully, etc. It seems by far the most interesting book about clean code I've read. However, today my boss didn't like the way I wrote code after reading this boo... |
I have 4 XML files: A, B, C, and D. I want to know if the difference between A and B is the same as the difference between C and D.
The XML files are serializations of the same .NET object; one of the primary differences will be in a particular list that describes the features available on a particular product. (A desc... |
I have an existing class which interacts which can open, read or write to a file. I need to retrieve a file modification for that purpose I have to add a new method
Suppose this following is my class definition where I want to add a new method.
class IO_file
{
std::string m_file_name;
public:
IO();
IO(std::string... |
TL;DR
What procedure is followed when selecting bytes to represent opcodes? Are byte(s) for opcodes just randomly chosen, and them mapped to mnemonics?
I recently learned from this answer that bytecode usually consists of instructions which have one opcode, which consists of a fixed number of bytes, and operands. Spec... |
In my day to day programming, I tend to use very few pointers, not only because I want to keep my code simple and error free, but because I assume that the programming that I do does not have any objects large enough to benefit from delegating them to the heap.
At most; my largest object would probably be a QString of ... |
My ASP.NET app provides many complete separate group discussions. As currently written, the active global data is kept in a complex GroupDiscussionObject that is stored in System.Web.HttpContext.Current.Application under a key specific to that discussion, i.e.
Dim thisDiscussionID as integer = 99
Dim thisDiscussionObj... |
The database I'm currently building is pretty complicated to me. So it would be much more complicate if i try to explain so i will try to generalize. The question is at the end of the post.
So I created a little database model. The Tables are connected with a n:m relationship. Only the manufacturer and the machine tabl... |
I have a fairly complex C++ component whose performance has become a problem. Profiling shows that that most of the execution time is simply spent allocating memory for std::strings.
I know that there's a lot of redundancy among those strings. A handful of values repeat very frequently but there are also lots of unique... |
In UI-related code, I often end up writing a construct like this:
function doItOnceAndRepeat() {
if (!stillNeededToDoIt()) {
return;
}
doIt();
runLater(doItOnceAndRepeat, 1000);
}
runLater is a function that will execute the specified function asynchronously, after some time. It might be setTim... |
Is it acceptable to use Http status codes (.NET HttpStatusCode enum) in my application instead of creating a new enum ?
I encoutered an issue (design issue?) in my API, for example in the authentication process, I had this method signature:
public bool authenticate(string token)
Leaving me with a Yes/No possibility, ... |
I need to write my own version of a bounded queue. It must be thread safe. The consumption of this queue is based on a priority system, where a consumer makes a request for an object in the queue.
The queue can have many producers and many consumers. Consumers come and register their requests based on a certain criteri... |
Currently we have 3 branches and trunk. If a developer makes a change in one branch, they alone are responsible from merging that change to the 3 other branches and eventually back to trunk. There's a published chart on the merge order that gets updated periodically.
So, we have lots of little merges happening across... |
In a past posting, I asked about commands in Bash to align text columns against one another by row. It has become clear to me that the desired task (i.e., aligning text columns of different size and content by row) is much more complex than initially anticipated and that the proposed answer, while acceptable for the pa... |
It's a good practice (I believe) in C to handle errors like this:
int status = tree_climb(tree, ...);
if (status != 0) {
global_logger.message(2, "Cannot climb a tree %s", tree->name);
return EPIPE;
}
or, alternatively
forest_errno = tree_climb(tree, ...);
if (forest_errno != 0) {
goto exit;
}
exit:
if (t... |
GitHub has:
pull requests
pull request reviews
pull request review comments
BitBucket has only:
pull requests
pull request comments
So there are three kinds of objects.
I write code which receives, processes, and stores in a DB these things from both GitHub and BitBucket. So I should have three kinds ... |
I want to know how to structure my Service Layer
I have thought about something like that:
Assembly called SomeNamespace.Service.
Have a seperate folder for each problem domain (SomeNamespace.Service.Email).
Structure by Interface/Model/Service
But then I am not sure, how to call the folder where the actual service i... |
Is it poor practice to not use spaces between parameters in a scripting language (or any for that matter)?
With spaces:
def does_a_thing(x, y):
...
does_a_thing(5, 9)
Without spaces:
def does_b_thing(x,y):
...
does_b_thing(1,2)
I have seen it done both ways and personally prefer using spaces as it shows mor... |
I have been using OpenGL and OpenGL ES for a long time, and I know them pretty well. They're also really, really annoying to use, and I haven't really seen this discussed anywhere. Here are some examples of bad design I have noticed:
Global states everywhere. There are states for every feature, often implicit, sometim... |
In C, When do we say that a variable is undefined ? When it is not present in the complete code or in a function scope ?
|
Can writing business logic in the view(.cshtml) of an MVC application have an impact on performance (for example, Load time)? Is it the preferable way or are there any other best practices?
|
I am working on a real-time terrain rendering engine. I have a QuadTree and Node classes. The QuadTree class expands/collapses a tree depending on where the camera is. So it makes sense that the QuadTree is responsible for the Node objects lifetime. The problem is that there is many data which needs to be associated wi... |
I'm working on the specification for building a web services platform and AMQP is the messaging protocol used for the interaction between the components of this platform.
I'm using topic exchanges for this, and I want to define a common approach + some naming convention for the routing keys.
For these topics RMQ exempl... |
I work as an iOS developer in a small outsourcing company in a team of 4 people. We work on a project that started a couple of years before I and two other developers joined the company. Before that the project was mostly being done by one person.
When I started working on the project it was a complete mess. There was ... |
Ever since I first learned about the Gang of Four (GoF) design patterns, at least 10 years ago, I am having the impression that these 23 patterns should be only a small sample of something much larger which I like to call the Pattern Space. This hypothetical Pattern Space consists of all recommendable solutions (known ... |
I have a Jetty web server running which accepts POST submissions from clients(currently just a java program that simulates what I want to be an Android device) The client program sends data via POST and the server process each request and stores them in a sql db.
Is this the correct way of communicating with the server... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.