суббота, 7 июля 2012 г.

Возможность

Interface

Abstract class

Множественное наследование

Класс может реализовывать несколько интерфейсов.

Класс может наследоваться только от одного абстрактного класса.

Имплементация методов

Интерфейс не может содержать имплементации, только сигнатуры методов (чисто виртуальные методы).

An abstract class can provide complete, default code and/or just the details that have to be overridden.

Access Modfiers An interface cannot have access modifiers for the subs, functions, properties etc everything is assumed as public An abstract class can contain access modifiers for the subs, functions, properties

Core VS Peripheral

Interfaces are used to define the peripheral abilities of a class. In other words both Human and Vehicle can inherit from a IMovable interface.

An abstract class defines the core identity of a class and there it is used for objects of the same type.

Homogeneity

If various implementations only share method signatures then it is better to use Interfaces.

If various implementations are of the same kind and use common behaviour or status then abstract class is better to use.

Speed

Requires more time to find the actual method in the corresponding classes.

Fast

Adding functionality (Versioning)

If we add a new method to an Interface then we have to track down all the implementations of the interface and define implementation for the new method.

If we add a new method to an abstract class then we have the option of providing default implementation and therefore all the existing code might work properly.

Fields and Constants No fields can be defined in interfaces An abstract class can have fields and constrants defined
http://www.codeproject.com/Articles/258173/Interfaces-Vs-Abstract-Classes

суббота, 14 апреля 2012 г.

Свойства привязок

Привязки и режимы безопасности передачи
Привязка None Transport Message Mixed Both
BasicHttpBinding ✔(default) ✔ ✔ ✔ ✕
NetTcpBinding ✔ ✔(default) ✔ ✔ ✕
NetPeerTcpBinding ✔ ✔(default) ✔ ✔ ✕
NetNamedPipeBinding ✔ ✔(default) ✕ ✕ ✕
WSHttpBinding ✔ ✔ ✔(default) ✔ ✕
WSFederationHttpBinding ✔ ✕ ✔(default) ✔ ✕
WSDualHttpBinding ✔ ✕ ✔(default) ✕ ✕
NetMsmqBinding ✔ ✔(default) ✔ ✕ ✔

вторник, 13 марта 2012 г.

Кросс-доменные запросы

Достаточно много головной боли вызывают кросс-доменные запросы в разных браузерах.
Упростить это можно, если получать данные из другого домена на сервере (веб-сервис или IHttpHandler), а из браузерного ява-скрипта уже асихронно обращаться к этим данным.

воскресенье, 5 февраля 2012 г.

Способы хранения данных в ASP.NET

Их можно поделить на 4 вида:
1. web-based, то есть для которых используются механизмы броузера и веб-сервера. Это
ViewState
ControlState
Session
Cookies
HttpContext.Current.Items
А также сохранить в полях HiddenField.

2. классы Application и Global.

3. Средства самого .NET
Статические классы и кеш.

4. Свойства профиля пользователя.

пятница, 3 февраля 2012 г.

Static class или Singletone?

по этому вопросу, у меня как и у многих программистов нередко в голове случаются нелегкие баталии.
Итак, если у нас какой-то метод обеспечивает единую точку доступа к классу,
Например, в .NET remoting, если мы создаем клиентский прокси-класс к хостовому классу, то класс, который будет этим заниматься и будет синглтоном, неважно статический или динамический класс.
Плюс накладка: статические классы наследуются только от типа object и сами не могут иметь наследников.

пятница, 20 января 2012 г.

Структуры и IDisposable

Да, структуры поддерживают интерфейсы, и можно реализовать IDisposable в том числе. Однако такую структуру следует рассмотреть как подходящий кандидат в классы.