instruction stringlengths 34 36.1k |
|---|
I'm working on a small (and very tame) FOSS utility; and I want to test it to make sure that it builds on Mac OSes. But - I don't have a Mac OS I could use for that. I have access to Linux and to Windows boxes, and that's that.
Other than trying to knock on some people's doors and asking for SSH privileges into their M... |
I need to search a long string of binary string data (couple of megabytes worth of binary digits) for patterns of binary digits. There are about 100 000 different patterns to search for. Each is a maximum of 10 bits/character length patterns of 1's and 0's. I then need to display the most common pattern of all of these... |
I have a search algorithm that is used in conjunction with a machine learning algorithm. I separated the two because I wanted to be able to swap out search algorithms on the fly. However, the coupling is currently too tight. It looks something like:
class ML_Algorithm:
def __init__(self,observers):
import ... |
Is there any convention on how to declare, name, use or access object properties that themselves do not add new information and could be re-calculated at any point in time? Basic example (made this one up, just for clarification):
class User {
// provided by DB
int ID;
// calculated
boolean id_is_odd;
... |
Following the reading of the question Why are zero-based arrays the norm?, I wonder about the terms to use for referring to specific array elements, in the perspective of linguistic reading of programming.
Should Array[1] be called the first element of Array or the second element? In the latter case, then how should th... |
I am designing a UI framework in Java. Every UI component, represented by the class Component, in the framework is identified by a non null unchangeable String key. So I get the key in the constructor itself and provided no setter.
Now I have another class AggregateComponent which represents a component containing arra... |
We're currently working on upgrading a small information system for an enterprise. Currently, the system has a corporate network zone (CORP) where services for internal users are placed, and a data center network segment (DC) where a data access service and all databases reside. All applications are essentially deploye... |
I've seen the url like this
domain.com/some-article-title-which-can-be-very-long
many times. There's no ID embedded in it. Therefore, in a db it must be defined as "unique article_url varchar(NNN)"
While it's good for SEO, doesn't this have too much overhead for a database: there's an index on "article_url" and it's v... |
I have a situation in a current application I'm working on that requires featuring batch editing and I'm wondering if there are any design patterns that I should be considering.
The task at hand is given a collection of objects that represent files on disk the user can edit a property on one object and have the edit ri... |
I'm writing code using arm assembly language for college and the I'm really confused about endianess.
The default should be little endian but I'm sure the test string has been stored big endian. The first byte in memory at 0xA1000004 is 0x30 which is 'O', and 0xA1000007 is 'j',
but surely if its little endian the 'j' ... |
I'm trying to write an Entity-Component System and I want to have different factories creating different kinds of entities. For example the HumanEntityFactory class will create human entities.
Would it break separation of concerns if I store the different types of human that the factory can create, or should I create a... |
We have a number of IoT devices that communicate over TCP/IP to a server. Once connected, the server can then talk to the device, get data or send down commands.
The server accepts incoming connections from hundreds of IoT devices on a specific port.
My question is around testing of new code and deployment. Heres my sc... |
(example code in PHP, but this can apply to more languages)
I have a scenario with an adapter pattern, where I have classes, interfaces and objects with different roles, like so:
An original object implementing CatInterface.
A class that implements DogInterface, which wraps a CatInterface object.
An instance of that c... |
I have a system that consists of several applications.
Often these applications need to talk to each other.
Sometimes it can make sense to use a "service account" for the communication but other times it will be necessary to authenticate the request on behalf of the authenticated user.
Because the applications are hete... |
The biggest difficulty I am having is finding where to house the responsibilities of each object identified by me in the system( say on problem space). I am posting a very simplified description of a feature in library management system.
Usecase
As a admin, I can add books to the inventory, or change the "states"
of t... |
I am developing a SAAS application where :
A single web application is hosted in IIS which will serve to multiple companies and each company will have its own database. The web application and databases will be running on the same server.
My question is - what is the best practice to change the database connection st... |
My team is using the Git Stable Mainline branching model and we are about to create the first release branch. From what I have read so far, it sounds like release branches are siloed from the master branch and never completely merged back to master. Instead, if a fix is made on the release branch, then it is usually ... |
I am working in designing Java-based web applications. Although, I have worked with Java core still a novice in designing web-apps and do not have enough confidence in what I am thinking is correct or not?
So, the thing is, we are a team of two, I am working with backend using Java and the other person with the front e... |
I have a class APIClient (Just an example name) which has the methods
def get(url, params={})
@last_response = conn.get(url, params)
end
def post(url, params={})
@last_response = conn.post(url, params)
end
def put(url, params={})
@last_response = conn.put(url, params)
end
def delete(url, p... |
I've always used the tried-and-true "Document and Pray" approach when it comes to conveying the fact that a pointer result from a function (either as a return value or a reference parameter) should not be freed by client code.
The other day someone showed me this function prototype:
const struct foo * const bar(void);
... |
I am working in a governmental institution. The technology being used here and the methods for developing software are quite old fashioned.
They have tons of storage space but no appropriate space to keep and maintain applications that are used to automate most of the work here.
The institution would not allow me to u... |
Say we have a column in table or a property in a collection called "sortOrder" which simply is an integer which denotes which order it is to appear when displayed.
I am trying to figure out the simplest way to implement this, considering that when we insert a new row in the table it may have a sort order which bisects ... |
The example domain problem
There is a student attendance tracking system that keeps records of student attendances of ExerciseGroups.
Course is a top-level component, AR, describes a generic info about the learning course (name, description)
Every Course has ExerciseGroups that describe groups where students can prac... |
I've inherited a somewhat complicated data-model in a SQL Database that I'll soon have an opportunity (read: nececssity) to overhaul. The data-model represents a Product catalog. So there's a table of products with lots and lots of other tables 1-3 generations deep containing category data, localized data, status etc. ... |
I'm currently updating a few very old web Services and came upon a Situation where I'm unsure.
I've got a web Service with the following method Header:
public string MyService(string data1, string data2, int subdatalength, short internalTimeout)
The data provided for the Parameters Comes via SOAP. So far I get it how ... |
I've been in an argument at work about writing readable code. It was mainly about variable and method names and the idea that comments are worthless if the code is readable enough. I would not like to emphasize only on no specific coding language.
1.) Descriptive vs minimalistic variable and method names
Descriptive v... |
Currently, I'm using these methods on HTTPS protocol:
SSL to secure the communication between two endpoints
CheckSum to generate a hash token that only the two endpoints can generate
Is there any way to detect that a specific request comes from the whitelisted server?
|
I'm evaluating the use of Kafka to implement Event Sourcing in a microservices environment that already makes use of an API Management platform.
I was wondering if it is common and/or considered a good practice to use the API Management as a gateway to the Kafka topics. The benefits could be analytics, caching, rate li... |
I want to write my own command line library from scratch. What algorithm should I use in order to parse gnu style args like in getopt for example ? I mean what's the best way other than tokenizing and parse them in a naive way? Should I try to look at LR, LL algorithms or this is way too overkill?
|
Someone made a comment about some of my code which I thought was valuable, and I wanted to look up the design pattern to learn more, but I'm having a hard time identifying which design principle it relates to.
Essentially I had a Encoder/Decoder object. In one direction it would take a string and return an object with ... |
I was working on a piece of code when I noticed that an if statement could work or crash depending on the order used for the parts connected with and.
You can replicate the problem like this:
boolean func(String x) {
assert x
return true
}
v = "text"
if (v != "" && func(v)) {
println("Hello")
}
Depending o... |
Our team has decided to move to a microservice approach for newly developed features. We've decided to keep a database/datastore per service and to split the services along the business function they perform. As we move this direction we're creating the services as necessary. This means that not only have we created a ... |
I'm writing a high level wrapper around the Python socket.socket object. Specifically, I want to do this for IPv4 TCP sockets (though it would be useful to be able to expand the library later with other families / types). As you may know, the socket module defines these as socket.AF_INET and socket.SOCK_STREAM. Is it a... |
I'm trying to better understand the pros/cons of instantiating vs injecting in a web application type development.
What are the pros & cons for each?
When should they be used (what sort of scenario we looking at)?
|
I have a type of "PC" (i.e. personal computer) that I need to model in C++ (can use language standards as new as C++11, but no newer than that). In short, we have a lot of granularity for components in the PC (in my actual tool, it would be about 10 times the number of components shown here), i.e:
Tower
Motherboard... |
I know that if user is forbidden in an admin's area, I should return 401 or 403 status error code. However, what I want to prohibit an admin for accessing a user's dashboard also? An admin has its own dashboard where he can already see a list of users, hence access to a user's dashboard wouldn't make sense.
What error ... |
I have two lists:
1:
1) A abc
2) A def
3) A ghi
4) B jkl
5) B mno
6) C fzy
7) C xxa
2:
1) vsf
2) jkl
3) fzy
4) xxa
5) xyz
6) mno
7) def
8) abc
I am trying to match each of the continuous sequences from list 1--in this case there are two continuous sequences, A and B-- with its corresponding sequence in list 2, with t... |
I need to decide on a bug tracking solution for our small dev team of 4 developers working on a web-based SaaS tool. There is plenty of products out there to use but one major difference seems to be if you either keep your bugs in a list (for example like GitHub issues or Redmine) or in a kanban board (for example like... |
I'm trying to create a Tower Defense game where minions move through a labyrinth and you can build towers on top of the labyrinths' walls to stop the minions. I'm personally using Python and pygame, but I'm looking for generic design answers that can be applied to any OOP language.
So, since both minions and towers hav... |
Generally, we like to have a common folder for common header files to be shared among various projects in solution but what about googletest since it needs access to all header files of project to test them? Is it the norm for googletest project to include files from target project directly?
Solution
├── Project1
... |
I've several cases where a single entity has multiple tables in the underlying database.
When reading or writing I want to handle all of the DB queries with a single class for that object, e.g., the SalesOrder class has a corresponding SalesOrderQuery class and that class uses the underlying tables of Sales_Order_Head... |
As developers, when we are assigned a task, we have two options:
Create one volatile branch for each issue:
Pull master;
make changes;
push changes to new remote branch;
wait for somebody to merge it to master.
or
Use one permanent branch per version:
Merge master to version branch;
make changes;
push changes to rem... |
On my website there's a new subscription form. And users can also register and subscribe to news after. When an anonymous user subscribes to the news, how should I better handle that? Should I create a) an inactive user for him b) and a record in the "news_subscritpion" table? The "news_subscritpion" table is connected... |
I have web application which structure is as-
webapi : django web services [NOT REST] no security implemented
frontend : Angular2. authentication implemented via SAML
Database : Mongodb
Can you please suggest best way to secure webapi, as currently anyone can access web services who has server[api] url
It will be big... |
Designing an Aggregate and choosing an Aggregate Root getting tricky for me all the time especially when it comes to ensuring right transactional contexts and consistency constraints so I'm wondering whether there are any practices that can make it easier.
By example
There is a student attendance tracking system that k... |
If I have a list of products and I need the total price of those products. Where is better to calculate the total sum, back end or front end?
Front end React
Back end PHP
Table that shows Invoices list
|
In Regular Expressions Quick Start, it reads
Twelve characters have special meanings in regular expressions: the backslash \, the caret ^, the dollar sign $, the period or dot ., the vertical bar or pipe symbol |, the question mark ?, the asterisk or star *, the plus sign +, the opening parenthesis (, the closing pare... |
In the project I work on we use XSD to generate some classes. XSD determines the order of elements, similar to this snippet:
<xs:element name="Customer_ID" type="com:Text6"/>
<xs:element name="Customer_Desc" type="com:Text150"/>
<xs:element name="Customer_Name" type="com:Text50"/>
<xs:element name="Institution" type="c... |
I apologize in advance for the length of this question; it requires some explanation. I'll try to make it as clear as possible.
I am developing and maintaining a mobile app (Xamarin, F#) that communicates with a web API (ASP.NET Core, F#). The server-side API exists only to communicate with the app and do database oper... |
This isn't necessarily restricted to software engineering, but I'm asking here because I'm curious to know if there's a specific phrase used within the context of SE, as it's where most of my Q&A activity is performed..
For a long time I've used various community-help resources such as SE, EE, forums, even IRC and simi... |
For team of 6,
We have spring MVC project being developed with Angular as Frontend and Spring framework as back end.
From Java project build & version control aspect,
Is it recommended, to not restrict the team on using specific editor, by creating the maven template(spring mvc archetype) and share java code on github... |
In my application I have a service method which loads some data. The key identifying the data consists of a key type - which is defined as an enum - and some key values.
public enum KeyType
{
Alpha,
Bravo,
Charlie
}
public class KeyData
{
public KeyType KeyType { get; set; }
public string AlphaKey ... |
I currently have two microservices. We'll call them A and B.
The database under microservice A has the following table:
A
|-- users
The database under microservice B has the following table:
B
|-- trackers
The requirements state that users and trackers have a many-to-many relationship.
I'm not sure how to properly ha... |
I have a class calculating workers' net yearly income. It has a constant representing a tax percentage. But one day the tax rate has changed, so I need to fix the code.
Does the act of fixing this constant indicate a violation of the Open-Closed Principle, since it postulates that a class should be closed to modificati... |
Is it seen as bad practice to try to hide local functions in Python? The intention not to clutter the global namespace with second rank or common function names may stand against ... er... some Pythonisms that I am not aware of.
def foo(aparameter):
def somenamewhichislikelytoclash(anotherparam):
....
Is... |
In OAuth2.0 we have to send client id and secret along side the user credential to obtain an access token from an authorization server. We have a ReactJS web application that needs to send its request to API gateway (Main API), but problem arise when the web application wants to store the client secret for its requests... |
Both of the following are valid pointer declarations in C/C++:
int *x;
int* x;
The former seems to be preferred by seasoned C/C++ programmers. I personally find the latter to be easier to understand - it illustrates that pointer-ness is a factor of the variable's type, not its name. Furthermore, this unifies stylistic... |
Some info on the current setup:
We're currently using database replication - transactional replication, to be specific - between 2 servers. For sake of this post, we are replicating from a PRIMARY to a DR halfway around the globe. The goal is to have the ability to 'switch' to the DR in case the primary goes down, whic... |
Our company creates financial software that integrates into a banking system backend. We're running into a lot of problems making changes to it without seemingly impacting another customer or another banking backend system.
The company goal is to push for one product having seamless integration among any and all system... |
Looking to step into the world of Domain Driven Design with a simple project for my personal use. The project is a simple calculator to evaluate different retirement scenarios between the old DOD "High-3" retirement and the new "BRS" retirement.
The issue I'm having as I go through this (very simple) project is that I... |
I would like to use URIs to represent different files we can use in our system. But to know which module to use to parse it, it would be great if I could somehow encode what is content type of the resource to which it is pointing at, so that it can be given to a proper module for parsing.
I was thinking to maybe extend... |
We are building a react based web app for a project/potential business and I'm wondering if it's ok to include the static site in the web app code?
I've always had a separate basic html and css code base for the static site but if I included as a couple react components I could re-use a lot of the app styling and code.... |
Just trying to design an architecture/class relations for my current C++ project in the IoT field.
The program itself (controller) controls various hardware via an arm-based device. I intend to use cpprestsdk for an http server implementation that provides an API for the client program that would allow to send the cont... |
Say, I want to create a db schema for a blog. So far I've used 2 separate fields for "description" and "content" of Article. But I've seen a lot that usually only a single is used for both. The "description" is everything that goes before a special tag such as "========cut=======" and the whole field is "content". The ... |
Problem
I wonder what best practices are to indicate implementation errors detected at runtime.
For example, if you write the following method (in Java):
public void doSth(int i) {
try {
runOp(i); // an operation possibly throwing FrameworkException
} catch (FrameworkException e) {
throw new Run... |
I'm using Swift, but I understand computed properties are a thing in a few other languages as well. I have the following case:
var bar in class Foo is changed throughout program flow.
vars a, b, c and d are constrained to bar's value so defining them as computed properties is a clean way to handle that.
the constrai... |
Example
I came across monolithic code that does "everything" in one place - loading data from database, showing HTML markup, acting as a router/controller/action. I began applying SRP moving database code into its own file, providing better naming for things, and it all looked good, but then I began having doubts as t... |
Say I have the endpoints:
/users
and
/users/<id>
If I wanted to DELETE a user authenticated with a JWT token that contains the user object, should this DELETE handled go under /users or /users/<id>?
It makes sense to have under the /users/<id> endpoint as you're deleting that specific item.
But also makes sense to h... |
Our project uses Gradle (whose dependency system is compatible with Maven IIUC). When depending on external projects, we try to depend on stable versions. Sometimes we have to depend on a development version. And sometimes we have to fork the repository of a dependency and depend on that (in general we try to upstre... |
I'm going into Clean Architecture and lift my Android level from MVC to MVP, introducing DI with Dagger 2, Reactivity with RxJava 2, and of course Java 8.
In MVP clean architecture there is a layer between the entities (in datastores) and the presenters that should access them. This layer is the "Use Case". An use case... |
Reading about GitHub Flow, I saw that one of the main suggestions after merging to master is that we should immediately deploy, but I don't completely understand the reason for that. Isn't it possible to wait for a couple more features? What it will happen if we wait?
Basically what I'm trying to ask here is for exampl... |
I am trying to abstract the elasticsearch python client.
I have a method index document
def index(self, body, id=None):
"""
Inserts one document into elasticsaerch.
If id is None then it will autogenerate the id.
:param self:
:param body:
:param id=None:
... |
I'm designing a continuous integration pipeline using Bitbucket & Jenkins with only master and feature branches. I'm failing to find convincing arguments to the fact that my design is better.
* Our Build process includes compiling frontend and backend code (same repository), run fronted and backend unit tests & Cucmber... |
I asked a question about structuring a Tower Defense game a while back, and ended up using the Flyweight pattern for my towers. Here's what my TowerType looks now (I'm using Python but looking for generic architectural answers):
class TowerType:
def __init__(self, name, image, attack_speed, damage,
... |
Most open source Content Management Systems use a database to store field data and then use files in the server's directory for config settings. Why is this model chosen so often and why would it not be as effective to maintain a file on the server to store field data in? Would this change if the goal is a large, pro... |
I was looking for more information on logging user actions on the application (web based project). I did found this question, but it's a more conceptual answer, wich helped me getting started with this.
But I don't know for sure how to build this structure for the log system and also how to log the information. Everywh... |
If I have a string:
let str = "Hello world"
It seems quite reasonable to be able to extract a character:
let thirdChar = str[3]
However, that's not legal. Instead, I have to use the extremely obtuse syntax:
let thirdChar = str[str.index(str.startIndex, offsetBy: 2)]
Similarly, why isn't str[0..<3] or str[0...2] lega... |
I was watching WWDC video and can not understand when they talk about
Even though all of these properties are value types, internally, they
contain a class which is used to manage the lifetime of their internal
data.
Can some one share me his understanding on the above point.
|
I have a domain layer, which my application architecture holds "sacred"; that is to say, the domain layer has no references to either data storage, or presentation concerns (vice-versa is allowed). I would like to keep it this way!
Everything was going quite well until I came to one particular requirement. Given:
publi... |
So I'm using pygame to create a simple top-down shooter game, and I'm doing lots of angle calculations from the top-down perspective. Let's use a simple arrow and a ball as an example, I want the red arrow to keep pointing at the blue ball regardless of where the blue ball moves:
And it seemed easy enough, I just need... |
I am studying modelling and UML through a presentation based on Craig Larman's book "Applying UML and Patterns". It describes seven consecutive design steps, from the requirement analysis to the class diagram:
Software Requirements Specification,
Use Case Diagrams,
Conceptual Model,
System Sequence Diagrams,
Contract... |
I am having a doubt while creating a DB, and I would like to know if there are objective arguments that could help me mak a better decision.
Case
A project that can have several revisions, so I created entity Project and Project_Rev. Each revision has positions, so I have created entity Position. Each position has elem... |
I have a large class with complex properties. I'd like to introduce a default implementation, allow the user to override part of the default implementation and also make sure the user calls a sync method so that the object is always at a consistent state.
public class Complex {
public int Id { get; set; }
publi... |
Let's say I have two components talking to each other. The first one calls a "get results" function from the second one. How should I return the results?
For example,
SomeObject getResults(String name);
works fine but I am not sure whether it's the best way to go. This way both components seems coupled to the SomeObj... |
In my UML class diagram, I have an interface called Contract which a Staff implements. There are two types of Staffs: one is partTime and the other is fullTime.
Does that mean that the two partTime and fullTime classes inherit from Staff class? More generally, can you inherit an implemented class?
|
Fielding writes in his famous dissertation (p.89)
The only thing that is required to be static for a resource is the
semantics of the mapping, since the semantics is what distinguishes
one resource from another.
So a resource prot://bookstore.com/new-books-this-week is OK, because although it will always show di... |
I was wondering what the purpose of rooms is. See: https://socket.io/docs/rooms-and-namespaces/
You can basically mimic join and leave with just socket.on and socket.off
Take for example:
(no room)
client:
socket.on('chat', (data) => {
console.log("chat received", data)
$(this.$refs.chatBox).append(`
<d... |
When writing unit tests for classes (especially when using DI and mocks) lately I often found it handy to structure my tests to one class actually running the tests and one responsible for the setup, which helps me keeping my tests clean and readable.
The tests class will look like the following
public class MyFooBarT... |
I have a shared resource in a database that is used by clients C1 and C2. Before the resource is read by C1, C1 should mark the resource as leased so that C2 will know it is busy. C1 will do some work and when it is finished it will update the lease to make the resource available to C2. I am using a lease so that if t... |
I am migrating a legacy system from Oracle Form to Web Application. The migration is conducted with code study and interview.
As the requirement is to migrate the existing system to Web application and keep all existing functionalities.
There are some differences in behavior between Web application and exiting system b... |
I am currently working with PHP to develop a server client application and therefore, I am trying to design a reference architecture to guide me through my implementation process.
I really like the new mean stack folder structure and the component/modules way to do it but even here I do struggle a lot.
As an example:... |
How do you handle fat interfaces? Here is an example:
public class TSP
{
public AddEmployeeContribution(...) {...}
public AddMatchingContribution(...) {...}
public CalculateTotal() {...}
public CalculateEmployeeReturn() {...}
public CalculateMatchingReturn() {...}
public CalculateTotalCumulativ... |
I am thinking about creating a service that would automate the process of chaining REST API calls, for example:
POST /jobs to service A to ask it to process a job.
When I get a response for that job, then call POST /jobs to service B where some of the data passed in the request body may be mapped from some data we got... |
Are there any use-cases where a nested object as state is either more optimal/easier to work with than individual properties?
For instance if I wanted to express some user controls for interacting with a photo in state I could write something like so (nested object):
this.state = {
photoControls: {
open: false... |
I'm looking for the most efficient path to convert over time my own made php framework for nodejs and I believe that nodejs experts and specific developers who had their years working with apache/php/mysql will be able to give objective answers based on knowledge and experience that won't be just opinions but solution ... |
C#'s is operator and Java's instanceof operator allow you to branch on the interface (or, more uncouthly, its base class) an object instance has implemented.
Is it appropriate to use this feature for high level branching based on the capabilities an interface provides?
Or should a base class provide boolean variables t... |
I've inherited responsibilities for maintaining a section of enterprise intranet, and my manager has tasked me with, "Clean up the code, please. We're probably going to get lots of change requests next quarter and I'd like things to be in good shape."
Upon looking at the code, I've found it difficult to work with. Ther... |
A third party that is going to make HTTP requests to the API that I'm building, requires that the API responds in less than one second. My question is, do they have a way (literally any way, within the bounds of the http and/or tcp/ip protocols) to abort the execution of my code if it takes longer than one second?
|
So I'm creating a Tower Defense game and I want to have different ways for towers to prioritize their targets (I'm using Python but looking for a generic design answer):
class TargetPriority(enum.Enum):
LOW_HEALTH = 1
HIGH_HEALTH = 2
FIRST = 3
LAST = 4
CLOSEST = 5
class Tower(Entity):
def __in... |
I had this question in a school test:
Design a non-deterministic FSM that receives all words over {a,b,c} that:
Start with cc.
Contain at least 1 ab or aca.
Ends with an odd number of (bc).
The FSM I built was wrong. However, when I asked the teacher for an FSM that works, she gave me this:
(ignore the text).
From... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.