What are templates for? Document templates

The most memorable moments of our lives always remain with us. Some people reconstruct pictures of the past from their own memory, but most have documentary evidence in the form of photographs.

Special moments are always precious, but rarely perfect, which is why millions of people install Photoshop. Each PSD file of this program makes the real better:

Photoshop is not the easiest program. Of course, attaching pig ears to your best friend is a must and does not require any special skills. But making these ears look like their own is a task for more experienced users.

There are people who, due to their occupation, have to use Photoshop. There are different professions, so the goals for creating graphic objects also differ. Sometimes you only need to change images slightly to get the desired effect. It is in such cases that templates for Photoshop are ideal, which will be discussed in this article.

Why are templates needed?

A template is an object created once for subsequent repeated use. When using Photoshop, there are many situations where ready-made solutions are required. Let's look at the two most common categories.

  • Templates for photomontage. With their help you can create really beautiful photographs. The template helps to simulate the desired interior or natural conditions:

In this case, as a rule, the human figure is taken completely.

  • Photo templates. Nothing is impossible for Photoshop: Brad Pitt can dress up in a swimsuit, and your dog can become president. Photo masks allow you to insert a face into the desired place in a photo, similar to the famous entertainment on sea beaches ( stick your head into the cardboard decoration):

How to make someone a businessman

For a person who has even the most general knowledge of Photoshop technologies, inserting a face into a template will not be difficult. Let's do this step by step.

First, you need to buy ( or download for free) template you like. This file has a psd extension and opens in the same way as any image of a supported format (“File” - “Open”). After this, the template for Photoshop is at our complete disposal:

Business is business, so you need to choose serious characters. Open the desired photo and drag the image onto the template:

Now you need to adjust the image to size. Should be reduced proportionally. We also cut off as much unnecessary stuff as possible.

Let's go to the layers window. In order for the face to fit harmoniously into Photoshop templates, it must be placed in the background relative to the main layer. In our case, we move Layer 2 to the desired location:

What was left was a not-so-attractive gray area around the face. Let's remove it" with a magic wand»:

With correctly selected proportions and careful cropping of the image, you can achieve perfect integration of the face into Photoshop templates; it only requires practice and time.

Create templates yourself

Situations often arise when the available templates do not suit the style, in which case the do-it-yourself method is used. Before you start making templates for a photo shoot with your own hands, you need to consider the following points.

Although template standards have been published for a long time, they are still not widely distributed. Of course, it's hard to use something that your compiler doesn't support, which is probably the number one reason why most C++ programmers don't know how to work with templates. Fortunately, now all the major compilers have entered the twentieth century, so this problem has already disappeared. All that remains is to understand what a template is, how to bypass all the syntactic traps, but above all, why it is needed. This chapter goes beyond a syntax overview. It also covers the basics of type safety in C++, with a special focus on templates.

What are templates and why are they needed?

The interface of a simple collection class (using a linked list as an example) looks like this:

class ListNode ( private:

ListNode* next; void* data;

ListNode(void* d, ListNode* n = NULL) : next(n), data(d) () ~ListNode() ( delete next; )

void* Data() ( return data; ) ListNode* Next() ( return next; )

Noticed anything special?

Problems

First of all, all these void* are striking. Both you and I know very well that in fact behind them lies something completely different. Somewhere in the client code you will have to do something like this:

for (ListNode* n = listHead; n != NULL; n = n->Next()) f((Foo*)n->Data());

In other words, you will have to constantly cast void* to a concrete type. But how can you be sure that the resulting pointer is actually of type Foo* ? Here you will have to rely only on yourself, because the compiler, with the words “I hope you know what you are doing,” washes its hands of it. Let's say you're confident that your use of a class is type safe. But is it possible to guarantee that another programmer won’t do something stupid and add an object of a different type to the collection? If you firmly believe in this, I recommend staying away from risky investments and investing your money in government securities, you are unlikely to have luck in this life.

The second problem is that the list elements don't know what type they point to. Let's say you want the list destructor to delete not only the nodes themselves, but also the data they refer to. You can't pass a void* pointer to the delete operator and hope that it will choose the right destructor.

Workarounds

One possible solution is to require that all objects in your collection descend from a common ancestor. In this case, void* can be replaced with a pointer to the base class, creating at least the appearance of order. If the base class destructor is virtual, at least we can rewrite the ListNode destructor so that when it commits suicide, it also destroys the contents of the list. But if that base class has derived classes, you'll certainly end up having to do unsafe casts to those derived types.

Another workaround is to create a list tailored to a specific type. Let's say, to maintain a list of objects of class Foo, a collection class ListOfFoos is created. In this case, you won't have to do type casts if Foo has no derived classes. But is it worth creating duplicate classes that differ only in the types they work with? Of course, cutting and pasting in text editors is a wonderful thing, and word processing scripts help you quickly reproduce code. But if you need to change the presentation of all those lists, you'll inevitably end up with a massive headache.

In the past, problems like this were often solved using #define macros:

#define ListNode(Type) \ class ListNode##Type ( \ private: \

ListNode##Type* next; \Type* data; \

ListNode##Type(Type* d, ListNode* n = NULL) : next(n), data(d) () \ ~ListNode() ( delete next; ) \

void* Data() ( return data; ) \ ListNode* Next() ( return next; ) \

If you accidentally forget to include a \ , the compiler will erupt in loud howls of indignation, but with due care this technique works. The ## symbols indicate concatenation. The design gets even uglier, but you have to put up with it - you must ensure that collection type names are unique. This technique has numerous disadvantages. If the class functions are not inline, you will have to create additional macros for them and ensure that they are implemented in the same compilation unit. Some compilers have problems with macros that are too long. #defines cannot be nested, so recursive, type-safe data structures are no longer required. The worst thing is that when an error is detected in a macro, the debugger folds its arms and reports that there was an error somewhere in the macro, but does not indicate a specific line number.

Templates - advanced macros

The template engine comes into the picture - an improved macro processor for #define directives. Templates are nothing more than macros without all the limitations listed above. They can be nested. You won't have to worry about duplicating their functions. Most C++ debuggers correctly specify the pattern string when an error occurs. The size of the template will not cause any problems. Finally, you don't have to ruin your beautiful program with squiggles like \ and ## .

More and more often, I hear from developers and read in articles that no one needs design patterns (aka design patterns). They say that they appeared during the “blooming” of UML, RUP, CASE systems and other overly “complex” tools, approaches and practices. And now the most important thing is to write working code, and quickly. No one has time for smart, thick books, except for an interview. For those who want to discuss this topic, please go to cat.

Some memories from my youth

When I was at university, we were taught design patterns as part of one of our courses. At that time, they seemed to me something like a spherical horse in a vacuum, because I had no practical experience in using them (this was my third or early fourth year, many years ago). It was also quite difficult to remember which of them was which, not to mention the subtleties and details. However, questions on design patterns were asked without fail in every job interview. Candidates had to puff out their cheeks and prove how cool various templates are (especially Singleton), having seen them in life at most once or twice on the pages of books.

But it’s not stupid people who came up with design patterns:

  • IN 70s years, architect Christopher Alexander started the business and formulated a set of design patterns.
  • His business in IT was picked up far away 1987 year, the notorious Kent Beck and Ward Cunningham, who compiled design patterns for the popular Smalltalk programming language.
  • Another legendary person in IT, Erich Gamma, wrote a doctoral dissertation on this topic in 1988-1990 .
  • And finally, in early 90s The famous “gang of four” consisting of the same Erich Gamma, Richard Helm, Ralph Johnson and John Vlissidsome published the legendary book “Design Patterns: Elements of Reusable Object-Oriented Software”.

There is no point in continuing the historical chronicles any further. This was the first book from which our generation took their knowledge of design patterns and tried to apply them in their work. It is considered a classic on the subject and a must read.

After some time of work, I began to notice that even theoretical knowledge of design patterns helps me understand someone else's code much faster. And this is especially important at the start of your career, when you need to delve into existing projects without work experience. For example, when I encountered a class with the Builder suffix, I understood that it was added to simplify and isolate the logic of constructing complex objects. I immediately easily found how to use it and apply it in my code. Representatives of the Singleton template were scattered everywhere, it was so easy to make a mistake when initializing them without knowing the rules of application. In the code I worked with, Facade, Visitor, Chain of Responsibility, Iterator, Adapter, Decorator, Proxy, Strategy, Template Method and other popular design patterns were abundant.

I realized how much time I save by applying my meager book knowledge of design patterns and even began to respect their authors in my heart. It was easy for me not only to understand other people’s code, but also to expand it with my own solutions, as well as add new ones.

What about without templates?

Time passed... I quickly got used to the widespread use of design patterns and it became difficult for me to work without them. I began to understand why candidates are asked about them during interviews (of course, if not just “for show”). Here we are not even talking about the mandatory use of design patterns, but about simplifying communication between developers. And this is the process that occupies a key place in development - discussion of the architecture and design of a specific solution to a problem.

The first important parameter is time spent discussing and making decisions(I hope that your decisions are made by more than one bearded Senior Senior Global Product Software Architect). Imagine how difficult it would be to quickly explain to someone that you need to implement a Decorator: “we need to make a class to which we pass in the constructor an instance of another implementation of the same interface and which will add logic to the call of these methods without changing their basic behavior. ..” But there are still a lot of little things and nuances left behind the scenes. And this is for a small detail of your design, of which there are dozens, or even hundreds, in most solutions. We don't even touch complex and serious architectural patterns.

Using the example with Decorator, it is easy to understand the second important parameter - same understanding of design solving the problem in the minds of all team members. If the wording is vague, everyone can understand the solution differently, and this is fraught with problems. After all, the implementation may differ greatly from the idea under discussion. And this will lead to additional time for code review and rework.

The third important parameter is understanding of third-party tools and libraries. At the moment, almost every project uses many third-party solutions. In order to use them correctly and not step on the rake, the architect and developer must understand how things work. And for this, well-known templates are used, which are designed to greatly simplify understanding and compare with alternative solutions.

In life, we actively use examples to describe situations, objects, and actions. To explain a concept to someone, we rely on common knowledge and build examples around it. “As healthy as Vasya”, “as hard as after a 5 km run”, “as bad as a hangover”, “sour as a lemon”, etc. We use such expressions in our speech all the time and don’t even notice it. For us, their use is simpler than a detailed description and this allows your interlocutor to understand you better.

Next level

If you notice that you are not trying to remember the implementation details of a design pattern, but can simply state the details of its application in your own words, then you have outgrown the Shu level in the famous Eastern philosophy of Shuhari (I wrote a long time ago about its applicability to Agile approaches and practices) . At the level Shu you simply follow patterns and fail to recognize their usefulness, subtleties, and impact. At the Ha level, you are already aware of everything and can consciously refuse certain patterns, criticize decisions based on them, and modify some patterns to suit a specific situation and context.

At the level Ha I highly recommend reading the excellent book “Refactoring to Patterns” by Joshua Kerievsky. It talks about how to find inappropriate or poorly applied design patterns in code, and then refactor them into correct and appropriate solutions. This book should be read at the Ha level, because before that it will be just an empty phrase for you.

What about the level? Ri? At this level, you stop thinking about using templates altogether. Solutions are born naturally from your knowledge and skills that you have accumulated over the years. Somewhere only templates emerge, somewhere your own developments, which have become templates for you in this context. The chain “from template to solution” stops working in your head and only “from solution to template” remains. Then, instead of asking questions about specific design patterns in the interview, you move on to open-ended questions about the applicability of the tool and real-life examples...

Conclusion

Design patterns are one of the developer's tools that help him save time and make a better solution. Like any other tool, in some hands it can bring a lot of benefit, but in others it can bring only harm. I tried to convey with examples what exactly design patterns will give you and how you should treat them. I hope I succeeded...

P.S. At one of my trainings, the book on design patterns for beginners “Head First Design Patterns” was praised. Personally, I haven’t read it myself, because I had enough knowledge of the topic from other sources and am distrustful of books of this format.

Document templates are needed to automatically fill fields and tables in MS Word documents with data from the database. This allows you to create documents such as Application, Invoice, Invoice, Invoice, Agreement, Act and much, much more. They can be printed, sent by mail, etc.

How do document templates work?

A menu item appears in any table Document templates.

Selecting this menu opens a list of document templates for this object.

By selecting a template and clicking the button Fill in you will receive a completed document.

Preparing to use document templates

These settings only need to be made once.

  • Create a card for an object Document template. Add a field to it Name.
  • Create a table for the object Document template. Add fields to it Name And File.

Setting up a document template

After re-login, select menu Settings - Templates documents. A dialog will appear in which document templates are configured.

Description of window zones:

  1. List of all templates for all objects.
  2. Template object.
  3. Template object fields.
  4. Fields of child relationship objects, if any.

The Document section contains the following buttons:

  • Create- creates a new document in MS Word.
  • Open- opens a previously saved MS Word document or prompts you to specify an existing one.
  • Save- saves the MS Word document and marked fields.
  • Close- closes the MS Word document without saving.

The third and fourth zones contain fields that are inserted into the document. There are buttons:

  • Change- renames the field so it can be shorter.
  • Insert- insert the field into the MS Word document where the cursor is.

In the fourth zone, you can right-click on the marked field and set the sort.

Template customization example

Let's assume that you want to create a template that will display information about a client and his purchases.

  1. Add a new template by clicking the button Add(left).
  2. Create a new document by clicking the button Create. MS Word opens with a new blank document.
  3. Mark the required fields and insert them into the document. To do this you need:
    1. Place the cursor in the document at the desired location.
    2. Select the desired field in the program and press the button Insert.

If required, configure sorting in tables.

This is what setting up a document template in the program looks like:

And this is what the document template itself looks like with fields:

Filling out the document template

To use document templates, you need to give the appropriate permission to the user and the object. Then:

  1. Open the table of the desired object.
  2. Select the desired entry in the table.
  3. Select menu More- Document templates.
  4. Select the required template and click the Fill button.

As a result, we get a completed template.

You can now print this document or save it if required.

Additional information

  • Use fields no more than 255 characters long (as of version 1.12).
  • Do not manually close a document in MS Word. Close it only through the program with the button Close.
  • Use child object fields only in MS Word tables.
  • Use a special pattern [N] in tables to sequentially number data in tables.
  • In the network version, place templates along the network path.
  • When you insert a child object field you will see a number, do not remove it. This is the communication code. He is needed.
  • If you decide to rename a field, rename it first and then insert it.
  • Only fields marked with a checkmark are filled in.
  • Only the fields of the object and the fields of child objects are used. Fields of child objects of child objects cannot be used.
  • You can use several tables of child objects in one template.
  • The path to the document template can be relative (starts with a dot):
    .\Templates\Invoice.doc
  • Double-clicking on a hierarchy element places a flag on it and inserts it into the document.

General concepts about web construction.

Website creation today it is reaching a whole new level. Sometimes web designers pleasantly surprise you to the core with their talent, skill and ability to translate their plans into real life, and the works created by masters truly deserve to be considered a modern art form. Modern technologies help simplify images web design, and on the other hand, a considerable amount of knowledge in various sciences is required, as well as fairly good skills in computer technology.

Website templates: what are they for?

High price author's website design, made to order, is sometimes quite a serious obstacle to existence on the Internet: the services of professional web developers are not cheap, and high quality design a website can cost several hundred dollars. With such high costs, there is no certainty that the cost of creating a website will pay off. Website templates in this situation - the optimal solution. When using them costs for either very low or non-existent (provided you download the template for free).

Website templates- What is this?

A website template is an HTML page that you use to work on your website yourself. All template design graphics and its service files (PSD, CSS, Java scripts) have already been professionally developed web designer, and you only need to change its contents with your text and pictures.

Typically, sites are made for use in some kind of HTML editor, and to change them, the skills of an ordinary PC user are sufficient.

The composition of the files included in the delivery of a website template depends on whether you are willing to pay for it.

Paid website templates always contain all the files necessary for editing, with which you can change the design graphics (PSD, Flash).

Free website templates, are mainly provided in the form of a single web page and its required files. The free template core files are missing.