help me with these patterns

Explain what pattern each of the following examples will find:

c.  b*- d.  *b* e.  [!b]* f.  ???*- g.  *[[:digit:]]*- This pattern represents any digit 0-9 . 3.  [[:upper:]]* This command will list entries whose names have at least one upper-case letter and this can represent any number of characters (including zero, in other words, zero or more characters) 

Explain what each of the following commands will do:

a.  touch file{1..10} b.  mv file* Documents c.  mkdir Documents/{English,Math,Linux_Admin,Speech} d.  cp Documents/file[34] tmp 

Architecture patterns or SaaS solutions for throttling outgoing messages?

I’m implementing my service on AWS as a set of stateless EC2 nodes controlled by an ASG, backed by an RDS instance. I need to throttle the overall number of outgoing messages my service sends but can’t throttle the number of incoming messages.

The specific outgoing messages in this case are SES messages, but the problem seems pretty general to me (my service sends transactional mail, this is not a bulk-mailing problem).

“Use Guava RateLimiter” is not a sufficient solution, the number of instances in my ASG needs to remain variable but the overall number of messages sent across the group of nodes needs to remain under the limit. I think there’s going to have to be some shared-state here.

I’m thinking I’m going to have to implement some kind of queue of work items in the database and then some kind of slot-based throttling system to limit the amount of outgoing messages each node processes, so that the overall number of outgoing messages doesn’t exceed my limit.

My solution doesn’t need to be internet-scale, but I’d like it to be able to deal with a few-thousand outgoing messages per-second. I’m pretty sure the above-mentioned queue/slot-processor system will easily stretch that far on an RDS instance (and it can be re-factored later to work off of Elasticache or something). Another thing I like about the proposed system above is its minimum initial cost at low-scale (well, discounting my cost to write the code).

Are there any AWS services, SaaS solutions or even just libraries that can help me with this? I’m thinking cost-wise, a full-fledged AWS / SaaS solutions will have a cheap introductory tier initially, and as long as the price doesn’t get crazy to scale up it should be fine.

Patterns for loading related objects in memory (without an ORM)

I am using ADO.NET to read a bunch of data from the database into in-memory objects.

This is my domain model:

// Question.cs public class Question {     public int ID { get; set; }     public string Title { get; set; }     public string Description { get; set; }     public IEnumerable<Tag> Tags { get; set; } }  // Tag.cs public class Tag  {     public int ID { get; set; }     public string Name { get; set; } } 

On retrieving the list of Questions, I would like to fetch the related tags for each question. I am able to do this as follows:

// QuestionRepository.cs  public IList<Question> FindAll() {     var questions = new List<Question>();      using (SqlConnection conn = DB.GetSqlConnection())     {         using (SqlCommand cmd = conn.CreateCommand())         {             cmd.CommandText = "select * from questions";              SqlDataReader reader = cmd.ExecuteReader();              while (reader.Read())             {                 Question question = new Question();                 // Populate the question object using reader                 question.Load(reader);                  questions.Add(question);             }             reader.Close();         }      }     return questions; }   // Question.cs public void Load(SqlDataReader reader) {     ID = int.Parse(reader["ID"].ToString());     Title = reader["Title"].ToString();     Description = reader["Description"].ToString();      // Use Tag Repository to find all the tags for a particular question     Tags = tagRepository.GetAllTagsForQuestionById(ID);  }      return questions; }  // TagRepository.cs public List<Tag> GetAllTagsForQuestionById(int id) {     List<Tag> tags = new List<Tag> ();     // Build sql query to retrive the tags     // Build the in-memory list of tags      return tags; } 

My question is, are there any best practices/patterns for fetching related objects from the database?

Most of the SO questions I came across for loading related data provide the solution for entity framework. There is no answer for this duplicate question.

Even though my code works, I would like to know other ways to do the same. The closest explanation I came across that’s targeting my particular problem was Martin Fowler’s Lazy Load pattern, which I believe, will result in following implementation:

public class Question {     private TagRepository tagRepo = new TagRepository();     private IList<Tag> tags;      public int ID { get; set; }     public string Title { get; set; }     public string Description { get; set; }     public IEnumerable<Tag> Tags {         get         {             if (tags == null)             {                 tags = tagRepo.GetAllTagsForQuestionById(ID);             }             return tags;         }     }   } 

Are there any other alternatives?

Design Patterns & Strategies for a code library with many combinations of settings?

I’m not exactly an engineer. Just a recent graduate of a software development program. However, I am aware of software design patterns, such as the singleton, factory,dependency injection, etc.

I am currently working on a private back-end library for Node.js, and it is a library that I foresee accepting a bunch of settings that affects the way the library behaves. It will affect how the data will be processed in terms of security and validation, and it will also change the expected structure of the packets coming in. For example, if the user disables Challenge-Response Authentication, then I should accept connections immediately and not expect some fields related to that authentication in the payload.

A simple solution would be to set some default settings, and allow the developer to use methods/builders/constructors to change those settings. To implement the new settings later, I would need to do something like this in the library:

