Confirmation Pattern deleting a comment in Google Suite


I would like information about the current pattern to delete a comment from an app of the Google Suite.

Where and How to find it

Remove a comment made in Google Docs, Google Sheets, etc.

Google Sheet Confirmation Dialog. It says "Delete this comment thread?" with two buttons (Delete and Cancel)


  1. What’s the name for this mini-modal window that Google is using for removing comments?

  2. What’s the benefits of use this instead of a modal window? and when we should use one over the other??


My guess is that they are looking for a way to have the confirmation UI closer to the action button (Fitts’s Law). But, certainly I don’t know.

What is this preview pattern for vertical tabs called?

In the System Preferences on Mac OSX, the following preview pattern is shown: a list of options on the left, displayed as vertical tabs, and a preview window for every selected option. In this particular case, a video is played to clarify this option.

Mac OSX System Preferences screen

I have seen the same pattern being used on another website (Atlassian, I believe), in order to show multiple, grouped features in a way that allows for showing information very strict spacing.

Now that I would like to use a similar pattern, I’m curious to know whether these are regular vertical tabs or something else?

What is this preview pattern for vertical tabs called?

In the System Preferences on Mac OSX, the following preview pattern is shown: a list of options on the left, displayed as vertical tabs, and a preview window for every selected option. In this particular case, a video is played to clarify this option.

Mac OSX System Preferences screen

I have seen the same pattern being used on another website (Atlassian, I believe), in order to show multiple, grouped features in a way that allows for showing information very strict spacing.

Now that I would like to use a similar pattern, I’m curious to know whether these are regular vertical tabs or something else?

C++ pattern for compile-time configurable class functionality

Due to resource limitations (embedded), I want to make some functionality that a class provides optional. The decision to include this optional functionality should be made at compile time.

For example, I have a simple pool-based memory allocator, which has optional statistics support. The statistics support should be available for x86 and ARM debug builds, but not for ARM release builds.

The following code is an excerpt from the current, C-based implementation, showing the kind of interaction between the pool itself and a conditionally included statistics member struct:

struct fmpool {   // ...   #ifdef FMPOOL_SUPPORT_STATISTICS   fmpool_statistics stats;   #endif   // ... }  int fmpool_alloc(fmpool *pool, void **alloc_block, size_t alloc_size) {    // Do the allocation    #ifdef FMPOOL_SUPPORT_STATISTICS   selected_pool->stats.blocks_used++;   if (selected_pool->stats.blocks_used > selected_pool->stats.blocks_used_peak)   {     selected_pool->stats.blocks_used_peak = selected_pool->stats.blocks_used;   }   debug_log_pool_info(selected_pool);   #endif    // ... } 

I am not sure which pattern fits this use case best, but would like to unclutter the code of the allocator by removing the statistics code from the allocator itself.

In addition, the code is horribly cluttered with #ifdefs, so it is desireable to reduce the interaction between allocator code and allocator statistics code as much as possible.

What is a good pattern for multi language in MongoDb?

Say I want to build a website that support multiple language and use MongoDB datastore. I wonder what is a good approach to have multiple versions of the body and title of an article, one for each language.

Should I keep all versions in the same article document? Like a collection of key-value pairs of language code and text in the body field of the article. This way I’d get no more than 1 request for viewing articles, but I’d also get more data than I might need so the response is larger.

Is there a better solution? How and why?

Design pattern for exposing static functions in C/C++ only to unit tests [on hold]

I have some static free functions (the don’t belong to a class) in a C++ file. I want them to still be only visible within such module and to be free, but I want to test them with unit tests as well.

As far as I can see, the are several possible options:

  • Using macros, enable/disable the static keyword depending on whether or not a variable (TEST_MODE) is defined or not:
#ifdef TEST_MODE    #define static #endif 
  • Use ‘private headers’: create a header file whose name ends with _private and whose location is in include/private.

  • Declare the functions in the normal header file adding like a private section with code comments. Like /////// PRIVATE SECTION ///////

  • Include the *.cpp file in which they are declared (personally I don’t like this option at all)

  • Group the private functions in a ‘private’ namespace. Like namespace myNamespace { namespace private { .... } }. The problem with this one is that it can’t be used in plain C.

