static

Internal static variables in C, would you use them?

In C you can have external static variables that are viewable every where in the file, while internal static variables are only visible in the function but is persistent For example: #include <stdio.h> void foo_bar( void ) { static counter = 0; printf("counter is %d\n", counter); counter++; } int main( void ) {...

How do you archive an entire website for offline viewing?

We actually have burned static/archived copies of our asp.net websites for customers many times. We have used WebZip until now but we have had endless problems with crashes, downloaded pages not being re-linked correctly, etc. We basically need an application that crawls and downloads static copies of everything on our asp.net website ...

Java - static methods best practices

Let's say I have a class designed to be instantiated. I have several private "helper" methods inside the class that do not require access to any of the class members, and operate solely on their arguments, returning a result. public class Example { private Something member; public double compute() { double total = 0; ...

c# print the class name from within a static function

Is it possible to print the class name from within a static function? e.g ... public class foo { static void printName() { // Print the class name e.g. foo } } ...

Using static keyword in objective-c when defining a cached variable.

Pretty horrendous newbie question here. I'm looking at the following apple example source code: /* Cache the formatter. Normally you would use one of the date formatter styles (such as NSDateFormatterShortStyle), but here we want a specific format that excludes seconds. */ static NSDateFormatter *dateFormatter = nil; if (dateFor...

HttpContext.Current accessed in static classes

Can I call HttpContext.Current from within a static class and Method? I want to store a value on a per-user basis but want to be able to access it in a static manner. e.g. Will this work? public static class StatClass { public static string SomeThing { get { return HttpContext.Current.Items["SomeItem"].ToString(); } ...

Throwing/catching exceptions from C'tor of a static object in C++

Hi all, I have a case in which I have to read an input file in the C'tor, but sometimes this file doesn't exist. This object is usually held statically, so its C'tor is called while loading the dll. I can't catch the exception I throw if the file doesn't exist because it's too early, and my executable crashes in an ugly way. I know it's...

What is a "static" function?

Ok, I understand what is static variable is, but what is a "static" function? And why is it that if I declare function let's say "void print_matrix" in let's say a.cpp (WITHOUT a.hpp) and include "a.cpp" - I get "print_matrix@@....) already defined in a.obj", BUT if I declare it "static void print_matrix" then it compiles? UPDATE Just...

What's the best way to duplicate/extend a static class's functionality?

The application I'm working on has a single class that maintains a database connection. All members of this class are static to enforce a singleton-like pattern, so the actual connection logic is performed in a static initializer block: public class HibernateUtil { private static final SessionFactory sessionFactory; static { ...

What are the Pitfalls of using a shared static WCF Proxy Client?

I am considering using a Shared (read static) WCF proxy client for a high throughput application. I believe there is a performance gain in doing this, but I have not benchmarked this as yet. Are there some serious pitfalls to this idea? From my research I can see that there is the issue of handling the fault state, it is not clear wh...

Convert static files into MySQL entries

I am converting about 4000 text files that contain HTML into MySQL database entries. Seems like an easy way to do this would be to add a couple lines to the HTML to make them appear as XML files, then XSLT the XML into MySQL INSERT statements. (Building a CSV would also work, but less optimal IMHO). I've tried doing this but am having li...

What does "static" mean in a C program?

I've seen the word static used in different places in C code; is this like a static function/class in C# (where the implementation is shared across objects)? ...

ASP.NET/Static class Race Condition?

I have an ASP.NET application with a lot of dynamic content. The content is the same for all users belonging to a particular client. To reduce the number of database hits required per request, I decided to cache client-level data. I created a static class ("ClientCache") to hold the data. The most-often used method of the class is by ...

Moving from static language to dynamic

There are a lot of discussions all over the internet and on SO, i.e. here and here, about static vs dynamic languages. I'm not going to ask again about one vs another. Instead, my question is for those who moved (or at least tried to move) from static typed language to dynamic. I'm not talking about moderate usage of JS on your web pag...

Design considerations for a class full of static methods

As a Swing developer for as many years as one can possibly be a Swing developer, I've identified a lot of patterns that I use in laying out components. For example, I often create components that are associated with a JLabel. I usually write: JPanel panel = new JPanel(new BorderLayout()); panel.add(label, BorderLayout.NORTH); panel.ad...

Overriding static variables when subclassing.

I have a class, lets call it A, and within that class definition I have the following: static QPainterPath *path; Which is to say, I'm declaring a static (class-wide) pointer to a path object; all instances of this class will now have the same shared data member. I would like to be able to build upon this class, subclassing it into mo...

C# accessing control propertes from static void

I have form with button and checkbox. if i hit button static void is called which call non static void which shows messagebox with the checkbox.checked.toString() The problem is if i change the checkbox value it always shows false Code is using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; ...

showing video on a static web page

I have a static web site that need to display a video. I do not control the server (but know the guy who does). Is there any "host some files and add some boilerplate" ways to display the video as part of the page? I'm thinking of something that would look like an embedded youtube video. I'd rather keep stuff local (I don't have a youtu...

static member variable of a subclassed class

Is it OK to have a static member variable defined in a base class, and having several derived classes each using its own instance of this member variable? The following code compiles successfully, and prints the right output, but I am still not sure that doing something like that is a good practice. In the following example, how can it ...

getClass() and static methods: What is the best practice?

I am looking to provide some convenience through reflection to programmers who will be using my code. To achieve my desired result I would like to get the class object for classes that extend my code. Even though they can't override the static method I wish to access the information from, it would be currently helpful. I may end up si...