Epic Blog of Awesome

code.tech.sci.math.art.write

Better random numbers in .Net: an updated Mersenne Twister in C# – Home

The Mersenne Twister is a rather well-known algorithm for generating pseudo-random numbers. It is fast and has a huge period range over which it doesnt repeat itself, which makes it ideal for simulation. However, the sequence can be guessed after only 624 numbers have been generated, so it is not useful for cryptography. It was first published in 1998 by Makoto Matsumoto and Takuji Nishimura using C code.

via Better random numbers in .Net: an updated Mersenne Twister in C# – Home.

Java Chat Bot Tutorial A.I Artificial Intelligence Chatbot Tutorial Chatterbot Tutorial this is a basic introduction to how to implement a chatbot in Java or other programming languages

Basically, a chatterbot is a computer program that when you provide it with some inputs in Natural Language English, French … responds with something meaningful in that same language. Which means that the strength of a chatterbot could be directly measured by the quality of the output selected by the Bot in response to the user? By the previous description, we could deduce that a very basic chatterbot can be written in a few lines of code in a given specific programming language. Let’s make our first chatterbot notice that all the codes that will be used in this tutorial will be written in Java. So, it is assumed that the reader is familiar with this language

via Java Chat Bot Tutorial A.I Artificial Intelligence Chatbot Tutorial Chatterbot Tutorial this is a basic introduction to how to implement a chatbot in Java or other programming languages.

Apache Jelly – Wikipedia, the free encyclopedia

Apache Jelly is a Java and XML based scripting and processing engine for turning XML into executable code.[1] Jelly is a component of Apache Commons.Custom XML languages are commonly created to perform some kind of processing action. Jelly is intended to provide a simple XML based processing engine that can be extended to support various custom actions.

via Apache Jelly – Wikipedia, the free encyclopedia.

Server Side Paging using SQL Server 2005 – SQLTeam.com

A common activity in applications is to page results or record sets from a database. This is usually done on the client using the clients paging functionality or on the server through a variety of methods. In SQL Server 2000 those server side methods typically used dynamic SQL or nested TOP clauses and werent very efficient. Using Common Table Expressions in SQL Server 2005 we have a better way to page record sets on the server.The Members Page on SQLTeam.com lists the first 20 members sorted by number of posts. In order to generate this it selects the entire set of members, returns it to the client and then displays the first 20 rows using ADOs paging functionality. The SELECT statement it runs looks something like this

via Server Side Paging using SQL Server 2005 – SQLTeam.com.

>Creating RIA Services Solutions

>

Default Solution Structure

In the default solution structure, RIA Services creates a single client project and a single server project. When you create a new project with the Silverlight Application template and select the Enable WCF RIA Services check box, you create a solution with the default structure. A RIA Services link exists between the two application projects. When you build the solution, client code is generated for domain services and shared code. The following illustration shows the default solution structure.

Default Project Structure

The default solution structure is convenient because all domain service types and shared code added to the server project are automatically available to the Silverlight client project after you build the solution. Also, the shared code you add to the server project is visible in the client project. This structure works well when you do not have many domain services in the server project and you do not need to reuse business logic across many different Silverlight applications.

In a solution with the default structure, you can add more Silverlight applications with a RIA Services link to the server project. However, there are limitations of the default structure. The generated code for each Silverlight client can access all of middle-tier code from the server project. For example, if you have three Silverlight applications linked to a single server project and you want to add a domain service that will be used by only one of the Silverlight applications, all three client applications will have a generated domain context for the domain service and will be able to access that domain service.

For more information, see Walkthrough: Creating a RIA Services Solution. For more information about the code generated for a client project, see Client Code Generation.

Silverlight Business Application template

RIA Services also provides a Silverlight Business Application template. This template provides a convenient starting point for building a business application that utilizes Silverlight for the client. The template builds on the Silverlight Navigation Application and uses RIA Services to support authentication and user registration. When you create a project by using the Silverlight Business Application template, RIA Services creates the solution with the default structure. The Silverlight Business Application automatically adds the following features:

  • Login window

  • Registration window

  • Silverlight Navigation

The default authentication mode for the Business Application is Forms Authentication. To use Windows Authentication, you simply change the value of the authentication element in the Web.config file, such as <authentication mode=”Windows”/>, and change the value of the Authentication property on the generated WebContext class. The Business Application template automatically contains code to support either FormsAuthentication or Windows Authentication. For more information, see Walkthrough: Using the Silverlight Business Application Template.

The Services folder of the server project contains the domain services that expose user registration and user authentication. The user registration service utilizes the ASP.NET membership provider to create new users. In the server project, a folder named Models contains classes for defining properties for user and registration data. You can add properties to these classes to customize the user data for your application.

In the client project, the Business Application contains code to simplify developing the presentation layer. The Libs folder and the Controls folder contain assemblies and controls that are used within the template. The Login folder (located within the Views folder) contains the authentication and user registration controls. These controls are automatically enabled in the project. The Resources folder (located in the Assets folder) contains resource strings for text within the project. As you add text to your application, you can add them to the file for application strings.