  • Use compiler directives for hiding stuff, like __attribute__(("hidden"))

I would say that my favourite one is the private header, it seems to be clean and does not need namespaces, in case the language doesn’t support them.

Which one is considered the best practice?

Is this Factory pattern or Strategy pattern? c/c++ ,And proposing an alternative solution

The idea is that when we want to create an object of some type, we will only use a robotcreator and enum from the interface. I would like to understand what template design I used because it sometimes looks like a factory and sometimes like a strategy.

Should I use define or not? I will also be happy to receive new ideas to implement.


 class InterfaceRobot     {    public:     InterfaceRobot();     enum RobType { Y=0, C=1, D=2, F=3 };      virtual void open() = 0;     virtual void close() = 0;  };  #endif // INTERFACEROBOT_H 


class RobotCreator :public InterfaceRobot { public:     RobotCreator(InterfaceRobot::RobType _robType);     void open();     void close();     ~RobotCreator();  private:     InterfaceRobot *Robot; /** pointer to InterfaceRobot**/ }; 


RobotCreator::RobotCreator(InterfaceRobot::RobType _robType) {     switch (_robType)     {     case InterfaceRobot::C:         this->Robot = new c();     break;     case InterfaceRobot::Y:         this->Robot = new y();     break;     case InterfaceRobot::D:          this->Robot = new D();     break;     case InterfaceRobot::F:         this->Robot = new F();     break;     } }  void RobotCreator::open() {     this->Robot->open(); }  void RobotCreator::close() {      this->Robot->close(); }  RobotCreator::~RobotCreator() {     cout << " d'tor of RobotCreator" << endl;     if (this->Robot!=NULL)     {         delete[]  this->dlRobot;         this->Robot = NULL;     } } 

use in main:

int main() {   RobotCreator rob(InterfaceRobot::Y);;  rob.close();   RobotCreator rob2(InterfaceRobot::C);;  rob2.close(); } 

Update Entity for Repository Pattern and UOW Pattern C#

In one mock solution, I have created 3 mock projects to implement layered architecture design mainly the – Presentation Layer (Web) – Domain Model Layer – Infrastructure Layer. I haven’t yet to add Application Service Layer (Web API).

For simplicity, I have only two domain model entities: Customer.cs and Category.cs. In my domain model layer, I also put my repository interface (both custom and generic).

In Infrastructure layer, I have the dbcontext, Unit of Work (including its interface) and repository classes (which implement repository interface).

enter image description here

Here is my generic repository interface

public interface IRepositoryGeneric<TEntity> where TEntity : class {     // CRD     void Add(TEntity entity);     void Remove(TEntity entity);     TEntity Get(object Id);     IEnumerable<TEntity> GetAll();      void Save(); } 

Generic Repository class

public class RepositoryGeneric<T> : IRepositoryGeneric<T> where T : class {     protected readonly AppDbContext db;     public RepositoryGeneric(AppDbContext db)     {         this.db = db;     }      public void Add(T entity)     {         db.Set<T>().Add(entity);     }      public T Get(object Id)     {         return db.Set<T>().Find(Id);     }      public IEnumerable<T> GetAll()     {         return db.Set<T>().ToList();     }      public void Remove(T entity)     {         db.Set<T>().Remove(entity);      }      public void Save()     {         db.SaveChanges();     } } 

Unit of Work Interface

public interface IUnitOfWork : IDisposable {     IRepositoryCustomer Customers { get; }     IRepositoryCategory Categories { get; }      int Save(); } 

Unit of Work Class

public class UnitOfWork : IUnitOfWork {     private readonly AppDbContext db;     public UnitOfWork()     {         db = new AppDbContext();     }      private IRepositoryCustomer _Customers;     public IRepositoryCustomer Customers     {         get         {             if (this._Customers == null)             {                 this._Customers = new RepositoryCustomer(db);             }             return this._Customers;         }     }      private IRepositoryCategory _Categories;     public IRepositoryCategory Categories     {         get         {             if (_Categories == null)             {                 _Categories = new RepositoryCategory(db);             }             return _Categories;         }     }      public void Dispose()     {         db.Dispose();     }      public int Save()     {         return db.SaveChanges();     } } 

I learned that I should not have the update method in my generic repository interface. But without update method, I am now stuck at edit method in my presentation MVC web controller. Below, I extracted just the edit action method. The error is in that line in bold.

[HttpPost]     [ValidateAntiForgeryToken]     public ActionResult Edit([Bind(Include = "CategoryID,CategoryName,Description")] Category category)     {         if (ModelState.IsValid)         {             **db.Entry(category).State = EntityState.Modified;**             db.Save();             return RedirectToAction("Index");         }         return View(category);     } 

Lastly, are my classes created in the right layer? Example should IUnitOfWork.cs be in Infrastructure layer?

My whole solution source is available at my github –

Revealing Module Pattern Javascript

Which approach is more convenient in an real life project? Can someone please enlighten me?

All of them give the same result. Classes are ES6.

2nd approach Constructor pattern combined with Revealing Module Pattern.

3rd is only a constructor pattern / function and the properties are used in an normal function declaration.

I want to make an application which i insert some data from the input form, creating with the classes / constructors and then display it in the UI. Data obviously is always changing( creating multiple objects when i insert new input form)

// 1st approach with classes const test1 = (() => {   class TestClass {     constructor() {      this.string = 'Class';     }    classMethod() {    console.log(this.string);   }  }    const testClass = new TestClass();    return {    testClass   }  })();  test1.testClass.classMethod();  // 2nd approach with constructor and constructor protoype methods const test2 = (() => {  function TestConstructor() {   this.string = 'Constructor';  }  TestConstructor.prototype = {  constructorMethod() {   console.log(this.string);  } }  const testConstr = new TestConstructor();   return {   testConstr  } })();  test2.testConstr.constructorMethod();  // 3rd approach with constructor with function declaration const test3 = (() => {  function TestConstructor() {   this.string = 'Constructor with function declaration';  }   const testConstr = new TestConstructor();   function normal() {   console.log(testConstr.string);  }   return {   normal  } })();  test3.normal(); 

Using Observer Pattern to selectively act on events

I’m currently in the process of architecting a small RPG-style dungeon crawl (in Unity), and am a little stuck on how to update various objects when things change, while not updating unrelated objects. For this question, I will be using my current project as an example, but the question itself can be applied to any situation where multiple different kinds of Observers each watch a single Subject.

The design I’m currently leaning towards for object interactions in my game implements the Observer Design Pattern, where I have a single Subject (let’s call it GameEventManager), and each interactive object is an Observer of this Subject (this includes things like the player, enemies, interactive items on the ground, etc.).

When an event occurs (let’s say a User hits Spacebar to shoot an arrow at a selected enemy), the current plan I have for the action’s lifetime can be broken into steps:

