instruction stringlengths 34 36.1k |
|---|
I'm working on a larger solo project and right now, and I have several classes in which I do not see any reason to create an instance of.
My dice class right now, for example, stores all of its data statically and all of its methods are static too. I don't need to initialize it because when I want to roll the dice and ... |
Context
I'm about to start a new project for my company1 which architecture will comprise several elements. There are 2 mobile applications (Android and iOS), a web API (Java) and an ETL (still deciding whether I use NodeJS or Java).
The system should extract data from several OpenData repositories (web APIS), transfor... |
I preserve old software by asking copyright owners (often one author) to release the source code under an Open Source License, GPL or MIT. In many cases the source is gone, but the binaries still exist. Often they were released under some home made license 20 years ago. If I'm correct the binaries could be released und... |
I created a new Asp.Net MVC web project. I took the decision to create two different apps, the first one would be a web REST API that would provide all data for the second one, which would essentially be a MVC web application without any database interactions. It seems to me like a great way to separate business logic ... |
I've been using this term with a loose understanding as heard in the phrases "uses base python", "built on base python" that basically suggests a python project that only depends externally on Python Standard Library modules alone.
I've recently been exposed to the lingo of system python, and seeing comments like # SYS... |
I've seen a couple other posts about people trying to run untrusted user inputted code into a eval or exec statement.
My implementation checks the code before hand for any import statements, makes sure there are no builtins on the exec statement and clears all the global variables. I also put checks in place for the us... |
I'm creating a program that analyzes comments in Word documents (in terms of their textual content). However, occasionally one who wants to analyze the textual data may like to change some of the comments content. Yet I think it's better to leave word processing functionalities to the word processing program itself and... |
I am building out a parser for a well-known track & field meet management software output file (sample output).
I can parse this manually, and put items into my object model (overview below), but it's a bit time intensive, and it's going to have manual issues.
FYI, I'm using C# but I have no problem crossing boundaries... |
I don't mean to come across as glib, but I feel that the clearest way I can communicate what I want to know is through some analogies:
CPython, gcc, javac, ... -> compilers
MS Windows, OS X, Ubuntu, ... -> operating systems
PCRE, re2, ... -> regular languages and FSM
Android Layouts, iOS xib files, HTML/CSS, -> ????
... |
So I've been working with background processing and event-driven systems, namely Azure WebJobs and ServiceBus. And while there is extensive use of async/await programming, I'm always wondering if it is generally bad practice to await asynchronous operations when not at all needing the results further in the program. Mo... |
I am working on a sports scheduling algorithm with several different constraints, one (two) of them being a minimum and/or maximum wait time between games. Of the same team, that is.
So if Team Blue is scheduled at 4pm (finishes at 5pm) in Field 1, and we have a maximum wait of 3 hours and a minimum of 1, then its next... |
I'm trying to define a base class and override it's items on different inherited sub-classes. I'm following MVVM pattern to fetch records from backend. Created several stores and formulas within ViewModel.
+---------------+---------------+
| NUMBER value | |
+---------------+ GLYPH value |
| STR... |
I'm wondering how I can document **kwargs in Python using sphinx dostring style.
For example I have the following method and I want to document more details about kwargs.
def get(self, url=None, **kwargs):
"""
InsReq get (overriding)
:param url: url
:type url: str
:param kwargs: How to document th... |
I have a situation where in a class I have 2 constructors and they have very similar code. The only difference is the the call to the constructor of the super class. Where should I put this common code? I tried to use the instance block but with instance blocks I am not able to pass arguments required.
Also, the fields... |
I've been reading Robert Martin's Clean Code book where it suggests we should separate a programs startup/construction process from its run time logic.
In Java (the language the book uses) this involves moving all aspects of construction to main and designing the rest of the system assuming all objects have been constr... |
Is it possible to say that the difference between imperative programming and declarative programming is merely in the level of abstraction? I.e. where the imperative programming will say "break the eggs, put them into plate, turn the oven to 180 degrees, etc", a declarative language will only say "cook me eggs"?
|
At my new work I am dealing with a quite big C/C++ project (50k lines in multiple files). I usually "draw" what the code is doing to understand its functioning but this time I am struggling a bit because of the code's size. Is there a technique that you use to such a purpose? The common algorithm notation with 2D shape... |
I am working on a project (to use as a reference). The project uses mysql, hibernate and spring (REST) and is supposed to be a single microservice.
I have come to find out that limiting user/consumer database access to stored procedures in mysql is considered a better practice security-wise (no unintended operations, a... |
I'm currently developing an Ecommerce application and am trying to figure out how best to add a 'guest checkout' feature. The 3 main models that I am wrestling with to add this feature are Address, User, and Order. An Address needs a User, and an Order needs both an Address and a User.
For our guest checkout we don't w... |
We've created a simple 2D game, it has fields and elements on it, the player can move the elements. The game has two views: a graphical (with images), and a textual (printed to the console). But only one at the time, and the game's logic must not know about the actual view.
To solve this, I created a factory interface.... |
Struggling to handle aggregates and aggregate roots when it comes to persisting. For example, I currently have a repository for each aggregate/table, but this is causing some issues in my service class.
Current JournalService
public class JournalService
{
public JournalService(IUnitOfWork uow, IJournalRepository j... |
I have to design a Class for ATM cards with the following attributes:
Cardholder Name
Card Number
Pin
Other than getters and setters, I have a method to validate the pin of the ATM. As per the principle of encapsulation all the methods related to the ATM should be part of the ATM class.
But in case, later we need to... |
Let's say i have a table (in a large enterprise application) that has about 10 columns.
I am limiting any consumer access to the table to only be possible by calling stored procedures.
When it comes to updating a record in the table, i basically have 2 options.
One stored procedure to update all the columns of the tab... |
Right now I'm using Direct Exchanges (i.e. one queue per "topic", pretty much pushing messages directly to a queue). This works OK, but I'd like the flexibility of working with Topic Exchanges, specifically multiple consumers subscribing to topics without destroying the message (i.e. multiple queues per topic).
The com... |
I'm working on a free proyect over Github. I fork it, made some changes, did a PR and everything worked ok (PR was accepted).
Then I update my fork with upstream, did some other changes, and made another PR.
Then I realice that my PR included all the commits I pushed earlier, and every file I modify, even the ones I al... |
We are developing a system with coarse microservice architecture. We have an API that uses controllers and back-end logic with Entity-Framework repository, and several types of clients that use this API, all in dotnet, therefore, typesafe.
We need to use some sort of data transfer objects for communication between the... |
For example, suppose my app have some localization texts. My question is, should I load appropriate locale at start:
var locale=userPrefs.getLocale();
localeStringMap=getLocaleTextFromFile("locale_string_"+locale+".json");
//some other code
//.
//.
//.
var message=localeStringMap["welcome_to_use_the_app"];
or get th... |
Google describes the rules for Firebase as:
You are required to notify
your App Users by disclosing the following information:
The Google Analytics for Firebase features you have implemented.
How you and third-party vendors use first-party cookies, or other first-party identifiers, and third-party cookies and simi... |
I develop a WPF application using MVVM and I am learning how to do things best.
I have a WPF form with selectors, two list with search fields, and some other elements. Currently all is in one form and it works. But by now the VM for that form has more than 800 lines and it is not yet finished.
I want to structure this... |
Our application creates audit trails in response to system actions and user actions. Our business logic depends on these audit trails to find out which user performed what action.
Is it good practice to have business logic use audit trail data?
|
I have function that takes as arguments a number of classes of average complexity.
When writing docstring for that function, I'm running into a series of questions: Should I describe (besides what the function is doing) those classes too, or can I assume that the reader will dig up the class definition? Or should I po... |
I'm working on a system with hard real-time constraints in c++ and I need a very fast way to calculate the rolling/moving/streaming median of a set of numbers of size N=100 to 300. Normally this size would be trivial but in this case the algorithm will run about 1000/2000 times per 0.1ms
Every calculation a single valu... |
I found this question
Return magic value, throw exception or return false on failure?, however it is kind of broad. I would like a more specific answer.
Say I have a method called Connect() which connects to a remote device over an Ethernet socket. If the socket fails it throws SocketException.
So the way I see it I h... |
I'm designing a REST API that needs to allow me to send messages to members in the system.
Right now, I'm thinking about creating a /messages endpoint that I make a POST request to when I want to send a message, providing a member's ID and the message content. The problem that I see with this approach is handling the c... |
What name should I give classes which are just for configuration? For example, when using JAX-RS, every application is required to have an Application class which extends the superclass javax.ws.rs.Application like so. The Application class is just to register the list of resource classes.
public class APPLICATION_NAME... |
I've been writing web applications for almost 10 years. The ASP.net stack has been my bread and butter and although it has a lot of great things about it, I honestly never chose ASP.net. It's just a matter of what my employers and clients wanted.
Recently, I had the opportunity to prototype something I was working on... |
I do a lot of work in various languages, most of which are scripting languages such as JavaScript, Shell Scripting, PHP and so on. But I do also work a lot with Java, which is closer to a more "real" language.
C/C++ has been an interest always, but have not had much use for it. I did have a few small things in some Ja... |
I am very new to Domain-Driven Design. I have come across a part of a domain which I'm not sure if I have modeled in the best way possible.
There is a Membership entity which has a membership type.
public enum MembershipType
{
TypeA,
TypeB,
TypeC,
TypeD,
}
Each Membership can have 1 or some Businesses... |
Given that a lot of modern web applications just consume JSON data from the sever, what is the point in having a REST api at all instead of just using SQL's query language?
Nowadays people are starting to use GraphQL. From what I understand is a query language from the client to the sever, which then gets translated i... |
Today, I searched for includeOS and I found that it defines itself as a minimal unikernel.
I am wondering what is UniKernel. The wikipedia explanations are not clear enough to me.
Is unikernel an operating system incorporated with a single application for a special purpose similar to embedded systems?
|
If data structures such as trees and certain sorts(quick sort, merge sort) work using recursive algorithms and recursive algorithms take up a lot of memory space in the stack and can only work on a limited data sets(if not it'll lead to stackoverflow), then how come trees and the aforementioned sorts used practically t... |
I am working on the domain model of an application that stores information provided by sellers about the goods they sell on a platform. The application just acts as a data store for this information. The information is called as an "ProductFact", and may be diverse. Each example below represents one "ProductFact" insta... |
At the end of this article from Martin Fowler there is this sentence:
In general, the more behavior you find in the services, the more likely you are to be robbing yourself of the benefits of a domain model. If all your logic is in services, you've robbed yourself blind.
What the whole, very abstract article, doesn't... |
I have a class, which looks like this:
public class Customer
{
private readonly IList<Order> _orders = new List<Order>();
public FirstName FirstName { get; set; }
public LastName LastName { get; set; }
public Province Province { get; set; }
public IEnumerable<Order> Orders
{
get { fore... |
I don't have more than 6 months of experience and I am a little lazy . I work on Android platform . I have very good skills in understanding what is happening in general . The problem is that I don't have the experience to read and understand someone elses code (btw I just got a new project which I will develop a new f... |
Currently I have an entity called Product with the respective ProductRepository and ProductService.
For ProductService, I have tests for:
Read (Covering Create too)
Update
Delete
Besides achieving higher test coverage, is there any particular reason to also test ProductRepository?
What I think:
It could be possible t... |
I am learning about SOLID principles in a Pluralsight course where Command Query Separation is being discussed. I am fine with the query functions returning something (and crucially being non-mutating).
The question I have is about commands. The idea here is that commands should return void. What if there is a problem ... |
I have been using git for a while now primarily on CLi. I am the only person
working on this project so far. I just have 1 master branch and 1 production
branch. The production branch is named such that all tests in that branch
pass. I work directly on the master branch.
I had a issue recently, which prompted me to thi... |
From what I can tell from Scala and Hack-
Mixins:
Can have state (ie. instance properties)
Can only provide concrete methods
Can have constructors, that are called in the same order that their classes were mixed in
If A mixes in B and C, A instanceof B == false and A instanceof C == false
Traits:
Can only provide me... |
I have many substrings(2-5 words each) which I would like to search in some text of about 40-50 words length. What is the most efficient way to flag matching substrings.
Currently I am simply using:
for substring in substrings:
if substring in fullText:
return True
substrings - the list of strings to be searc... |
I'm creating audit tables to track changes made to some of my crucial tables and I'm wondering whether there's a point to history rows having their own id. Here's how my interfaces look like:
public interface ITrackedDbEntity : IDbEntity
{
Guid GUID { get; } //pk, unique
int Id { get; set; } //unique, not pk
... |
I am just designing my application and I am not sure if I understand SOLID and OOP correctly. Classes should do 1 thing and do it well but from the other hand they should represent real objects we work with.
In my case I do a feature extraction on a dataset and then I do a machine learning analysis. I assume that I co... |
I have a class called Book with fields such as title, type etc. I also have a class called Library that manages books.
Library has methods that:
Add a copy of a book on a shelf
Move a copy of a book from a shelf to another
How Can I manage the fact of the copy of the book?
One solution is create a subclass of Book,... |
I'm trying to improve my skills in planning out clean, modular projects with minimal coupling. Is it best to keep objects as generic as possible?
If so, are there any pitfalls I should try and avoid when designing architecture?
|
Note that I cannot use static inheritance due to language limitations (Java).
There is a general Building class. Each instance of Building has properties that exist regardless of instance variables (such as width, length, max level, BASE damage). There are numerous types of buildings, such as resource and defensive, an... |
I am looking to create a random username based on a set of existing phrases plus an integer since there can be multiple users with the same phrase. For now lets assume there's 12 phrases such as AnonymousPotato, so a user who signs up could randomly receive AnonymousPotato12345 as a unique username. The user would be s... |
I am writing some code that really smells but I can't figure out exactly why.
I have documents that exist in multiple languages. I want to be able to serve a document in its requested language and be able to switch it out for other languages when requested. On my database the documents are separate entries with identic... |
As far as I know both the regular and enterprise developer programs both have a 100 iPhone limit for development. I don't mean distributing the app for testing where the limit is higher, but for plugging the phone in for debugging with Xcode.
How do larger companies deal with this limit? If they have multiple teams tha... |
I've written a few things using .NET Core and like it a lot. So far, I have always used Visual Studio Code (which I think is very good and getting better all the time) and have enjoyed being able to pick up work on a Mac. I've been using Visual Studio less and less as I do more using .NET Core.
However, last night, I a... |
I would like know opinions about the next sentence:
"In a object oriented static typed language you should declare variables and parameters as broad as possible and return types as narrow as possible"
In some extreme this afirmation could produce this code:
interface anyInterface<T> {
Collection<T> getCollection()... |
Are there objective, supportable software-engineering arguments for or against modifying the values of by-value parameters in the body of a function?
A recurring spat (mostly in good fun) on my team is whether or not parameters passed by value should be modified. A couple members of the team are adamant that parameters... |
In refactoring some code I found a helper method get_records_from_file that has a complex return signature:
class RecordDefinition:
def __init__(self):
self.foo = None
self.bar = None
def get_records_from_file(file_name) -> Dict[int, List[Dict[str, RecordDefinition]]]:
...
After some inspection I... |
Here is a diagram of how our source control setup is configured.
The issue with this setup is how we handle various customers. I would really like to use a different approach than copying the entire baseline for each of our customers. I think further down the road this will become a major problem to maintain.
How can ... |
Assuming I have the following (over-simplified) class structure:
class Base
{
public:
Base(int valueForFoo) : foo(valueForFoo) { };
virtual ~Base() = 0;
int doThings() { return foo; };
int doOtherThings() { return 42; };
protected:
int foo;
}
class BarDerived : public Base
{
public:
BarD... |
We are using version in following format:
Major.Minor.Bugfix.Test
Development for upcoming release is going on in the trunk. When enough features are done we are creating a new release branch: 1.1, 1.2 and so on.
After branch is created there is a continuous "stabilizing" process, producing test versions of branches:... |
We have some fields (age, visit type, insurance type, city) and some rules:
Some doctors that define weekly schedule template like as:
Doctor D1 works on Monday 7-9 pm , Thursday 7-9 pm.
Some type of Visit Type like as:
Doctor D1 accept Follow up- Laser- Rhinoplasty.
Some type of counters rule in specific time r... |
I'm midway through Eric Evans' DDD book but don't think this question would be answered in the book.
If an application has its own complicated concepts different from the underlying domain, can we create another domain model for representing the application too?
An example would make it clear. Say, the core domain of a... |
The "Three Questions" for Scrum dailies sound to me like a perfect instruction, to waste 15 minutes with useless status reporting:
What have you completed since the last meeting?
What do you plan to complete by the next meeting?
(impediments...)
It often goes in the way of: "Yesterday I did task X, today I will work... |
I'm having troubles with using the right workflow with TDD. Some people say we should design before writing any code, some say we should make a test, make it pass, then refactor the code and that should help our thinking to find the right design.
But everyone say you should have 10 times more unit tests than integrati... |
We had a contractor visit recently who questioned our methodology of structuring projects. Please note that I am specifically referring to the directory structure. He suggested using the Microsoft guidelines. I thought I would be able to Google "Microsoft guidelines .NET project directory structure" and find somethi... |
The date format should support different timezone and Daylight saving issues.
|
For a match I have certain number of players, certain number of groups (players and groups are aliquot) and certain number of rounds to be played (players are reshuffled every round). Ideally, I'd like players to meet new people every round.
It seems like a common problem that had to be solved many times before, If I o... |
I had a recent code review that gave me some slightly surprising feedback. It was in an instantiable service class that had a number of fully encapsulated private methods. In other words, methods that didn't reference any higher level functions or variables. For a trivial example:
private decimal IncreaseByPercent(deci... |
I have a CQRS system in development that passes the Command to a CommandHandler, which gets an Aggregate from a Repository, and calls a method with the properties of the Command (converted to ValueObjects).
The method then creates the Event internally and registers it in a hash object to be collected and persisted late... |
i’d like to push discussion on the same named thread again.
I also use auto increment primary keys as foreign keys - mostly for code tables. Every row also has a code for identifying entries for users (like ProductKey).
Everything works fine till I need a validity period for entries in code tables.
e.g. every Client ha... |
I have a library with several layers. The library is a hardware API and has several threads. The application that is using it has no direct user interaction the UI is for display only. I needed a way to tell the user if there was an error and what it was. So I created an Error Event that passes a message up the layers.... |
To clarify, as I'm not entirely sure how to summarise in the title.
I have a redis cluster and a redis-backed scheduler (similar to sidekiq/resque, etc).
My redis cluster has a master and a couple of slaves. I insert a job onto the master and that is replicated onto the slaves.
I have 4 workers listening on these slave... |
As I was working on upgrading deprecated ereg_replace() statements in an e-cart sollution I was suddenly puzzled by questions regarding how to handle the submitted data I was working with.
I was working with the add to card function, which from the backend perspective recieves an integer for how many products to add to... |
Suppose I am designing a web application and also building a Web API with authentication via Kerberos/NTLM. The Web API is first for my app, but I imagine I want to make it general-purpose. My instinct is to create the Web API as its own separate solution, and then consume it with XHR requests in my web app. So perh... |
I'm writing what I might refer to as a Maven project dependency management process for a project I work on. Whenever a developer wants or needs to change the version number of an existing Maven dependency or add one or more new dependencies, they must follow the process.
So far, I've identified four stages:
Confirmati... |
Suppose that you are in the phase of requirement elicitation (discovery). You have
already interviewed your customers and created use case models to discover as many
requirements as you can. However, you strongly suspect that there are some implicit
requirements (e.g., domain knowledge that is so familiar to cus... |
So I've done a good job separating the DAL from the BLL. I use repositories for each aggregate root. The issue I'm having is database concurrency with IDs in the domain.
I don't want to use the surrogate key in the domain layer (e.g. GUID). So the aggregate root I have now is a Journal and that Journal has a list of... |
I have a great deal of 'dirty' data pulled from an API request.
Before database insertion, I clean out a lot of line feeds and regex out values such as height and width from item descriptions.
This is my first large project as a software engineer, and I would like to leave something coherent for future developers.
He... |
I have two parallel hierarchies:
B and C implement interface A
D and E extend the abstract class F
I want to be able to do: F f = createObject(A a)
where createObject should follow the behaviour:
F f createObject(A a){
if (a instanceof B)
return new D(a)
else if (a instanceof C)
return new E(a)... |
I'm working on a project with a MVP architecture.
My program revolve around forms that give rights to people.
There are X differents forms depending on profiles ( so there are X differents profiles)
I have an abstract class which we will call BasicFormClass.
Each forms has a presentation that inherits from BasicFormCla... |
I'm in the middle of refactoring a project (in C++11) and I'm struggling with a decision is it good to change huge enum with about 100 record to separate classes.
This enum is used in about 4 places in code in 4 different functions with huge switch statements. For every enum, the record is some code in every function.
... |
I'm testing that a function does what expected on a list. So I want to test
f(null) -> null
f(empty) -> empty
f(list with one element) -> list with one element
f(list with 2+ elements) -> list with the same number of elements, doing what expected
In order to do so, What is the best approach?
Testing all the cases in ... |
Going through Effective Java, Joshua Bloch states that the drawback of using JavaBeans pattern is that an object may be in an inconsistent state partway through the construction and with JavaBeans pattern, we cannot make our class immutable. I have understood this much.
He also says that we can reduce these drawbacks b... |
Where I work, we use a language for our desktop software development (Delphi) and an other for web apps (asp.net/c#). My bosses want me to implement a feature on a website but they ask me to develop it in Delphi because they think they might need it for one of our software someday.
When the same situation happened in ... |
I do not have production experience with docker and have several questions regarding a local registry:
A dockerfile is the description (=recipe) of how an image is built(=cooked, e.g. FROM alpine:3.5)
If the image on my Docker Host isn't present, it is pulled from a docker registry. As far as I know is Dockerhub regar... |
In my understanding, evolutionary architecture boils down to making architecture easy to modify. Now architecture is often defined as the things that you should get right early because they will be hard to change later.
How does this fit together? Is there any difference between evolutionary architecture and simply min... |
Note: I am note sure how to phrase the title
This is pseudo code of my Project that I am working on. For conciseness I have left out some details.
I have a 2 types of Consumer classes. One is inherited from the other and does a some extra things.
Consumer has a thread that runs a queue of tasks.
I have a IProducer that... |
Assume
You have some POJO Animal like
public class Animal { // some fields }
You have some enum AnimalType like
public enum AnimalType { // some animal types }
You have some method that given an Animal returns an AnimalType with signature
public AnimalType getAnimalType(Animal animal);
Finally, you have some inf... |
I have seen it done both ways, but I have never seen any discussion around which is the more "right" way.
Say you have a entity that has children relationships to other entities. The children can't exist without the parent, so does it make more sense to make on service that handles the CRUD of the parent AND the child... |
So, there is a workflow I feel needs to exist. It may already exist, and I don't know about it.
Consider the Linux command line workflow, the "motto" of Linux, more or less. You have a bunch of small programs, accepting input and producing output. Each does one thing well, and the user puts them together to do compl... |
I have a code base that contains several different instances of the following pattern, the key point of which is that the concrete type of the class is decided at run time based on a string from a config file.
class Foo {
public:
virtual void bar() = 0;
};
class AFoo : Foo {
public:
void bar() {
// ...... |
So one thing I didn't really think about when designing this personal finance application was WHEN (not HOW) to persist the data. I'm using DDD, a 4-tier architecture, and EF.
It struck me when I added a new Transaction, Account, etc. that it's immediately saved to the DB. However, this is not how most desktop applic... |
This isn't so much as a specific code review, but a concept review when converting a class diagram to code and then eventually a database, in Python. I know how to add things in to a database, but I have only ever done this directly with SQL from forms and not from classes, (which I believe is called ORM)
I have the fo... |
In our user-rights management system we basically follow "CRUD", where at each incoming request the user is checked against his rights, and see if he has create, read update or destroy rights for the data he wishes to access.
This system is created by my predecessor, however I'm constantly in doubt if this is the right... |
We've built a class that allows you to easily draw stuff on a <canvas> element.
That class is called Canvas. I've encapsulated the <canvas> element and the class itself in a WebComponent, called <paper-canvas>.
<paper-canvas>
<canvas id="#canvas"></canvas>
<paper-canvas>
<script>
class PaperCanvas {
constructo... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.