c ++ – Design of the shift register library

I create a small library to control the LED bars and I have doubts about my design.

Until now, I have 2 basic entities in design:

BarService (and implementation)


class BarService{
  virtual void turnOnLeds(T* bar, int end) = 0;
class PinBarService : public BarService{
  virtual void turnOnLeds(PinBar* bar, int end);
  void initPins(PinBar* bar);
class OpampService : public BarService{
  virtual void turnOnLeds(OpampBar* bar, int end);
  void initPins(OpampBar* bar);

Bar models:

class Bar{
  int ledCount;
  Bar(int ledCount);
  int getLedCount();
class BasicBar : public Bar{
  int* pins;
  BasicBar(int ledCount, int pins());
  int getPin(int index);
class OpampBar : public Bar{
  int input;
  OpampBar(int ledCount, int input);

My reason for separating them is that I think that Bar models should only contain information about themselves, thus allowing me to create more classes later that use this information rather than asking the bar itself for information. 39; perform actions (such as writing on material).

The reason I doubt is that by using templates each implementation of the service must accept a different template.

My question boils down to: do I go too far in separating the model from its actions? and are models a good solution here? and overall, what could be improved in this design?

c # – Promise Library – Code Revision Stack Exchange


I am working on a C # Promise implementation (based on Promises / A + and ES6 with some modifications). I would like to have comments, if someone has something to give.

The most glaring problem that he has right now is that it's not safe for threads, which I plan to bypass soon. Of course, I have not encountered any other thread-safe promise library in C # anyway. In addition, there is obviously no readme yet. I am looking for comments before writing this and set the API in stone.


public Promise DownloadTexture(string url)
    var www = UnityWebRequestTexture.GetTexture(url);
    return PromiseYielder.WaitFor(www.SendWebRequest())
        .Then(asyncOperation =>
            if (asyncOperation.webRequest.isHttpError || asyncOperation.webRequest.isNetworkError)
                throw Promise.RejectException(asyncOperation.webRequest.error);
            return ((DownloadHandlerTexture) asyncOperation.webRequest.downloadHandler).texture;

c # – Should we put small pieces of code potentially used often in the tool methods of a shared library?

Save me unwanted drawers published.

If you want to place a small piece of potentially used code in a shared library, this library needs a good organizing principle. More importantly, it needs a good name that clearly indicates what is there and what should not be included. Do not create a dump that is nothing more than the material you have decided to extract. Gather things that have a good reason to be together.

I'm afraid you are following DRY's dead brain shape. This bad habit forces you to go through the code base to find a similar code without considering if duplication exists for a good reason.

DRY encourages you not to release a design decision by copying and sticking lazily. But he never asked you to make sure that no single line of code looks alike. Duplication is more appropriate when it represents a different idea, which could change independently, which simply looks the same.

If you carefully consider that when you target code for extraction, I am always with you.

However, the main engineers seem to think that we should not encapsulate such code fragments consisting of only two or three lines in the tool methods.

I must disagree with that. Small methods with good names are a gift from God.

Instead, it would be best to place the respective code where it is executed. They argue that the code is "clearer" this way, because when reading the code, you do not have to come and go between the methods.

This complaint is a valid concern. This seems to worry that you will take them to a festival of jumps when they read the code. You could do it even if you chose a code that should really be extracted.

To avoid this, you must use good names, a good abstraction and a proven code. Do this and they will not look inside your method. They will trust it as they do Console.WriteLine("Hello World!");. Make them look inside again and again and of course, they will hate it.

A good name means that when they look inside, they will find what they expect. A good abstraction means that it works as they expect it. Looking inside and looking at documentation should not teach them anything they did not expect.

Do this and there will be no going back and forth between the methods. They will know what you mean when you call it.

So now the question is, is that DeleteByColumn(conn, "students", "grade", "F"); at the height of that?

I must confess that I had to look inside this method before feeling like I understood what she was doing. I only guess that I use it correctly. But I think DeleteByColumn() is a name that I could get used to.

Keep in mind that any library in which you put this should focus on the kinds of things it focuses on. I would tend to create a persistence adapter where I would dump logic that knows how to talk to the database so that the rest of the application does not have to know it.

If you've found, let's say, frequently used string manipulation code that has nothing to do with the database, I would not group it with that.

A shared library is a significant term that often extends between applications. If you propose that this code is ready to be used, keep in mind that you bite a lot. If you want to write a DB Access Library, you are facing guys like this: JOOQ. It's a lot to live.

It is much easier to create a code for your application rather than for each application. With a database adapter, you only hook up the features that your application really needs. No need to be everything for every database user. Reusability is a good idea but do not kill yourself by creating things that no one has asked for. Do not forget that your application may change. Be ready to change.

Show that you are ready to temper your plans so that it does not seem like you are rewriting because it's easier than reading that your team can be more welcoming towards your changes. If they are not, here is my advice:

It's perfectly fine to help you, when you try to understand the code, by extracting the code into small functions to push out the curious details so that you can see what's really going on at a glance. I do it all the time. Sometimes, after sitting with someone, I discover that what I have created is good enough to keep it. Sometimes no. When that is not the case, I do not record it. I throw it in my personal garbage drawer.

applications – You search for a library to implement a vertical segmented progress bar, with scale and labeling

I'm looking for a library to implement the following design in Android (and later for iOS):

Vertical progress bar with colored segments and scale

It is important that on the progress bar we have:

  • different color segments
  • a linear scale of numbers at the top or the bottom
  • a labeled pointer of the current progression
  • (Optionally, it is also acceptable if the label can be written inside the bar itself)

I've already looked at many graphical libraries, like AnyChart, Highcharts, MPAndroidChart, but these libraries are primarily meant for graphics and none of them has such an exact functionality. I've also tried searching for progress bar libraries, but these do not normally support such advanced features.

blockchain – How can I print this information using this library?

I want to know how, by using this library, I can print information about the current block that the world is currently mining and I mean by that: version, previous block, root Merkle, time, bits and how many zeros we are looking for . the output of the hash.

Can the search results on a specific library be configured to be displayed for authenticated users, but not anonymous users?

I have a library of documents that I would like:

  1. Be accessible to anonymous and authenticated users
  2. But only to be searchable by authenticated users, appear only in their results

Until now, I have not really found a way to accomplish this in SharePoint 2013. Someone has ideas?

view – Library items not listed in the calendar (SP2010)

I have created a library in SP2010 in which the main content type is a set of documents. I want to display the sets of documents in a calendar, but nothing is displayed when I do it.. These document sets are not the built-in Sharepoint event content types, but they have start and end date columns. So I think that they could be displayed as a calendar. Ideas?

Know C ++, but not the STD framework / library

I'm building a curriculum, and my question is: I know C ++ (with the Arduino framework), but not stdlib (just a bit). So, should I put C ++ in my curriculum?

Creating a folder in the SharePoint library using the Rest API

You must use the Folders endpoint something like below:

_spPageContextInfo.siteAbsoluteUrl + "/_api/Web/Folders/add('Communications/NewFolderName')"

Note: You must pass the ServerRelativeUrl in the interior of add method.

Official documentation: Work with folders using REST.

Similar question: Creating a Folder Using REST and JavaScript

storage – Users' Library folder is much larger than the content

There are a number of similar questions about the fact that the files are larger than the content. However, from what I've seen, the most common suggestion is to check the Library folder, which can be hidden.

In my case, the Library folder and all it contains are not hidden and apparently this file is the culprit.

enter the description of the image here

Is there a way to find it?