instruction stringlengths 34 36.1k |
|---|
Do Special Case or Null Object design patterns still provide value when application behavior, not just object behavior has to change?
I was tasked with revisiting an old application and refactoring its code to better log/handle errors.
This application is a .NET MVC API written in C# that handles readonly data. Since i... |
I want to know which are the rules so i can figure out what code files should be put in the "core" directory (and sub-directories), because i didn't get it yet.
I was thinking if it's about code that the user doesn't interact with directly, like database management ones, for example... Is that it?
Thanks in advance. ... |
A quick search on the role of compiler brings up the following:
A compiler is a special program that processes statements written in a
particular programming language and turns them into machine language
or "code" that a computer's processor uses.
However, I also read that every language needs to have a target ru... |
I have always been taught that one of the most important things to do at the beginning of the developments of a software is the Requirement gathering. I have also been taught that requirements always (most of the time) change dramatically between the beginning and the end of the project, either because the client wasn'... |
Basically this question is of the variety "Can I check that we're not about to do something dumb?"
We're setting up a new system that needs to guarantee delivery of emails.
We have an existing system that processes financial transactions and we want to decouple that from sending receipts (which it is currently handling... |
An example is switching the main view according to the selected item in a hamburger menu. Also sometimes it is just a small part of the GUI that changes according to the application state or according to user interaction with other parts of the GUI.
In WebForms days we used to create a tab control and hide the tab butt... |
This week I want to start a greater app project that is expected to handle much data. The app will provide an interactive forum, a media library that allows streaming and a task module with push notifications.
The forum data and the videos should host on a server and be provided through a service, securely.
Since I'm ... |
I'm currently writing a neural network implementation in c++ and a curios question occurred to me:
I want my NN to be "generic", therefore i want to be able to define custom transfer and error functions. My first instinct is to create an interface (abstract class) and pass derived objects as argument (basically funct... |
I'm programming in Java and have the following problem:
I would like to do collision detection. For that, I need different types of BoundingBoxes. For the sake of example, let's say that I have entities that have a circular collision box and entities that have a rectangular bounding box. So I need two classes, Bounding... |
(This is probably a dupe, but if so I haven't seen it yet, although it may be Best practice for encapsulating a parameter that requires multiple interfaces to be implemented, but that question doesn't answer my situation)
Normally I don't care that c# only has single inheritance, but I have run into something where I t... |
In the article: Why POCO, there is this sentence:
Maciej Sobczak puts it well: “I just don’t like when somebody gives me half of the language and tells me that it’s for my own protection”.
I don't understand what he means, even though C# is owned by Microsoft & Java is owned by Oracle, it doesn't mean they hold half ... |
I had an interesting discussion today with another developer about how to approach a class with a method that accepts a string and outputs string.
Imagine something like the following which is completely made up for the purpose of example
public string GetStringPart(string input)
{
//Some input validation which is... |
I have written a webscraper in Python that grabs data from ~10 different websites (they have confirmed that this is ok). Most of the websites are a little bit different, but the general idea of getting data from each is the same:
Load the site's URL
Press anywhere from 0 to 3 buttons (depending on the site).
Enter a s... |
I am wondering if this is a good idea in the first place.
Basically I want to create a template upon which to build numerous sites. The idea is I can update the "core" of the website without having to change much, if at all, any application specific code.
This way, if there is a flaw in the core of one web server I can... |
I am working on understanding DDD and want to see if this idea is sound, if it is common practice, and if there are any pitfalls or unforeseen complications.
I want to effectively have one "entity" with a globally unique primary key. I want to use event sourcing. I would like have different AR classes represent this "e... |
Premise: I'm asked to develop a system that will trace sensitive data. The data are gathered by an intermediate operator (let's call him IO) on an office terminal. The final user (EU) will show up to the office, identify itself via an ID document, the operator will acquire the information and send it to the system.
On ... |
I am writing an iOS application in XCode. The data loaded for the multitudes of viewcontrollers is generally loaded from the DB upon the viewDidLoad() or viewDidAppear() for that particular VC, or it it is passed from one VC to another upon IBAction button clicks.
I am wondering if there is a better/more efficient way ... |
Imagine a psedo-code class like this which does name comparisons:
public class NameComparer
{
public bool DoNamesMatch(Name name1, Name name2)
{
if(WholeNameMatch(name1, name2))
{
return true;
}
return ProcessorIntensiveFuzzyMatcher(name1.Forename, name2.Forename)
... |
Recently, I've been talking with a friend about the code I've written. The code looked something like:
import json
def save_data(destination, data):
with open(destination, 'w') as out:
json.dump(data,out, ensure_ascii=False)
# Code...
save_data(path,data)
Similar for loading the file.
My friend argued that it... |
I've got a class member function that generates a large list and puts it into a private member variable so it can be accessed through a getter. The generation of this list is a rather intensive process (in my testing it's just under a second, but with larger datasets I expect it to take much longer), involving lots of ... |
I am looking at updating some of my companies existing code to allow unit tests to be implemented. To be able to do this, all repositories are being interfaced to allow DI. However, the existing code has a habit of creating 1 repository class per table in the database, meaning that one section of business logic may n... |
I'm working on a free software GUI application and we are considering what non-essential files to include in the end-user package
Here are my thoughts of possible files we may want to include:
License file,
Readme
List of contributors
Are there any other non-essential (non-essential for starting the software) files t... |
In my current organisation, we have several different build environments (like toolset etc.) which are needed for compiling the code of different modules within the same product. I found this a big mess where every engineer, in order to build their codebase, first has to go through the mundane task of setting up their ... |
I have a C++ serial code which simulates a physics algorithm. The C++ code is serially optimised. What is the standard procedure and documentation that is followed while parallelising the code or for GPU acceleration? I am accelerating the code on Nvdia Tesla K40 & Intel Knights Landing cluster.
|
Two months ago I joined a development team for implementing new features over a software that evolved over 10 years. The current state is that there is very few documentation and in order to develop a new feature, there is only the architect who completely understand everything, so the developers need to implement what... |
Suppose that a user has multiple items. Each item would have complex configuration - multiple tables with relationships.
Each configuration table would have an id and a item_id which is a FK to items table.
My question is given that we have a relational database and we export all tables to a text format (csv,json, etc... |
Disclaimer:
The post is Spring and Hibernate specific but any generic advice would be helpful too.
I recently started on a project which contains following technology stack Hibernate, Spring MVC and Angular2.
After reading a bunch of blogs and tutorials I found clean architecture has a good set of guidelines and I lear... |
In my C++ project, I have three classes, Particle, Contact, and Network. The Network class will have N particles (std::vector<Particle> particles) and Nc contacts (std::vector<Contact> contacts). Particle objects will each have a number of contacts, represented by Contact objects, and contacts are shared by pairs of pa... |
I'm having trouble defining the boundaries of my bounded context(s). I have the following, simplified/incomplete, versions of the classes in my domain. All of these classes are unique so they are Entities and I think they should be AR's as well, though I'm less sure about that last point. A Customer, User and Carrier a... |
Where exactly in the 3-tier-architecture is the access to the business layer (e.g. REST API) located? I would say that the API must be between the presentation and business layer, but I have never seen that someone has defined it that way.
Presentation -> API -> Business Layer -> Data Layer
Would that be a reasonable a... |
I have a search function on my site that needs to search through ~2000 items (this table never changes, it will always have the same number of items) stored in MySQL. All it needs to do is search by name or 'LIKE' the name and return the id. I have thought of two approaches to this:
Query database using ajax on keyup(... |
I have an application 'A' that was over engineered using Amazon SWF to do jobs asynchronously. We are re-writing it to app 'B' to keep it simple and do the same jobs synchronously without using SWF. The actual code that does the job was kept clean and separate. Application 'A' will eventually be decommissioned - say li... |
I have a client side android app which needs to send an encrypted string to a server implemented in PHP. For this I have chosen an asymmetric algorithm (RSA).
Should I:
Save a public key in client side and use this for encryption and then
send the private key and encrypted string to the backend
or:
Get the public ke... |
For context, this project is a personal budget program I am working on while I try to learn to use MVC patterns effectively.
There is a SessionController that passes user commands to a MonthController. Each controller has a Parser that maps commands to controller methods.
Currently, the controller has a Month object as... |
I am new to the Xamarin technology, and I am working on an Asp.NET Core Web application which basically delivers micro-services which will be consumed by a Xamarin.Forms application.
So my Web API will offer quite a few operations, and each of them would use their own model class to represent their response and their p... |
I use this pattern quite often in JavaScript. Here is an example:
const comments = [
{ text: 'Hello', id: 1 },
{ text: 'World', id: 4 },
];
const byId = id => element => element.id === id;
const comment = comments.find(byId(1));
Sometimes, this pattern can make our code readable and modular. What is this pattern... |
I'm not sure if this is the correct form to be posting this on Stack Exchange. If not I apologize in advance and hope someone can point me in the right direction of where to post.
I have a AWS Load Balancer with multiple EC2 instances all handling my web traffic. I'm wanting to add iOS Push Notification support. I curr... |
I have read the replies from those post(Why are interfaces useful?) and (Why use an interface when the class can directly implement the functions?), which is the similar question as my this post. But I still cannot understand it why we use interface since we need to implement the method in our derived class?
I can unde... |
I am currently using NodeJS & Express to load webpages which contain element content that is rendered via a query to MongoDB.
A GET request will create Button elements, binding the MongoDB _id to each button.
I am designing a Point of Sale system. Each button is an item with an associated price on the Database server... |
My company develops embedded systems and they have a project where they are developing a new platform which will be used to do demos for potential clients. They are introducing a new technological concept and they want to have it as base for new products, so they can reuse most of the blocks of code generated and have ... |
In GNU/Linux the recommended installation directory for internal binaries of a given package is /usr/lib or /usr/libexec. However, I can't find any recommendation for internal (non-binary) executable scripts. Should they also go in the mentioned directories? Wouldn't /usr/share make more sense since they are architectu... |
I'm working on some code where the structure looks like:
Class A {
Client client;
B b;
void process(request) {
data = fetchData(client, data);
b.process(data);
}
}
class B {
C c;
void process(data) {
data2 = someProcessing(data);
c.process(data2);
}
}
class C {
D d;
SqsClient sqs;
... |
As a 3rd-party, I'm writing a program to interface with a webservice. The problem I've run into is that some classes end up being as commonly used as ints/strings (e.g. User), so I need to be careful with which responsibilities I give each class to prevent mega objects which depend on every other mega object.
The best ... |
I've come up with some ideas for the database design, but I don't know if any of them would be practical in production:
posts and a separate post_edits table with a copy of all previous revisions. To get a single post, it's completely transparent as if the post_edits table isn't there. Nothing wrong with this, but it ... |
A recent endeavor of mine requires asking users how related two concepts are. Example: Kiwi and Fruit. Identical? Fairly Similar? Rather different? Unrelated?
It occurs to me that for certain combinations of terms (such as Strawberries and Tasty) people may have varying opinions. This, in effect, poses problems ... |
I've been using a functional approach in my programming of late. I know that mutability and state changes are big no nos within the paradigm. I now find myself working with databases and other data structures where state must be changed. I've been trying to learn about monads and other means of interacting with state, ... |
I've been aware of SOLID for many years now and I've always though about "OLID" was a good set of design principles to follow... problem is I've always found difficulties with the "S", I've always thought of it as a very ambiguous principle and believe me, I've read about this principle from many different places/books... |
struct co_ordinate {
double x;
double y;
};
// -----> DESIGN 1
class Land {
public:
Land(std::vector<co_ordinate> co) shape_before_plotting(co) {}
// actions
// creates stage 2
// populates shape_after_plotting_outside_boundary
void do_plotting... |
In most web application which deals with a database, one has to enter the DB creds in a settings or config file, like DATABASES variable in settings.py in Django. What is the general practice to secure the creds such that only a selected few in the team knows the creds and even they are not able to connect to the DB wi... |
I have completed a project. But errors unexpectedly occurs anytime when the user inputs data in it. Yesterday my program was performing very well.
But today when the client tested the project it had some unexpected errors.
Is it a normal thing to have such unexpected errors?
Or Is there a way or a technique to verify t... |
I have a thread that goes in a loop doing something like this
void thread()
{
pthread_mutex_lock(mutex);
for ( ; ; )
{
/** code **/
{
pthread_mutex_unlock(mutex);
/** do_something **/
pthread_mutex_lock(mutex);
}
if (exit)
return;
}
}
where exit will be updated in a di... |
Introductory piece of code:
class BaseClass
{
protected Foo MyFoo { get; }
}
class ChildClass : BaseClass
{
void SomeMethod()
{
MyFoo.DoStuff();
//Here, I have no idea that MyFoo is not defined in this class,
//but rather in the base class.
}
}
The problem/debate is that you ha... |
I'm doing the exercise 10.1, page 476 from the book Java: How To Program, Early Objects by Paul and Harvey Deitel (10th Edition).
Modify the MyLine, MyOval and MyRectangle classes of GUI to create the class hierarchy as shown in picture below. Classes of the MyShape hierarchy should be “smart” shape classes that know... |
We have a logging protocol that defines how output of logging libraries should look like, e.g.:
each line should be a JSON
each line should not exceed 1MB
There are multiple implementation of this logging protocol, i.e, logging libraries written in different languages (Java, Python, etc.). I would like to create on... |
I have doubts on approaching doing this.
I have a Train class and a Wagon class. There are three types of wagon: FirstClass, TouristClass and DiningCar. Each of these types has the same properties and methods, the only difference between them is their multiplicity with the Train class.
Each train class has one and only... |
I'm working on a new style of database migration system that is coming along nicely. There is one last aspect of it that I want to finish, which is to enable MySQL linting. For background, this is a little different than standard migration systems that come with e.g. laravel, django, etc... Rather than specifying ac... |
I'm trying to port code from entity framework 6 (EF6) to entity framework core 2.0 (EF-Core) and have ran into a dead end.
In my EF6 code, I have a base class called Record which defines the base properties and methods of all Record types. This base class provides common functionality and properties for all different t... |
Which method is better to store the data in a database and why?
Here is a restaurant example. I'm using a SQL database and JSON to communicate with the database.
Imagine each row is a column in a database
Mostly without objects
Resturant ID -string
Resturant name - string
Resturant picture - hyperlink
Resturant des... |
I've been searching for weeks for an answer to this question, which seems as though it would be common across pretty much all applications and therefore a problem right at the forefront of CQS.
CQS dictates that a function should either:
Change state and return void (command), or
Change nothing and return a result (qu... |
I have a table UserItems {ID, UserID, ItemID}
Items must be in RAM (not in db table).
What is better for this? As enum with attributes or as dictionary of items?:
enum Items
{
[InternalParam("x432", 34)]
Red = 1,
[InternalParam("x431", 12)]
Green = 2,
[InternalParam("x438", 54)]
White = 3
}
OR
... |
I need few related variables (for example I have the lengths of 3 lines given. I have to say whether they form a triangle).
Which variable naming convention is preferable in Java?
len0, len1, len2 or
lenZero, lenOne, lenTwo or
lens is declared as an array. Then lens[0], lens[1], lens[2].
Maybe if there are many vari... |
I need to design a program in Java which calculates arithmetic expressions (only addition or subtraction).
Requirements:
1) abstract class Expression which contains abstract method calculate() and method equals() which overrides Object.
2) concrete class AtomicExpression which inherits from Expression and must have ... |
I'm wondering the best approach to designing a database for storing crossword json data. As the website is at the moment, the frontend view just needs to be passed the whole object to render the crossword:
{
grid: [15][15], // 2D array of letters
clues: {
across: {
clue_id: "here's an acros... |
I have several Django services which all have their own login portal, and colleagues have a user/pass for each portal (if we've given them permission). We'd like to unite all of these portals and there are a couple different options:
1) Just create a new service that is one giant consolidated tool, and get rid of the o... |
Would appreciate any recommendations regarding design a high-load image processing service.
There are lots (tens of hundreds of relatively large images (~10...20 Mb each)) that to be processed using command line utils when requested.
Generally: request->image processing->result. Obviously, the system must be able to sc... |
Imagine there is an endpoint GET /v1/status which returns one of predefined statuses that are documented. For example one of [disabled, enabled]. The endpoint can be used by other third party services.
The problem that I see with just adding a blocked status as is, is that
third party clients will not be able to proces... |
So our team has products that currently runs on Visual Studio 2013. Now we want to move to Visual Studio 2017. So I've been assigned the task to make the transition to Visual Studio 2017 as painless as possible.
Here is the list of challenges that this task presents
We use git as our versioning system and we have all ... |
I am trying to make a simple expression parser, in which users type an expression in infix notation (for example ln((1+2)(3-4))) to apply some calculations. To make this possible I need to tokenize the expression as a expression tree. I've read in blogs and forum that I need first to convert the expression to postfix (... |
I have to refactor a "for" loop which iterates over an array and does two independent things with the array element. For example:
doThisOrOtherStuff(array) {
for(int i=0; i<array.length; i++) {
element = array[i];
id = element.getId();
if(id < 0) {
doThisStuff(element);
} else {
doOtherStuff(element);
... |
I am looking for optimal for maintenance/easy of programming and elegant patterns to parse delimited network streams, e.g. protocols like SMTP. Some of the concerns I've always had are:
how to react when a recv(2) call returns 0 - the need to track state to determine if no data has arrived or no more data will arrive
... |
I have been working on a project with multiple microservices whose communication happens through API calls. Lets say microservice A calls a service provided by microservice B. According to the current implementation, we don't have multiple APIs for the different services provided by Microservice B; instead what we have... |
My manager has asked me to "just wrap the stored procedure".
The requirements are to create a microservice that will do the following:
Accept parameters from the user.
Pass those parameters to the stored procedure.
Return to the client the resultset of the stored procedure.
In the beginning of my career this was d... |
I'm just working on a set of MATLAB files right now that I'm using for my thesis. I want to be better organized and figure out the best way to keep track of changes. I have read that GIT is a good tool, although I'm not sure whether this is still good for a solo worker (I don't collaborate on any code).
My current met... |
I am currently studying on multiple inheriting operation.What ihave learnt is we can't inherit multiple class but we can inherit a class and an interface so i just need to switch a class to an interface. Like below
class a{}
class b{}
interface d{}
//class c:a,b{} That does not work
//class c:a,d{} or class c:b,d{} but... |
I am designing communication system that will be sending targeted based SMS (ads/offers) to its customer. The basic system with low load scenario works well, and the SMS sent are based on an event like a person visiting a place, he should get all the promotions done by that store or stores near him based on his interes... |
I recently stumbled upon some code which looked wrong.
I edited it only to see that my changes broke the code.
I tried to structure the code in different other ways to make the code both look and be right, but I wasn't satisfied with any alternative I could come up with.
The logic of the code is as follows:
A Path i... |
I have the following methods:
SingleUserMode() - turns the single user mode on in the database
BeginEdit() - starts the edit of items in the context, locks them in the database
SaveChanges() - saves the changes to the database
ReleaseSingleUserMode() - turns the single user mode off in the database
Each method return... |
I want ask experienced software developers and architects about this domain class which I found one day in some code.
public class User : Entity
{
public virtual string Firstname { get; set; }
public virtual string Lastname { get; set; }
public User(string firstName, string lastName, IUserRepository userRep... |
We are redesigning one of our API projects from an n-layered architecture into onion architecture. In the previous design, we had configuration classes in a common library project being referenced across all the layers (UI, Logic and Data Access layers). How should these configuration classes be fit into an onion archi... |
What is a good term to use for when I want to describe changes to the codebase that does not involve changing or adding functionality. This would include bug fixes, security patching -- including library upgrades, and perhaps refactoring as well.
The term would replace the incorrect sounding "non-functional changes" in... |
I am working on figuring out the architecture for putting together a complex modular system that has Orders, Customers, Projects and Quotes.
The customer can have multiple projects. For each project there will be at least one order or quote associated but there is the possibility of having multiple quotes and orders on... |
This question is generally regarding when it is a good idea to store quantities derived from member data in, say, std::vectors that will be repeatedly computed/accessed in various methods, but I will attempt to illustrate it within a specific context.
Suppose that I have two classes as minimally defined below. The Conf... |
I am in the process of migrating the way an app makes persistence of its settings.
It wrote and read data from registry;
now it is desired it load/save XML files on the C:\AppData\MyApp\Version folder
for several reasons.
It had lots of folders on the registry.
1st question: Whats is the best approach: A mega file hav... |
If I have a complex unit tested function:
def do_everything():
# turn twizzles
# push buttons
# move mountain
And I re-factor it into some smaller units:
def do_everything():
turn_twizzles()
push_buttons()
move_mountain()
def turn_twizzles():
# turn twizzles
def push_buttons():
# push... |
The Foreword
Hi! I'm just your average, fairly beginner, computer science student doing personal programming side projects, and who is probably out of his depth and has no clue what he's doing. So, I might need some extra help/explanation to understand things.
The Context
Games and Branching Narratives
It's very frustr... |
I have ASP.NET MVC application with the following controller and action:
public class AccountsController
{
public ActionResult Index()
{
var accounts = _accountsManager.GetAccounts();
return View(accounts);
}
}
and AccountsManager class like this:
public class AccountsManager
{
privat... |
I understand the difference between ordered and unordered sets, and I understand why for many purposes, we don't need ordered sets. But all set operations are still possible on ordered sets, and sets have to be stored internally with some order anyway, so why aren't sets ordered by default? Is the performance impact of... |
I got into a conversation with a coworker and we talked about reflection in PHP language. I insisted that instantiating instances of class using variable variables syntax like following is a reflective technique.
<?php
$className = 'Animal';
$animal = new $className;
My coworker differed in opinion. I did extensive ... |
I'm starting to wrap my head around PHPunit.
My questions is the following.
Whenever I use variables that do not change within my range of test methods I can initialize them within my setUp() method. Otherwise, if they do change, I should rather put them directly in my test methods.
Is my assumption more or less righ... |
Considering a solution that has some manual DI going on such as the below class, is there a better way of managing the concrete implementations without adding a container. This is theoretical, there is no real test case but something I was thinking of earlier.
The below DI example is fine, however it's preferred that c... |
My new team where I work are currently discussing how we go about changing our current old monolithic applications to go down the route of microservices. We are still at the early discussion and proof of concept phase.
The first proof of concept we are trying out, at a high level, is to mimik a customer adding somethin... |
I understand classic branching and deployment model as saying (in some small variant of the below):
makes the changes on dev branch
merge dev > staging branch, deploy to staging server, test it out
merge dev > production branch, deploy production server.
dont make commits directly on staging or production branches. On... |
This is the scenario in which I have to apply some creational pattern.
Build a fleet of 10 cars with the following features. Five cars should have all the features and five should be built without the lidar and ultrasonic sensors:
Radar sensors dotted around the car monitor the position of vehicles nearby.
Video came... |
What is the correct term(s) for different types that contain exactly the same information? For example (F#):
type Type1 = (int * string)
type Type2 = (string * int)
When describing that these types can contain exactly the same information, I could say that Type1 and Type2 are ______. Which word(s) could I use?
And is ... |
So i have a modified knight's tour problem. The problem is the following , is there an algorithm that can give you the route(if possible the shortest) from (1,1) to (n,m) in a chessboard of the knight piece? And also if some blocks are blocked
Eg. i have 3x5 chessboard and the blocks (2,3) and (2,5) are blocked. Is the... |
If I want to calculate the movements of each moving objects driven by regular algorithm, then how can I measure required computing power? Is required computing power proportional to the quantity of the objects?
|
I have interesting situation here, which I'd like to draw your opinions upon. I'm designing a REST API and here are the Resources pertaining to this question.
I have an User Entity, which I create through POST /users/ and Read-Update-Delete(RUD) by /users/:user-id
I have an Event Entity which I create through POST /ev... |
I'm just a junior developer but in about half a dozen projects I worked on there's always this situation:
Service methods that take big objects as parameters, but often use just a little portion of them. Let me try to clarify with a little bit of code:
class WorkforceService {
public void assignEmployeeToWorkplace(... |
How are variables abstractions for the memory cells of the machine? Is it because you can change the value stored in the memory cell by assigning a different value to the variable associated with the said memory cell?
|
I have a Django project. All the apps are separated nicely. Each apps often have functions that are used across the apps. Currently I place them in module named wrappers (for wrapping django/built-in/3rd party functions) and shortcuts (for wrapping django/built-in/3rd party functions with hardcoded arguments).
For pure... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.