referring to the e-book patterns for parallel programming.
i read the e-book and learn a lot of new things. but i wonder which pattern to choose.
for example Parallel class, task class, PLINQ, ThreadPool class, ...
is there any resource that provide more information about parallel programming in .net 4?
Different patterns are designed for different types of application.
Task class: when the parallel jobs you want to execute are independent of each other & the order of completion doesn't matter. The jobs may be of irregular size. E.g. Manufacturing a car. It doesn't matter which parts(tire, engine, doors etc) are produced in which order. You only care that car is manufactured in the end and you are doing it in parallel so as to complete it as quickly as possible.
Parallel class: This type is for tasks that are independent and similar but the tasks are of almost equal size. E.g.: A simple for loop where the iterations are independent.
Threadpool class: This is somewhat a combination of the above two except that there can be certain level of dependencies between threads which can be managed by the developer (E.g.: by executing threads in some order OR executing a thread based on the results/conditions obtained from other threads etc).
Note that the choice of parallel pattern is not exclusively yours! Most of the times, one is forced to pick one or another based on the kind of application that's being implemented.
Task and Parallel are not patterns, they're classes or namespaces. These classes can be used to implement various common parallel patterns. In some cases only a single class is required to do this, for example data parallelism with Parallel.ForEach. In others different classes must be used in concert to develop a solution, for example implementing a pipeline with Tasks and BlockingCollection.
The ThreadPool can actually be considered an implementation detail upon which the Task Parallel Library in .NET 4 is built. Tasks represent an abstraction over the thread pool allowing developers to specify work as Tasks and have the .NET runtime handle scheduling the work as efficiently as possible in a hardware independent and scalable way.
Patterns discussed in the book aren't really applicable at the application level, they are more like the design patterns described by the Gang of Four. Typically an application consists of many lines of code that use many different patterns. For example an image processing application might use the Model-View-Controller pattern to separate concerns of the View (GUI) and the Model. The model itself might use a pipeline and data parallelism. You can see just such an example in the pipelines chapter of the book.
there is an official documentation in MSDN explaning parallel patterns and section (Selecting the Right Pattern).
Related
According to "Head First Object-Oriented Analysis and Design", Complex projects involves first finding a feature list -> drawing use case diagrams -> breaking into smaller modules before implementing object oriented design (requirements gathering -> use cases -> OO -> design patterns etc.)
I want to understand, what is the criteria for the size of project when feature lists and use case diagrams should be implemented before finding requirements and writing use cases?
I am particularly interested in how can this knowledge be applied to my real wold problems
Example, I am working on a UI that send instrument commands to the server and displays the response back from the server. I know from customer feedback that the UI should have the following things:
It should be able to let the user select an instrument from available list and send any custom command and display the result
It should be able to let the user select an instrument and a command from available list and display the result (create commands using drag and drops from given lists)
It should be able to have capability of creating macros
Is this UI project small enough to not have steps for gathering features and drawing use case diagrams? Do we go straight to categorizing the asks as requirements and start gathering requirements and writing use cases?
How would one go about breaking down project of this nature to deduce it to its appropriate class diagrams?
I have tried considering the above mentioned asks as features and then tried creating requirements, mainly on the different states that one could have during the life cycle of the UI application but I am still not sure and unable to comprehend the teachings of the books on this project.
I haven't read the book, so I'm not sure what the author(s) of the book really wanted to emphasize here. But I assume that you misinterpreted it.
Without knowing the requirements there is no feature list. If you don't know what is needed then you can't say anything about the system's capabilities.
Gathering requirements is an iterative process. First you gather the high-level requirements in order to be able to start building a mental model about the system. This can help you to start think about the supported features. By sharing your mental model and the exposed feature set of the system with the stakeholder, it initiates the next iteration.
Here you can start talking about actors, user journeys, use cases, etc. These are mainly focusing on the happy paths. As you have more and more iterations you will reach a point where you can start talking about edge and corner cases: What suboptimal cases can we foreseen? What can we do (prevention, detection, mitigation)? How does it affect the system/actors/journeys?...
The better you understand the needs and circumstances, the better the design and implementation of the system could be.
UPDATE #1
Will we always have high-level and low-level (edge cases and detailed use cases) requirements i.e. we will first need to make use case diagrams and then write individual detailed use cases?
There are a lot of factors which can influence this. Just to name a few:
Is it a system, submodule, or component design?
Is it a green or a brownfield project?
Is the stakeholder experienced enough to know which information matters and which doesn't from the IT project perspecitive?
Does the architect / system designer have previous experience with the same domain?
Does wireframe or mockup exist at project kick-off?
Should the project satisfy special security, legal or governmental regulations?
etc...
In short, yes there can be circumstances where you don't need several iterations, but based on my experiences that's quite rare.
I'm struggling with assigning the responsibilities in BPMN. In the process I'm designing, I have a task that can have different performers, depending on the instance details (software, hardware...).
Should I use an exclusive gateway and copy the task with different responsibles or is there an other way to make clear that there can be different responsibles?
In BPMN, you can't graphically model that multiple roles are responsible for one task. The reason behind this is simple; if the distinction between the roles is important enough to be graphically modeled, shouldn't you also model the condition that determines which role takes over the task, as well as the difference between the tasks?
The model below does this for a simplified IT support process:
On the other hand, you could argue that the difference between tasks and roles is not important enough to justify the added complexity in the graphical model:
Then, you could specify the distinction in the textual description of the task and/or in the configuration of the task in the execution environment (e.g. BPX engine).
You could also use a sub process element to 'hide' the details in a child process.
Note that some BPMN modeling software providers use vendor-specific BPMN extension elements (like Signavio's additional participant element) for modeling multi-participant task execution. However, these elements are typically useful in more complex responsibility assignment scenarios and not in the simple scenario we discuss here.
I am studying Object Oriented Design and am using usecases with actors and scenario''s to plan out the application i am trying to build. No specific language yet, just the theory at the moment.
I have come to the point where i have identified and written out the use cases for the users, administrator, owner, etc and also the external systems like the feed generator.
but i have come to realise that my application actually consists of multiple smaller apps. like a data gathering application and a analysis application.
Can/should i use the data gathering and analysis app as an actor in the overall application too?
I can write specific use cases for them, with scenarios etc.
Typically, no.
Actor is an entity that sits outside of the system and produces some action. It gets to the system boundaries, but then all interactions between system components are modeled not as usecases, but as i.e. dynamic diagrams or sequence diagrams.
For the record, I think this approach is flawed and doesn't really help you in building applications. I personally prefer thinking about components and their interactions directly, without forcing the idea of architecture to fit a particular modeling scheme.
This question is related to diagraming a software process. As an electrical engineer, much of the software I do is for embedded micro-controllers. In school, we learned to illustrate our algorithm using a flowchart. However, nowadays, many of my embedded projects are heavily interrupt-driven where the main process runs some basic algorithm a variety of interrupt sources provide its stimulus. So, my question is, what are some diagramming techniques that I can use to illustrate my process such that future developers can understand what I am doing easily and get involved in development?
Here are some key features that I am looking for:
Shows data structures and how data is passed between processes & interrupts
Shows conditions that cause each interrupt
Shows how data is gathered and passed through a downlink
Shows how command messages are received, parsed, and executed
Ideally is well suited for hierarchical breakdown into smaller processes with greater levels of detail
I've always seen interrupt timing drawn as follows:
Or inline line so:
But I prefer the former as it gives more room for annotation.
In response to your comment, perhaps a UML state machine diagram (with some adaptation) may be closer suited to your purpose:
There are many of interesting approaches you can find in diagram drawing. I will post a few here. You will find a lot of Operation System and Architecture scpecific names in there such as register , event, function names and etc. It is more for representation so far, right? So he we are.
Use UML class diagrams for showing data structures. Use sequence diagrams to show interactions between classes and interrupt service routines (showing function calls only). Use activity diagrams to show how interrupts interact with processes (signals are good for this). An activity diagram can also be used to show the process of receiving data, parsing it, and dispatching it. This can also be represented in a static view by a package diagram where the command handler is in one package and the command parser is in another, connected by a dependency line. Use cases are good for a high level view of functionality.
The main point is that UML supports many different views (static, dynamic, logical, deployment) into your system. Don't try to express everything at once.
The diagram below shows an example of an interrupt to a process.
I wonder how create a CSP library for obj-c, that work like Go's channels/goroutines but with idiomatic obj-c (and less boilerplate than actual ways).
In other languages with native courutines and/or generators is possible to model it easily, but I don't grasp how do the same with the several ways of do concurrent programing in obj-c (plus, the idea is have "cheap" threads).
Any hint about what I need to do?
I would look at the State Threads library as it implements roughly the same idea which underlies the goroutine switching algorythm of Go: a goroutine surrenders control to the scheduler when it's about to sleep in a syscall, and so the ST library wraps OS-level file descriptors to provide their own FD-like objects which can be read from (and/or written to) but instead of blocking the whole process these operation transfer control to other light-weight threads managed by the library.
Then you might need a scheduler more advanced than that of the ST library to keep OS threads busy running your SPs. A no-brainer introduction to the Go 1.2 scheduler is here, and it contains a link to a more hard-core design document. The rest is in the Go's source code.
See also this answer on SO.
Create operations, e.g. for an example consider this process:
process x takes number from east, transforms it to a string, and gives it to west.
That I could model it with an object that keeps an internal state of x (consisting of number and string) and the following operations:
east-output, operation defined somewhere else by east process logic
x-input, operation that depends on east-output. It copies number from east-output's data structure into x's data structure
x-output, operation that depends on x-input. Its content is defined as purely internal transformation - in our example, stringWithFormat...
west-input, operation that depends on x-output, etc.
Then you dump the operations into NSOperationQueue and see what happens (does it work, or are there contradicting dependencies...)