https://www.google.com/contributor/welcome/?utm_source=publisher&utm_medium=banner&utm_campaign=2376261057261409

Search This Blog

Search with our Site

Custom Search

Friday, January 20, 2012

CS304 GDB Solution & Discussion Last Date:24-01-2012

GDB will remain open for two consecutive working days. For this you have choice to post your comments from 23rd January to 24th January.
Topic is as follows:
“As the role of Template in programming is vital. Let’s suppose you are an Application development Analyst. You are given a task to highlight the value of using Templates in developing the Architecture for a large scale project.
Do you think that usage of Templates in given requirement is useful? Justify your answer with maximum five major points”.

Read more: CS304 GDB Solution & Discussion Last Date:24-01-2012 - Virtual University of Pakistan http://vustudents.ning.com/group/cs304objectorientedprogramming/forum/topics/cs304-gdb-solution-discussion-last-date-24-01-2012#ixzz1k08wFMtE

3 comments:

  1. CS304 GDB Idea Solution 2012
    CS304 GDB Idea Solution 2012
    Some uses of templates, such as the max() function, were previously filled by function-like preprocessor macros(a legacy of the C programming language). For example, here is a possible max() macro:

    #define max(a,b) ((a) < (b) ? (b) : (a))
    Both macros and templates are expanded at compile time. Macros are always expanded inline; templates can also be expanded as inline functions when the compiler deems it appropriate. Thus both function-like macros and function templates have no run-time overhead.
    However, templates are generally considered an improvement over macros for these purposes. Templates are type-safe. Templates avoid some of the common errors found in code that makes heavy use of function-like macros. Such as evaluating parameters with side effects twice. Perhaps most importantly, templates were designed to be applicable to much larger problems than macros.
    There are three primary drawbacks to the use of templates: compiler support, poor error messages, and code bloat. Many compilers historically have poor support for templates, thus the use of templates can make code somewhat less portable. Support may also be poor when a C++ compiler is being used with a linker which is not C++-aware, or when attempting to use templates across shared library boundaries. Most modern compilers however now have fairly robust and standard template support, and the new C++ standard, C++0x, is expected to further address these issues.
    Almost all compilers produce confusing, long, or sometimes unhelpful error messages when errors are detected in code that uses templates. This can make templates difficult to develop.
    Finally, the use of templates requires the compiler to generate a separate instance of the templated class or function for every permutation of type parameters used with it. (This is necessary because types in C++ are not all the same size, and the sizes of data fields are important to how classes work.) So the indiscriminate use of templates can lead to code bloat, resulting in excessively large executables. However, judicious use of template specialization can dramatically reduce such code bloat in some cases. The extra instantiations generated by templates can also cause debuggers to have difficulty working gracefully with templates. For example, setting a debug breakpoint within a template from a source file may either miss setting the breakpoint in the actual instantiation desired or may set a breakpoint in every place the template is instantiated.
    Also, because the compiler needs to perform macro-like expansions of templates and generate different instances of them at compile time, the implementation source code for the templated class or function must be available (e.g. included in a header) to the code using it. Templated classes or functions, including much of the Standard Template Library (STL), cannot be compiled. (This is in contrast to non-templated code, which may be compiled to binary, providing only a declarations header file for code using it.) This may be a disadvantage by exposing the implementing code, which removes some abstractions, and could restrict its use in closed-source projects.


    Read more: CS304 GDB Solution & Discussion Last Date:24-01-2012 - Virtual University of Pakistan http://vustudents.ning.com/group/cs304objectorientedprogramming/forum/topics/cs304-gdb-solution-discussion-last-date-24-01-2012#ixzz1k097gfap

    ReplyDelete
  2. Helping Material


    You can use templates to:

    Create a typesafe collection class (for example, a stack) that can operate on data of any type.
    Add extra type checking for functions that would otherwise take void pointers.
    Encapsulate groups of operator overrides to modify type behavior (such as smart pointers).
    Most of these uses can be implemented without templates; however, templates offer several advantages:

    Templates are easier to write. You create only one generic version of your class or function instead of manually creating specializations.
    Templates can be easier to understand, since they can provide a straightforward way of abstracting type information.
    Templates are typesafe. Because the types that templates act upon are known at compile time, the compiler can perform type checking before errors occur.


    Read more: CS304 GDB Solution & Discussion Last Date:24-01-2012 - Virtual University of Pakistan http://vustudents.ning.com/group/cs304objectorientedprogramming/forum/topics/cs304-gdb-solution-discussion-last-date-24-01-2012#ixzz1k09JSbTC

    ReplyDelete
  3. Helping Material


    You can use templates to:
    Create a typesafe collection class (for example, a stack) that can operate on data of any type.
    Add extra type checking for functions that would otherwise take void pointers.
    Encapsulate groups of operator overrides to modify type behavior (such as smart pointers).
    Most of these uses can be implemented without templates; however, templates offer several advantages:
    Templates are easier to write. You create only one generic version of your class or function instead of manually creating specializations.
    Templates can be easier to understand, since they can provide a straightforward way of abstracting type information.
    Templates are typesafe. Because the types that templates act upon are known at compile time, the compiler can perform type checking before errors occur.


    . You know how your finished site looks. You can choose the template that appeals to you. You need not rely on a web developer to get a good looking website.

    2. Faster turnaround. You need not spend a lot of time on getting the colors and layout right. You can go straight to changing text and proceed with programming.
    3. Templates are much cheaper than hiring a web developer. There are several sites that offer free templates as well.
    4. Templates look much better than sites developed in traditional HTML programming. Templates are designed by professionals that are creative and competent and experienced.
    5. Templates can be customized by anyone with basic HTML knowledge. You can customize the template yourself using a text editor.


    Read more: CS304 GDB Solution & Discussion Last Date:24-01-2012 - Virtual University of Pakistan http://vustudents.ning.com/group/cs304objectorientedprogramming/forum/topics/cs304-gdb-solution-discussion-last-date-24-01-2012#ixzz1k09OlFjD

    ReplyDelete