if (settingsA) {     // Use Object-A with certain fields     // perform tasks for A } else if (settingsB) {     // Use Object-B with different fields     // perform tasks for B } else if (settingsA && settingsB {     // Use Object-A and Object-B     // perform tasks for A and B }  private someMethod() {     if (settingsA)     {         // perform tasks for A     }     else if (settingsB)     {         // perform tasks for B     }     else if (settingsA && settingsB     {         // perform tasks for A and B     } } 

The above code may not be an exact representation of the problem, but it definitely highlights one issue where I have to keep using if statements to check the configuration values (which are boolean), and take into account any applicable combinations of settings which might simply combine properties of two objects, or perform 2 or more independent tasks in sequence.

My question is: is there a design pattern that allows me to do this without the ugly if-statements and lets me implement settings in a cleaner way? What are my options?

Thanks in advance!

What design patterns can help consume a web service while maintaining an instance of a web client?

I have several web applications which I am attempting to automate the use of with C#. For these applications, I am attempting to mirror their respective user interfaces as closely as possible. In reality, I am not mirroring every available action but enough that I have separated each into its own file. I’m using a web client for each (generally RestSharp) in order to maintain cookies through the session from logon to logoff. The idea is to mimic a web browser to automate repeated actions on the application.

So far, I’m putting each general action method in its own file, with all of the subordinate private methods underneath in the same file. However, some of these supporting methods are rather large and also contain JSON classes, etc. I’d really like to encapsulate each general action method into its own class, which will keep those subordinate private methods totally isolated to their respective action.

To do this, the only options I see would be to pass the web client into each action class, or create each action class as an extension class of the client. I don’t want to even think about what the code would look like instantiating each action (in keeping with dependency injection). Nor do I think that extension classes will solve this problem. Is there a design pattern that would allow me to maintain the same client through a variety of classes while also being able to call the action methods on the client?

I’m currently using something like this:

// main file public partial class AppClient {     private IRestClient restClient;      public AppClient()     {         restClient = new RestClient(...);     } }  // second file public partial class AppClient {     public void SomeAction()     {                     SubordinateMethod1(restClient);     }      private void SubordinateMethod1(IRestClient client) {} }  // third file public partial class AppClient {     public void OtherAction()     {                     SubordinateMethod2(restClient);     }      private void SubordinateMethod2(IRestClient client) {} } 

This separates each action into its own file, however all of the subordinate methods within the class can access each other, since I’m defining it as a partial class. I’d rather have these actions grouped into their own classes. I have considered implementing the functionality into classes and then passing that functionality through interfaces to placeholder action functions on the main AppClient, however I don’t think that would work because I don’t want to make the web client public, and each action needs access to the web client. Is there is an obvious design pattern I should consider using?

Design patterns to indicate status on infinite scroll pages

There are several questions regarding design patterns that apply to infinite scroll such as What's the design pattern at the end of infinite scroll? and also What are best mobile navigation practices for infinite scrolling pages with a deep hierarchy?

However, my question specifically applies to design patterns that help indicate where the user is currently located within an infinite scroll section of a page, which is often simply handled by the same page scroll bar. While this is a solution to the design pattern, it exists by default and isn’t designed specifically to handle this issue.

There are also instances of two scroll bars on the same page, which causes some confusion with users, not the least of which exists on the mobile page views of having to manipulate two scroll bars in a very limited space.

Are there good examples of how infinite page scrolls are handles in a web or mobile application that provides clear indication of where the user is currently located and allows then to navigate the content?

Best practices or patterns for “Saved Search” and “Edit Saved Search”?

I have been tasked with redesigning our saved search function, as it has been deemed confusing (and I can’t find another site that works like ours does currently). Are there any standard ways of handling both Saving a search and then allowing people to edit and save changes to a search? I have checked out what Ebay does. Is that fairly standard?

Edited to include the ebay (UK) example: enter image description here

Combination of different behavior patterns to identify unique user [on hold]

I want to create digital profiles of users interacting with my website for security purposes.

Using behavior analytics data, I am collecting all sorts of data. This data ranges from keystrokes to mouse usage to website navigation and many more.

Once I have a good amount of behavioral data per user, I can use this to find fraudulent users. For e.g. a user has his own style of typing (latency b/w key presses). A fraudulent user may use keyboard differently.

What set/combination of features sets apart 2 users from each other?

This question is intentionally kept a bit general to generate discussion and good feedback.

Good examples of UI patterns for data assembling

I’m particularly interested in Node based UIs and I have a few questions:

1. What are good and elegant services in your opinion that use these pattern to create complex outputs? (I really like how https://lobe.ai/ manages to use this UI pattern in a very effective way).

2. Are there other alternative UI patterns that work well with data assembling like Nodes and Networks? (I’m thinking something like https://roli.com/products/blocks ).

3. Where can I find a list of UI patterns used in desktop software GUIs and services where the user has to assemble or build something. (Here I’m thinking to 3d softwares or Layer based UI of Photoshop).