Strange behavior when overriding private methods

Inheriting/overriding private methods In PHP, methods (including private ones) in the subclasses are either: Copied; the scope of the original function is maintained. Replaced (“overridden”, if you want). You can see this with this code: <?php class A { //calling B::h, because static:: resolves to B:: function callH() { static::h(); } private function h() { … Read more

Calling the base class constructor from the derived class constructor

The constructor of PetStore will call a constructor of Farm; there’s no way you can prevent it. If you do nothing (as you’ve done), it will call the default constructor (Farm()); if you need to pass arguments, you’ll have to specify the base class in the initializer list: PetStore::PetStore() : Farm( neededArgument ) , idF( … Read more

Difference between Visibility.Collapsed and Visibility.Hidden

The difference is that Visibility.Hidden hides the control, but reserves the space it occupies in the layout. So it renders whitespace instead of the control. Visibilty.Collapsed does not render the control and does not reserve the whitespace. The space the control would take is ‘collapsed’, hence the name. The exact text from the MSDN: Collapsed: … Read more

XAML Grid Visibility Transition?

So as a quick example, one way of doing this; <Grid Grid.RowSpan=”2″ x:Name=”TheGrid” Margin=”30,30,0,30″ Visibility=”{Binding IsSearchEnabled, Converter={StaticResource visibilityConverter}}”> <Grid.RowDefinitions> <RowDefinition Height=”60″/> <RowDefinition Height=”*”/> </Grid.RowDefinitions> <!– Start the magic –> <Grid.RenderTransform> <TranslateTransform x:Name=”SlideIn” X=”750″ /> </Grid.RenderTransform> <Grid.Triggers> <EventTrigger RoutedEvent=”Grid.Loaded”> <BeginStoryboard> <Storyboard> <DoubleAnimationUsingKeyFrames Storyboard.TargetName=”SlideIn” Storyboard.TargetProperty=”X”> <SplineDoubleKeyFrame KeyTime=”0:0:1.25″ Value=”0″ /> </DoubleAnimationUsingKeyFrames> <DoubleAnimationUsingKeyFrames Storyboard.TargetName=”TheGrid” Storyboard.TargetProperty=”Opacity”> <SplineDoubleKeyFrame KeyTime=”0:0:1.55″ Value=”1″ /> … Read more

How to make a real private instance variable?

You can use the @private keyword inside the {} to make all subsequent variable declarations private. The default visibility is @protected (which is similar to protected in Java) and that generally works well. You’d have to specifically declare a variable as @public for it to be directly accessible outside the class. This Apple documentation has … Read more

DataTrigger where value is NOT null?

This is a bit of a cheat but I just set a default style and then overrode it using a DataTrigger if the value is null… <Style> <!– Highlight for Reviewed (Default) –> <Setter Property=”Control.Background” Value=”PaleGreen” /> <Style.Triggers> <!– Highlight for Not Reviewed –> <DataTrigger Binding=”{Binding Path=REVIEWEDBY}” Value=”{x:Null}”> <Setter Property=”Control.Background” Value=”LightIndianRed” /> </DataTrigger> </Style.Triggers> </Style>

What is the difference between the hidden attribute (HTML5) and the display:none rule (CSS)?

The key difference seems to be that hidden elements are always hidden regardless of the presentation: The hidden attribute must not be used to hide content that could legitimately be shown in another presentation. For example, it is incorrect to use hidden to hide panels in a tabbed dialog, because the tabbed interface is merely … Read more

Why isn’t CSS visibility working?

You cannot hover over a hidden element. One solution is to nest the element inside another container: CSS: .spoiler span { visibility: hidden; } .spoiler:hover span { visibility: visible; } HTML: Spoiler: <span class=”spoiler”><span>E.T. phones home.</span></span> Demo: http://jsfiddle.net/DBXuv/ Update On Chrome, the following can be added: .spoiler { outline: 1px solid transparent; } Updated demo: … Read more

How to demonstrate java multithreading visibility problems?

By modifying the example here by removing operations I have come up with an example that consistently fails in my environment (the thread never stops running). // Java environment: // java version “1.6.0_0” // OpenJDK Runtime Environment (IcedTea6 1.6.1) (6b16-1.6.1-3ubuntu3) // OpenJDK 64-Bit Server VM (build 14.0-b16, mixed mode) public class Test2 extends Thread { … Read more