  1. The Input system (not an Observer, but contains a reference to the Subject), sends an Event to the GameEventManager for broadcasting to the right place. I haven’t designed the Event class yet, to keep the problem simpler and in case I need to redesign things.
  2. The GameEventManager broadcasts the Event to the Player with the relevant information.
  3. The Player, realizing an Event came in saying to shoot an arrow, does some internal math (like subtracting from the total ammo it has, maybe performing some sort of animation visually), and emits a new Event to the GameEventManager telling it that the Player shot an arrow at “enemy2”.
  4. The GameEventManager broadcasts the Event to “enemy2”.
  5. “Enemy2” receives the Event, realizes that it got shot, and dies in some fashion.

So the question is, how does GameEventManager know where to pass around all these different types of events (i.e. the movement event should only go to the player, and the arrow should only go to “enemy2”). Also, once the event gets to its designated target(s), how do these Observers know what to do with the event (i.e. how does the player know to shoot an arrow, and not take damage?).

I’ve done some research on Observer examples, but most are either obscenely complex and abstract, or are just simple “Subject emits event to ALL observers, and ALL observers interact with EVERY event they get”, which is not what I want at all (an arrow shot at “enemy2” should not impact “enemy1” in any way).

Sorry if this is a little abstract, I like to have a plan before I start to actually build the code.

Also, as an aside, I am fully aware that in Unity I can have one GameObject directly interact with another, but the purpose of this entire project is to make everything as polymorphic and re-usable as possible, and most Unity tutorials simply don’t touch on extensibility at all.