instruction stringlengths 34 36.1k |
|---|
I am using Python's peewee ORM to map my relational database, but I'm noticing that my models are starting to get bloated and I also seem to be violating separation of concerns.
For example, my User class has self explanatory methods such as
authenticate()
push_message()
upload_image()
Even though it's useful to call ... |
I'm planning a database which will contain data for many projects / customers.
Data for each customer will be totally independant. However they will all have the same structure.
So I'm wondering, could making a schema for each customer (and duplicating tables in it) be a good option ?
To resume, I ponder between the t... |
My application interacts with an external system. There are multiple request-response interactions for a single business case. This information (request and response messages) is also logged in MongoDB. The structure is similar to:
{
_id: ObjectId("..."),
caseId: "PRC-122",
msg_date: ISODate("2017-06-10T11:21:41.112... |
I am supposed to design the tests for state machine software. I have covered all states and all transitions. The last step is to detect the hidden states (states that look the same but internally might be different, e.g. overflown buffers) using the tests designed with characterising set W. I have no idea how to determ... |
I've been working in an app that handles relations and constraints in application level.
How would this affect changing databases while keeping the application software?
This would mean the database would just be 'Data persistance as a service'.
How would this affect decoupling, modularity and orthogonality?
|
In many years of OO programming I've understood what discriminated unions are, but I never really missed them. I've recently been doing some functional programming in C# and now I find I keep wishing I had them. This is baffling me because on the face of it, the concept of discriminated unions seems quite independent o... |
I have two type of entities: User and Resume. So my instinct said me to write two controllers.
UserController endpoints:
/users
/users/{id}
/users/{id}/resumes
ResumeController endpoints:
/resumes
/resumes/{id}
/resumes/searchBy[?criteria={criteria}]
User has a reference to resume, so to create one I do a POST to ... |
I have a requirement that is a user of the system can make a complaint about an organization and then the admin can blacklist that organization. Do I have to include the use case "Make complaints"(of user) to the use case blacklist(of admin). Please help me with this matter.
|
I have been reading a bit about Kanban and I am slightly confused on the topic of Requirements.
In my current project we use Scrum. At the beginning of a Sprint, we have a session where the BA does a walkthrough of the Story and describes it as best she can. We then take the story, review it, discuss it and prepare a ... |
What are the best practices regarding start of an application which depends on several services and maybe some file system stuff like mounts, directories or config file.
Let's say the dababase is not up or returns a fail status when the application starts. Should the application:
fail to start and report this error or... |
I would like some input on some refactoring I am to do on a mobile backend (API).
I have been tossed a mobile API which I need to refactor and improve upon, especially in the area of performance.
One (of the many) place where I can improve the performance while also improve the architecture is how the backend currently... |
This is always a problem for me. Say, in a game, there's a class representing an enemy spacecraft named EnemySpacecraft and there's a class representing some collection of those, say all that exist in the game. This class may be implemented as just an encapsulated array of enemy spacecrafts. Giving this class a name li... |
What's the needed math for building algorithms? Because I was reading a book and I can't understand much. It says I need simple math from high school.
I don't want to learn all the math that exist because I hate math, no that much though. What math is actually required?
|
I have the need to match incoming fragments of semi-structured text to previously encountered fragments.
The most text fragments are sized ~200 to ~4000 characters and contain both human-readable text (a few sentences at most) and machine-generated text - string and numberic codes, IDs, URIs etc.
I've used K-Means clus... |
How can you know if something is "pure CRUD solution" ("just CRUD")? It seems complexity is a hard thing to define for the various DDD proponents. Everyone says if it's "just CRUD" you don't need DDD. What does "just CRUD" mean? Every application I've made has CRUD operations somewhere.
I realize there are differen... |
I've made a small change to an integration component and have prepared unit tests to cover my work. All new and existing unit tests are passing.
It will take a substantial amount of time to configure and run the component locally as I will need to restore databases, check firewall rules etc.
The definition of Done in t... |
In short, this question is about the cross-browser-compatibility-ness of a way to serve a HTML page as XML. I am interested in serving a web page as XML to be interpreted as HTML for increased CSS performance by removing the user agent style sheet. The reason for this concern will not be explained as it already has ca... |
I have a Hotel entity which can have many address and many image objects i.e. they are one2many related with the hotel.
The question arises while fetching and saving the linked resource.
Fetching
I load the resource which is Hotel here which has the ids array of the address as well as image, these address contains the... |
Lets say A, B are classes then what does this UML diagram mean?
(1) A contains B
Or
(2) B contains A
I'm confused as to which direction the aggregation holds.
|
Say I have a LINQ query like this:
application = CreditDatabase
.Applications
.Select(Mapper.Map<Application>)
.Where(c => c.uID == urID)
.DefaultIfEmpty().First();
It returns null if the LINQ query returns an empty result... |
I am trying to implement the following pattern in a Cache layer.
I'm splitting the implementation of possible Cache methods such as getUsers() in UserCache Class, getLikes() in PostsCache class.
But I'd like all these methods to be accessible from a Single class object such as Cache.getUsers() , Cache.getLikes()
The re... |
I'm starting to learn more about software development, I'm still learning it, so some things are still difficult for me. Also, just to put in context, most (or basically all) of my projects are online projects (WebApps, e-commerce, crm, etc ...).
I was reading more about how to plan a project before starting it but I h... |
In this post, there is:
For example, with your own persistence model, you are not able to
benefit from the built-in change tracking functionality. And that
means you will not be able to implement reliable domain events – the
ones which get fired only when a transaction gets committed to the
database. You eithe... |
Pure functions are known to facilitate parellelizing.
What is it about functional programming that makes it inherently adapted to parallel execution?
Are compilers such as Javac smart enough to detect when a method is a pure function? One can always implement classes which implement functional interfaces such as Funct... |
I'm in the early stages of developing a game engine in C and so far I've been using a simple logging module to print error messages to a log file. For every possible error that could occur, I have prepared an error message that includes the file name and line number. This is all done using preprocessor macros so I can ... |
I've been looking for a good way to style a react component just using css stylesheets. I would have used style-loader, because it's as easy as require('./style.css') and allows to save the final styles into a stylesheet file for production, but... I'm trying to make a shareable react component (I will publish it as a ... |
I'm looking for perspectives on how risk analysis is performed when there's not precisely a "dollar value" associated with the risk, as in an Open Source project. Traditionally, risk analysis takes the form of
Asset Value X Annual Probability of Loss X Probable Outcome of Loss = Risk
Open source community driven projec... |
Say I have a function whose first parameter is used differently depending on how many arguments are passed. In this case, it is easier to just process the arguments object as a whole within the function definition instead of giving the parameter an explicit name to deal with that could be semantically incorrect dependi... |
How do you determine when and where to use a for loop in programming?
|
I have been using AngularJs since a long time. Me and my team makes heavy use of services for retrieving the remote resources like Users which intern uses $http service so, basically, for each entity, I have services which fetches/stores etc that entity.
I was thinking why not the entity itself should be able to do tha... |
There is a plethora of tools available for engineers to test their code these days. However, frameworks like Mocha.js came around only in 2011 with the ascent of NPM. So I wonder what were the practices around software design a few decades ago?
|
So far I have used to write interfaces to those classes I want to mock/fake. Reason for that is that those classes don't have any virtual method to overwrite. But resently I have figured out that I could use virtual methods also.
When should I use virtual methods rather than interfaces?
Should I even make most of meth... |
I am trying to build a mobile application (Android/iOS) and the app will require a lot of back end operations.
After doing some research I noticed that several developers recommended using MBaaS services only if the back end operations are very simplistic however since I have little experience using these tools I had t... |
Please see the Rules Design Pattern on this webpage: http://www.michael-whelan.net/rules-design-pattern/. It has classes like this:
public interface IDiscountRule
{
decimal CalculateCustomerDiscount(Customer customer);
}
public class BirthdayDiscountRule : IDiscountRule
{
public decimal CalculateCustomerDisco... |
I am working on a number of maintenance projects and I always include requirement/issue number/code in the the comments whenever I am adding or changing code. In such way I provide traceability from requirements to the code and back. My experience is that such effort can be of really great help for furhter maintenance,... |
I'm getting familiar with an existing Akka.NET codebase and the actor model itself, and I notice a number of actors are configured to receive empty messages and do their work.
class Invoke
{
}
class MyActor : ReceiveActor
{
public MyActor()
{
Receive<Invoke>(i => /* do work */);
}
}
The use of a c... |
I know we can use the Mediator Pattern to communicate between view models but what about views?
Lets assume I have a button in View A which should trigger functionality of View B. How is this preferably done? I could use the Mediator but it seems more like a hack.
Here is a thought of mine:
|
We are building a system where we accumulate data from many of our internal services, process them and generate set of data called Jobs saved to database. Our client application running on client systems periodically requests for these Jobs and eligible Jobs for the requested client will be sent in the response. For ea... |
This question is about the architecture approach.
How would someone go about creating the immutable state for a graphics editor that would eventually provide an "undo/redo" functionality, considering that the library for canvas manipulations already has its own state management.
I am not sure that I'd be doing the righ... |
Consider the following application structure.
The scraper class extracts the necessary information from a page, and I want to save it to the DB.
The ORM class is a wrapper around sequelize.js. It establish a connection to the db, loads the models, synchronizes with the db.
app.js inits the ORM, then the Scraper class.... |
I am trying to learn the Rules Design Pattern as described here: http://www.michael-whelan.net/rules-design-pattern/ (towards the bottom of the webpage). I have written a class like this:
public class OfferCalculator : IOfferCalculator
{
public List<IOfferRule> _rules;
public RulesOfferCalculator(... |
I'm planning on making a web app that'll use MySQL as the database, Java/Grails as the backend and JavaScript/VueJS as the frontend and then they'll communicate using only RESTful JSON APIs (that way I can have frontend apps running on any platform, all with the same backend). What I'm thinking is that every action (th... |
I am considering using a strategy pattern for configuration file management, that way I can support some legacy configs. I feel pretty solid on the overall design (as its pretty standard strategy pattern), but I am curious if the client should know the type of strategy that is being implemented or if that violates th... |
TLDR;
Is there a AMQP equivalent inside Service Fabric for Stateless services for communication between microservices?
I am building an application which contains multiple microservices.
For starters this application will have microservices locked behind API gateway. This API Gateway is publicly accessible from either... |
In CQS, does the "C" (Commands) require one class per query; same with the Q. That is the examples I have seen, but didn't see it really defined anywhere. Also, I do not mean CQRS, only CQS. I do not know where I'd use R at the moment, so I am only using CQS.
Edit: What I'm saying is something like this:
class Find... |
This is my first question on this forum, have tried to exhaust every possible research option I could think of or find. Actually this is the first time I've posted for help with this anywhere, so maybe I should have started here... :)
I am trying to build an automated scheduling solution for a pool league, right now th... |
I'm going through an introductory programming book and it lists a simple example in pseudocode:
Start
input myNumber
set myAnswer = myNumber * 2
output myAnswer
Stop
Why can't we omit creating another variable called myAnswer and just put the operation into the output command, like this:
Start
input myNumber... |
I'm currently building an Android app that uses OAuth to sign in to a service. With OAuth, I need to provide a client ID and a client secret to the service so it can identify my app. Right now, I'm storing the credentials like this:
public class Creds {
public static final String CLIENT_ID = "THE_CLIENT_ID";
pu... |
Imagine that you're modeling SE (or SO) on DDD.
You decided to implement the "board" as an aggregate root. So the board has the method AddNewQuestion(string question).
There are business rules that dictate that a given set of partners (think companies that advertise jobs) should be notified about question tagged with ... |
Before I began developing a RESTful API I used a query similar to this:
$query = "INSERT INTO availability (user_id, date, status) " .
"VALUES ('".$id."', '".$date."', '".$status."') " .
"ON DUPLICATE KEY " .
"UPDATE status='".$status."'";
Yes, I know it's subject to SQL injection. Anyway, I... |
I built an app that display time series data. The display is very similar to a yahoo finance chart (ie https://finance.yahoo.com/quote/AMZN/). I am using Postgres to store the data because that was the database available to me when I was building it. The issue I am having is when I try to scale the different time frame... |
Background: I am new to testing in general, and have been studying it in context of JavaScript, specifically React.js, front-end development (actually new to this as well). For the question, I have these 2 similar cases:
Case 1: My code and a library
I'm using UI library and aside from its decent design, I want to leve... |
I have three resources Hotel, Address and Image. A hotel can have may images but only one address. While showing hotel details I need to fetch its address as well as all images of it so, in my controller the following code goes:
function getHotel(req, res) {
const { hotelId, merchantId } = req.params;
Hotel.search(... |
I have a web application (ASP.NET Core / C#) with 3 layers (web/presentation, business logic and data access).
I'm using Entity Framework to retrieve a record from an SQL Server database which is subsequently mapped to my model object. One of the retrieved columns contains an XML string where I need to extract some val... |
Please see the code below, which is a factory method in a rich domain model (domain layer). There are two things I dislike about it:
public class SalesPersonOfferFactory (Applicant applicant)
{
if (applicant.Age > 30 && applicant.Employed = true)
{
return new PersonOffer (52, applicant.... |
Our business team want long periods between deployments and once a build has been staged for their testing it must not be updated unless a fix is required.
This goes against our development team's agile process, which works on two week sprints and want to push changes forward as much as possible.
There is a business ju... |
I am trying to program a simple shopping scenario using event sourcing:
--------------- --------------- ----------------
| OrderService | | ProductService | | PaymentService |
---------------- ------------------ -----------------
|________________|_____________________|
... |
I've been working on a Python(Django)/JavaScript(AngularJS) based application for some time now.(I learnt all of these on the way, had previously been a Java only programmer)and have hit moments where the code was really unmanageable:
Single js script for the entire application, around two-dozen controllers, a dozen o... |
Say I have two machines with their own hardware and different specifications. They are PCs actually. The discussion here is if there is a way to put them online together such as their processing power could be balanced, like a cluster. Except, the cluster has a specific connection and the machines are homogeneous.
Is i... |
I am accessing a third-party API. It requires a key, which is the same key for all of my users. Currently, my application includes that key in the client-side code, and calls the third party API directly. So any user can decompile my code, and get the key tied to my application. (Bad, right?)
I am guessing that I n... |
I'm a .NET developer, currently writing an ASP.NET site hosted on our local servers with Windows, IIS, and SQL Server. We're speaking to a company in India about hiring a developer for a different site, written in PHP but ideally running on the same server: Windows, IIS, SQL Server. He does not know English very well.
... |
One of our products generates vast amounts of reasonably detailed logs into a database table and we're looking to analyse them, possibly build a report from them. Reports can be run on demand, which makes this scenario quite a good candidate for performing the log analysis once and storing the results; the result set w... |
I have a MVC application and a web api. The Web api contain all business logic and the mvc controller has only ui logic.
I want build a web api proxy but I don't know if it's a good idea.
With the web api proxy The controller is decoupled from the name of the action in the web api and from the verbs and dto used in the... |
I'm working at a company on a project for their Sales department. It's my first professional programming job, but I've been coding by myself and learning for years. Part of the project involves taking some data and combining it with input to produce and graph. Then save the data...so on and so forth. So I wrote the cod... |
I am on C++ and using gtest as the main framework. Say I have a edge detection function I want to test that takes an image as an input and returns the edge detected image. I have 3 images ready to be checked.
Is it better to write it in a way that is self contained like
void EdgeCheck(const std::string& input, const st... |
I am trying to convince him in an attempt to produce better code by separating concerns, isolate logic and following best practices.
He wants to produce readable/shareable code but is not entirely convinced that opening it is a good idea.
What other arguments can i use?
|
Please see the code below:
public void GetOffers(List<Offer> offers)
{
if (Validate() == true)
{
OfferFactory offerFactory = new OfferFactory();
foreach (Offer offer in offers)
{
IValidator iValidator = offerFactory.getO... |
I am making a design decision to real time hit API to save all the fields in a form when user make an change even if hes not finished yet. Or, use a save button like most app does.
Any pros and cons other than
pro : real time will generate much more API calls thus heavier server / db load
con : user won't lose any da... |
It's maybe an old horse to beat (not dead yet?), but I'm wondering if OCL allows modeling the problem of the business rules for building houses and hotels in the game of Monopoly within a domain model (conceptual class diagram, separate from an implementation).
I've supplied the rules after my naive attempt, but I'm n... |
Pipeline processing of data can be done either,
using generators only
Example generator in pipeline:
def grep(source, pattern=None):
patternObject = re.compile(pattern)
for line in source:
if patternObject.search(line):
yield line
or
using coroutines only
Example coroutine in pipeline:
@corouti... |
Recently I started a project which didn't seem too hard to make, the concept was a fairly simple application that had to accept input every now and then (maybe 10x a day), and try to perform some operations on them and collect all results at the end. This application would then get a front-end web portal that customers... |
Designing a small API on the side/for fun/for experience. One issue I've run into is URI routing. The issue is:
GET /users/{id} // Get user data
GET /users/availability // Get all users' availability
Both of these map to the same controller@method based on which one comes first in my Routes.php file.
The function... |
General question regarding the STL. Do you guys think that the STL should be used for data structures or would you create custom code? In what scenario would you implement your own code for something that the Standard Library already does? What are your thoughts?
|
Say, I have a code/password like this:
abcde123 --> 8 characters
Where only letters and digits are allowed. How do I calculate the amount of all its possible values? I'm doing this the following way:
1) 26 letters + 10 digits = 36 full alphabet
2) 8 length ** 36 full alphabet = 324518553658426726783156020576256 values... |
Class Book
{
private int year;
private String session;
private int volume;
private int number;
private String khand;
private Date proceeding_date;
private int pageNo;
Book(year,session,volume)
{
$this.year=year;
$this.session=session;
$this.volume=volume;
}
public getBookName()
{
re... |
I have a surveys website. I want to add a feature "level of happiness/unhappiness".
Database schema is something like this:
1) Question
2) Answer options (for some questions single, for some multiple ones allowed)
3) User's answers (question_id <--> answer option id)
Namely, I'd probably need to assign a special co... |
I am writing a C++ applications in the embedded area. A lot of times I think about should I use static or non-static const variable in the functions/methods? Here are my thoughts:
Static constant variable eats memory while the app is running, this leads to a more memory consumption and less memory available on the dev... |
I'm an intern software developer and in my career I've occasionally heard the term 'silo' being used. I've looked into it myself and tried to nail down exactly what it means, but I seem to be getting mixed results. By my understanding, in a general context it means keeping something separated and abstracted away from s... |
I'm working in a team where there are several different OS present (windows, various linux distributions (Ubuntu, Mint) as well as Macintosh). Projects are passed around and we have already come across some issues.
For example the total path length in windows is 260 characters, whereas linux is more relax (though this ... |
From all I read and watch, Domain-Driven Design (DDD), is a costly and time-consuming endeavor. In fact, everyone I have seen, including Eric Evans and Greg Young, say, don't use DDD except where you have a "Competitive Advantage." To find that advantage it kind of drops off into various discussions of business and T... |
I'm writing an iOS app in Swift that calculates a '1 rep maximum' weight using two inputs, weightLifted and repetitions. One of several formulas is used to perform the calculation with these two inputs to arrive at the answer which is the 1 rep max. I'm only storing the input values, not the 1 rep max value. I'm also s... |
I have the following scenario: a client app that consumes a REST API. The client is a mobile application. Therefore, it caches the API data for bandwidth saving and offline support.
With REST it can be done using the If-Modified-Since header. It is, the cache management system from the client side stores the HTTP-Date ... |
I have a hotel entity which has a set of images. I have some business rules which are basically simple crud operations right now. I have heard of repository pattern but working with it I feels like procedural mindset.
Let me give an example, I need to fetch all the images associated with a hotel.
'use strict';
const m... |
I'm in the process of writing a development philosophy document for a small groups of developers (6.5 developers to be specific), but it's ideally a document that will set down the company's best practices as our team scales up. In the process of creating this document I've been interviewing each engineer to understand... |
We use Github and Smartgit.
We are often finding we have lots of "old" branches that clutter up our repos and cause confusion among our Dev team, I can use: git branch --merged for a lot of this.
So I'm seeking to define the rules for safely deleting a branch from an upstream repo, here (in English) is my suggested "al... |
Is there any reason not to build JSON data that can be indexed by some key? For example in the WhenIWork API below, using the user's id to quickly access the data? The reason I'm asking is because it seems that for a lot of uses on the client side you could easily index into the array then and grab the data you need ... |
Without using big int classes in C++, what's a good way to handle arithmetic on large numbers?
For instance, writing a Vector class that deals with dot products and cross products using large doubles can result in non-finite values. Do I leave this up to the user to handle NaN's/(-inf to inf), etc.? Or do I somehow ha... |
I read the first chapters of Clean Code by Robert C. Martin, and it seems to me it's pretty good, but I have a doubt, in one part it is mentioned that it is good (cognitively) that the functions should have as few parameters as possible, it even suggests that 3 or more parameters is too much for a function (which I fin... |
Suppose I have a DAO which touches the DB.
Should the DAO return only data and then it's up to me to do the instantiation or is the DAO supposed to also do the instantiation and return me the instance - and why should I choose one method over another?
// Example with instantiation
studentDAO = {
getById: function() ... |
I seem to have trouble understand the Semaphore implementation.
Q = Queue.
Wait(Process P) {
value = value - 1;
if (value < 0) {
add P to Q;
P->block();
}
}
Signal() {
value = value + 1;
if (value <= 0) {
remove P from Q;
wakeup(P);
}
}
I don't understand why the sig... |
Every day a couple of new javascript modules are created and published around the world and we need to think long term. Let's say today I need to use an ORM module to go smooth and fast. But tomorrow I may face a deprecated module or may find a better one to switch or even may need to create my own.
For example, the te... |
I am designing a treeNode class. While implementing the getPathToParentNode() and getPathFromParentNode() methods, I noticed that their functionality is essentially the same - they just operate on different data structures.
getPathToParentNode() recursively adds all parent nodes into a queue, and then creates the path ... |
I’ve read the answers to Why is Global State so Evil?, and I think the negative consequences do not apply in this situation. However, that’s what everyone says just before they get hit by a falling piano and my software architecture lessons have been a few years ago, so…
We are developing a desktop chat application in ... |
The problem:
Since long time, I am worried about the exceptions mechanism, because I feel it does not really resolve what it should.
CLAIM: There are long debates outside about this topic, and most of them struggle at comparing exceptions vs returning an error code. This is definitively not the topic here.
Trying to de... |
I've gone through a few tutorials in ASP.NET Core MVC, and I've built a little app (for looking at problems in old exams) that looks roughly like this:
Solution
Project
...
Models
Exam.cs
Problem.cs
SubProblem.cs
Views
Exam
Inde... |
I'm having a hard time understanding the b) point from the following statement.
The base of a triangle has a length of 25 cm. Its height is 12 cm. This results in an area of (25 x 12) / 2.
a)What values can be considered parameters for the above statement?
b) Rewrite the statement in a parameterized manner.
c)Which of ... |
Given I have a type we'll call Person defined as
// psuedo code
Person {
Name: string;
Age: int;
Friends: Person[];
Career: Career // black box and assume that Career
// is a type with a few arbitrary properties
}
Given I have two instances of the Person type, we will call p1 and p... |
I have this sequence diagram and want to transform it into a class diagram.
But I don't know if the actor (Customer) is in this case a own class or not. Normally the actor isn't a own class, but in this diagram there are methods performed on the customer...
|
Should a DAO save() method set the id/pk of the instance that is to be saved and return the instance or should it just return the PK?
// Example A: Return the instance
studentDAO = {
save: function(student) {
const id = db.query('INSERT INTO `students`...');
student.setId(id);
return student;
}
}
// E... |
I have a highest-level diagram / map / picture of connected networks where internet is pictured as a cloud, some physical machines, firewall, switches etc which describe an overview of the "ecosystem" / at large scale.
Is there a name for such a diagram?
It might not make a difference that this particular diagram does... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.