For more information, see Walkthrough: Using the Silverlight Business Application Template.

Posted via email from Mocha Brain Freeze

>Some Best Practices for Silverlight Application Development (XAML)

>

I was working with WPF/Silverlight since March 2008 and learnt lots of things. I wrote lots of Articles on Silverlight and published in my Blog. Today I decided to share you some of the best practices you should follow while doing development in WPF/Silverlight. Hope, this will help you guys while writing XAML codes. Read and try to strict with the guidelines whenever you are modifying your XAML.

 

Feedbacks are always appreciated. Hence, don’t forget to leave your comments at the end. If you have any more points, please share it here. I will review them and add those here.

 

Update [08-Aug-2010]: On popular demand, I updated this post with some explanation on “Why?”.

 

Some of the XAML coding best practices mentioned below:

  • Don’t use unnecessary “xmlns” namespaces in the XAML file. This overburdens the load time of the Silverlight page (If you are using Resharper, you can do this very easily as it will change the color of the unnecessary items to Grey).
  • Don’t add same namespaces multiple times in a single XAML page. It screws up the XAML code at the time of maintenance and also loads the assembly namespace multiple times causing various memory issues at runtime.
  • Use proper name for your “xmlns” namespace prefix. For example: xmlns:commonControls is more meaningful than xmlns:cctrl. This avoids multiple declarations of namespaces in future.
  • Try avoiding “xmlns” namespace prefix name as “local”. Instead use “localControls” or “localConverters” etc. as per your namespace name. Using “local” will not give you proper meaning. In the same assembly there may be two or more namespaces (e.g. Controls, Converters etc.). In such case, it will be helpful for you to use proper prefix name to distinguish between them in proper way.
  • When adding a control that has no elements inside it, better to close it by self-closing tag “/>” instead of the hard closing tag (</TAG>). This gives more cleaner XAML code. 
  • Remove all unnecessary resource keys if they are not in use. These increases the memory uses and you may sometime encounter some animation issues due to this. If you need it at later point of time, you are always welcome to add it.
  • Don’t use extra panels (e.g. Grid, StackPanel, Canvas etc.) unless it is required.
  • Always try to use Grid as your panel first and if you require other panels, use them. Grid has the flexible UI layout and thus resizing your application will have a great effect.
  • Never try to give a name to all of your controls inside your Silverlight page as it takes unnecessary object creation at the time of load. Name only those elements which you want to use from your code behind and/or from your xaml. If you are using MVVM pattern, you can remove the naming of your controls in almost all the cases.
  • Use the Visibility property of the controls instead of the Opacity property to hide the content. Opacity to zero makes the control to hide but takes space in both memory and the UI. Other side, the Visibility property collapses the control from the UI, thus making spaces for the other controls in the same place.
  • Use proper formatting of your XAML code. This gives better look of code and also easy to maintain in future.
  • Use comments in XAML whenever require. This is useful when you revisit the code after a long time or some other person comes to work with your XAML file.
  • Try to use StaticResource instead of DynamicResource as it increases the performance and also it throws exceptions at development time. Hence, easier to identify the root cause.
  • Remove unnecessary styles & storyboard animations if they are not require at all.
  • Try to add your styles in a separate file if you want to share them across your application. If they are specific to a single page then add them in the page resource.

Save and Share!

Share/Bookmark

Posted via email from Mocha Brain Freeze

>Silverlight MVVM: An (Overly) Simplified Explanation

>

The Model

image

The Model is where the data for the application goes, The Model can contain:

  • Web Services – A Silverlight application typically needs to communicate with the web server to get the data, you can put your web service methods here.
  • Rest Services – The same as web services.
  • Generic Collections – Basically any data.

 

The View Model

image

The View Model consists of:

  • Properties – One of something. This could be a String or an Object. Implements INotifyPropertyChanged, so that any element bound to it, is automatically notified whenever it changes.
  • Collections – A collection of something. This is of type ObservableCollection, so that any element bound to it, is automatically notified whenever it changes.
  • Commands – An event that can be raised. Also, one parameter of type Object can be passed. This implements ICommand.

 

The View

image

This is the part that you can make with no code using Expression Blend.

An Outline

  • Model
    • Get your data any way you can. Usually calls to web services.
  • View Model
    • Consists of:
      • Properties – One of something. This could be a String or an Object. Implements INotifyPropertyChanged, so that any element bound to it, is automatically notified whenever it changes.
      • Collections – A collection of something. This is of type ObservableCollection, so that any element bound to it, is automatically notified whenever it changes.
      • Commands – An event that can be raised. Also, one parameter of type Object can be passed. This implements ICommand. 
        • Implemented using Behaviors. Mostly the InvokeCommandAction Behavior  
  • View
    • Properties
      • Bind to a text box, radio button, toggle button, MediaElement, trigger an animation or ViewState change
    • Collections
      • Bind to List box, TreeMenu
    • Commands
      • Implemented using InvokeCommandAction behavior
        • Bind to a ICommand in the ViewModel
        • Indicate the ICommand that you want to raise
        • Pass a parameter

Posted via email from Mocha Brain Freeze